use of org.wso2.carbon.user.core.common.AuthenticationResult in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2AuthzEndpointTest method testBuildOAuthProblemException.
@Test(dataProvider = "provideFailedAuthenticationErrorInfo")
public void testBuildOAuthProblemException(Object oAuthErrorDTOObject, Object authenticationResultObject, String expectedCode, String expectedMessage, String expectedURI) throws Exception {
OAuthErrorDTO oAuthErrorDTO = (OAuthErrorDTO) oAuthErrorDTOObject;
AuthenticationResult authenticationResult = (AuthenticationResult) authenticationResultObject;
Assert.assertEquals(expectedCode, oAuth2AuthzEndpoint.buildOAuthProblemException(authenticationResult, oAuthErrorDTO).getError());
Assert.assertEquals(expectedMessage, oAuth2AuthzEndpoint.buildOAuthProblemException(authenticationResult, oAuthErrorDTO).getDescription());
Assert.assertEquals(expectedURI, oAuth2AuthzEndpoint.buildOAuthProblemException(authenticationResult, oAuthErrorDTO).getUri());
}
use of org.wso2.carbon.user.core.common.AuthenticationResult in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2AuthzEndpointTest method provideFailedAuthenticationErrorInfo.
@DataProvider(name = "provideFailedAuthenticationErrorInfo")
public Object[][] provideFailedAuthenticationErrorInfo() {
OAuthErrorDTO oAuthErrorDTO = null;
AuthenticationResult authenticationResult = new AuthenticationResult();
authenticationResult.addProperty(FrameworkConstants.AUTH_ERROR_URI, null);
authenticationResult.addProperty(FrameworkConstants.AUTH_ERROR_MSG, null);
authenticationResult.addProperty(FrameworkConstants.AUTH_ERROR_CODE, null);
OAuthErrorDTO oAuthErrorDTONull = new OAuthErrorDTO();
AuthenticationResult authenticationResultEmpty = new AuthenticationResult();
OAuthErrorDTO oAuthErrorDTOEmpty = new OAuthErrorDTO();
AuthenticationResult authenticationResultWithURI = new AuthenticationResult();
authenticationResultWithURI.addProperty(FrameworkConstants.AUTH_ERROR_URI, "http://sample_error_uri.com");
authenticationResultWithURI.addProperty(FrameworkConstants.AUTH_ERROR_MSG, null);
authenticationResultWithURI.addProperty(FrameworkConstants.AUTH_ERROR_CODE, null);
OAuthErrorDTO oAuthErrorDTOEmptyTest = new OAuthErrorDTO();
AuthenticationResult authenticationResultWithoutErrorcode = new AuthenticationResult();
authenticationResultWithoutErrorcode.addProperty(FrameworkConstants.AUTH_ERROR_MSG, "OverRiddenMessage2");
authenticationResultWithoutErrorcode.addProperty(FrameworkConstants.AUTH_ERROR_URI, "http://sample_error_uri2.com");
authenticationResultWithoutErrorcode.addProperty(FrameworkConstants.AUTH_ERROR_CODE, null);
OAuthErrorDTO oAuthErrorDTOWithDes = new OAuthErrorDTO();
oAuthErrorDTOWithDes.setErrorDescription("messageFromErrorDTO");
AuthenticationResult authenticationResultWithURIOnly = new AuthenticationResult();
authenticationResultWithURIOnly.addProperty(FrameworkConstants.AUTH_ERROR_URI, "http://sample_error_uri3.com");
authenticationResultWithURIOnly.addProperty(FrameworkConstants.AUTH_ERROR_MSG, null);
authenticationResultWithURIOnly.addProperty(FrameworkConstants.AUTH_ERROR_CODE, null);
OAuthErrorDTO oAuthErrorDTOOverWritable = new OAuthErrorDTO();
oAuthErrorDTOOverWritable.setErrorDescription("messageFromErrorDTO");
AuthenticationResult authenticationResultOverRiding = new AuthenticationResult();
authenticationResultOverRiding.addProperty(FrameworkConstants.AUTH_ERROR_MSG, "OverRiddenMessage5");
authenticationResultOverRiding.addProperty(FrameworkConstants.AUTH_ERROR_URI, "http://sample_error_uri4.com");
authenticationResultOverRiding.addProperty(FrameworkConstants.AUTH_ERROR_CODE, null);
return new Object[][] { { null, authenticationResult, "login_required", "Authentication required", null }, { oAuthErrorDTONull, authenticationResultEmpty, "login_required", "Authentication required", null }, { oAuthErrorDTOEmptyTest, authenticationResultWithURI, "login_required", "Authentication required", "http" + "://sample_error_uri.com" }, { oAuthErrorDTOEmptyTest, authenticationResultWithoutErrorcode, "login_required", "OverRiddenMessage2", "http" + "://sample_error_uri2.com" }, { oAuthErrorDTOWithDes, authenticationResultWithURIOnly, "login_required", "messageFromErrorDTO", "http" + "://sample_error_uri3.com" }, { oAuthErrorDTOOverWritable, authenticationResultOverRiding, "login_required", "OverRiddenMessage5", "http" + "://sample_error_uri4.com" } };
}
use of org.wso2.carbon.user.core.common.AuthenticationResult in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2AuthzEndpoint method handleFailedAuthentication.
private Response handleFailedAuthentication(OAuthMessage oAuthMessage, OAuth2Parameters oauth2Params, AuthenticationResult authnResult) throws URISyntaxException {
OAuthErrorDTO oAuthErrorDTO = EndpointUtil.getOAuth2Service().handleAuthenticationFailure(oauth2Params);
OAuthProblemException oauthException = buildOAuthProblemException(authnResult, oAuthErrorDTO);
return handleFailedState(oAuthMessage, oauth2Params, oauthException);
}
use of org.wso2.carbon.user.core.common.AuthenticationResult in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2AuthzEndpoint method getAuthenticationResult.
private AuthenticationResult getAuthenticationResult(OAuthMessage oAuthMessage, String sessionDataKey) {
AuthenticationResult result = getAuthenticationResultFromRequest(oAuthMessage.getRequest());
if (result == null) {
isCacheAvailable = true;
result = getAuthenticationResultFromCache(sessionDataKey);
}
return result;
}
use of org.wso2.carbon.user.core.common.AuthenticationResult in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2AuthzEndpoint method getAuthenticationResultFromCache.
private AuthenticationResult getAuthenticationResultFromCache(String sessionDataKey) {
AuthenticationResult authResult = null;
AuthenticationResultCacheEntry authResultCacheEntry = FrameworkUtils.getAuthenticationResultFromCache(sessionDataKey);
if (authResultCacheEntry != null) {
authResult = authResultCacheEntry.getResult();
} else {
log.error("Cannot find AuthenticationResult from the cache");
}
return authResult;
}
Aggregations