use of org.wso2.carbon.identity.application.authentication.framework.context.AuthHistory in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandlerFailTest method handleFailMethodWithoutParamsOnFailTest.
@Test
public void handleFailMethodWithoutParamsOnFailTest() throws Exception {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID);
ServiceProvider sp1 = getTestServiceProvider("js-sp-fail-method-without-params-onFail.xml");
AuthenticationContext context = getAuthenticationContext(sp1);
SequenceConfig sequenceConfig = configurationLoader.getSequenceConfig(context, Collections.<String, String[]>emptyMap(), sp1);
context.setSequenceConfig(sequenceConfig);
HttpServletRequest req = mock(HttpServletRequest.class);
when(req.getAttribute(FrameworkConstants.RequestParams.FLOW_STATUS)).thenReturn(AuthenticatorFlowStatus.FAIL_COMPLETED);
HttpServletResponse resp = mock(HttpServletResponse.class);
UserCoreUtil.setDomainInThreadLocal("test_domain");
graphBasedSequenceHandler.handle(req, resp, context);
List<AuthHistory> authHistories = context.getAuthenticationStepHistory();
assertNotNull(authHistories);
assertFalse(context.isRequestAuthenticated());
}
use of org.wso2.carbon.identity.application.authentication.framework.context.AuthHistory in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandlerNoJsTest method testHandleStaticSequence.
@Test(dataProvider = "noJsDataProvider")
public void testHandleStaticSequence(String spFileName, int authHistoryCount) throws Exception {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID);
ServiceProvider sp1 = getTestServiceProvider(spFileName);
AuthenticationContext context = getAuthenticationContext(sp1);
SequenceConfig sequenceConfig = configurationLoader.getSequenceConfig(context, Collections.emptyMap(), sp1);
context.setSequenceConfig(sequenceConfig);
HttpServletRequest req = mock(HttpServletRequest.class);
HttpServletResponse resp = mock(HttpServletResponse.class);
UserCoreUtil.setDomainInThreadLocal("test_domain");
graphBasedSequenceHandler.handle(req, resp, context);
List<AuthHistory> authHistories = context.getAuthenticationStepHistory();
assertNotNull(authHistories);
assertEquals(authHistories.size(), authHistoryCount);
}
use of org.wso2.carbon.identity.application.authentication.framework.context.AuthHistory in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2AuthzEndpoint method associateAuthenticationHistory.
/**
* Associates the authentication method references done while logged into the session (if any) to the OAuth cache.
* The SessionDataCacheEntry then will be used when getting "AuthenticationMethodReferences". Please see
* <a href="https://tools.ietf.org/html/draft-ietf-oauth-amr-values-02" >draft-ietf-oauth-amr-values-02</a>.
*
* @param resultFromLogin
* @param cookie
*/
private void associateAuthenticationHistory(SessionDataCacheEntry resultFromLogin, Cookie cookie) {
SessionContext sessionContext = getSessionContext(cookie, resultFromLogin.getoAuth2Parameters().getLoginTenantDomain());
if (sessionContext != null && sessionContext.getSessionAuthHistory() != null && sessionContext.getSessionAuthHistory().getHistory() != null) {
List<String> authMethods = new ArrayList<>();
for (AuthHistory authHistory : sessionContext.getSessionAuthHistory().getHistory()) {
authMethods.add(authHistory.toTranslatableString());
}
resultFromLogin.getParamMap().put(OAuthConstants.AMR, authMethods.toArray(new String[authMethods.size()]));
}
}
Aggregations