use of org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeRespDTO in project identity-inbound-auth-oauth by wso2-extensions.
the class OpenIDConnectSystemClaimImplTest method setUp.
@BeforeClass
public void setUp() throws Exception {
oAuth2AccessTokenReqDTO = new OAuth2AccessTokenReqDTO();
oAuthTokenReqMessageContext = new OAuthTokenReqMessageContext(oAuth2AccessTokenReqDTO);
oAuth2AccessTokenRespDTO = new OAuth2AccessTokenRespDTO();
oAuth2AuthorizeReqDTO = new OAuth2AuthorizeReqDTO();
oAuthAuthzReqMessageContext = new OAuthAuthzReqMessageContext(oAuth2AuthorizeReqDTO);
oAuth2AuthorizeRespDTO = new OAuth2AuthorizeRespDTO();
openIDConnectSystemClaim = new OpenIDConnectSystemClaimImpl();
}
use of org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeRespDTO in project identity-inbound-auth-oauth by wso2-extensions.
the class ClaimProviderImpl method getAdditionalClaims.
@Override
public Map<String, Object> getAdditionalClaims(OAuthAuthzReqMessageContext oAuthAuthzReqMessageContext, OAuth2AuthorizeRespDTO oAuth2AuthorizeRespDTO) throws IdentityOAuth2Exception {
Map<String, Object> additionalClaims = new HashMap<>();
String claimValue;
OIDCSessionState previousSession = getSessionState(oAuthAuthzReqMessageContext);
if (previousSession == null) {
// If there is no previous browser session, generate new sid value.
claimValue = UUID.randomUUID().toString();
if (log.isDebugEnabled()) {
log.debug("sid claim is generated for auth request. ");
}
} else {
// Previous browser session exists, get sid claim from OIDCSessionState.
claimValue = previousSession.getSidClaim();
if (log.isDebugEnabled()) {
log.debug("sid claim is found in the session state");
}
}
additionalClaims.put(OAuthConstants.OIDCClaims.SESSION_ID_CLAIM, claimValue);
oAuth2AuthorizeRespDTO.setOidcSessionId(claimValue);
return additionalClaims;
}
use of org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeRespDTO in project identity-inbound-auth-oauth by wso2-extensions.
the class DeviceFlowResponseTypeHandler method issue.
/**
* This method is used to handle the response type. After authentication process finish this will redirect to the
* constant page.
*
* @param oauthAuthzMsgCtx Authorization message context.
* @return Response DTO.
* @throws IdentityOAuth2Exception Error at device response type handler.
*/
@Override
public OAuth2AuthorizeRespDTO issue(OAuthAuthzReqMessageContext oauthAuthzMsgCtx) throws IdentityOAuth2Exception {
OAuth2AuthorizeRespDTO respDTO = new OAuth2AuthorizeRespDTO();
OAuth2AuthorizeReqDTO authzReqDTO = oauthAuthzMsgCtx.getAuthorizationReqDTO();
AuthenticatedUser authenticatedUser = authzReqDTO.getUser();
String userCode = authzReqDTO.getNonce();
DeviceFlowPersistenceFactory.getInstance().getDeviceFlowDAO().setAuthzUserAndStatus(userCode, Constants.AUTHORIZED, authenticatedUser);
respDTO.setCallbackURI(authzReqDTO.getCallbackUrl());
return respDTO;
}
use of org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeRespDTO in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2ServiceTest method testAuthorizeWithException.
@Test
public void testAuthorizeWithException() throws IdentityOAuth2Exception {
mockStatic(IdentityTenantUtil.class);
when(IdentityTenantUtil.getTenantId(anyString())).thenReturn(-1234);
String callbackUrl = "dummyCallBackUrl";
mockStatic(AuthorizationHandlerManager.class);
when(oAuth2AuthorizeReqDTO.getCallbackUrl()).thenReturn(callbackUrl);
when(AuthorizationHandlerManager.getInstance()).thenThrow(new IdentityOAuth2Exception("Error while creating AuthorizationHandlerManager instance"));
OAuth2AuthorizeRespDTO oAuth2AuthorizeRespDTO = oAuth2Service.authorize(oAuth2AuthorizeReqDTO);
assertNotNull(oAuth2AuthorizeRespDTO);
}
use of org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeRespDTO in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2ServiceTest method testAuthorize.
@Test
public void testAuthorize() throws Exception {
mockStatic(AuthorizationHandlerManager.class);
when(AuthorizationHandlerManager.getInstance()).thenReturn(authorizationHandlerManager);
when(authorizationHandlerManager.handleAuthorization((OAuth2AuthorizeReqDTO) anyObject())).thenReturn(mockedOAuth2AuthorizeRespDTO);
when(oAuthServerConfiguration.getTimeStampSkewInSeconds()).thenReturn(300L);
OAuth2AuthorizeRespDTO oAuth2AuthorizeRespDTO = oAuth2Service.authorize(oAuth2AuthorizeReqDTO);
assertNotNull(oAuth2AuthorizeRespDTO);
}
Aggregations