use of org.wso2.carbon.identity.oauth2.token.OauthTokenIssuerImpl in project identity-inbound-auth-oauth by wso2-extensions.
the class UserInfoResponseBaseTest method mockObjectsRelatedToTokenValidation.
protected void mockObjectsRelatedToTokenValidation() throws Exception {
mockStatic(OAuthServerConfiguration.class);
when(OAuthServerConfiguration.getInstance()).thenReturn(oAuthServerConfiguration);
when(OAuthServerConfiguration.getInstance().getOAuthTokenGenerator()).thenReturn(oAuthIssuer);
when(OAuthServerConfiguration.getInstance().getSignatureAlgorithm()).thenReturn("SHA256withRSA");
when(OAuth2Util.getAccessTokenIdentifier(any())).thenCallRealMethod();
when(OAuth2Util.findAccessToken(anyString(), anyBoolean())).thenCallRealMethod();
when(OAuth2Util.class, "getAccessTokenDOFromMatchingTokenIssuer", anyString(), anyMap(), anyBoolean()).thenCallRealMethod();
AccessTokenDO accessTokenDO = new AccessTokenDO();
accessTokenDO.setAccessToken(accessToken);
when(OAuth2Util.getAccessTokenDOFromTokenIdentifier(anyString(), anyBoolean())).thenReturn(accessTokenDO);
Map<String, OauthTokenIssuer> oauthTokenIssuerMap = new HashMap<>();
oauthTokenIssuerMap.put(DEFAULT_TOKEN_TYPE, new OauthTokenIssuerImpl());
oauthTokenIssuerMap.put(JWT_TOKEN_TYPE, new JWTTokenIssuer());
when(OAuthServerConfiguration.getInstance().getOauthTokenIssuerMap()).thenReturn(oauthTokenIssuerMap);
}
use of org.wso2.carbon.identity.oauth2.token.OauthTokenIssuerImpl in project identity-inbound-auth-oauth by wso2-extensions.
the class TokenValidationHandlerTest method mockRequiredObjects.
protected void mockRequiredObjects() throws Exception {
mockStatic(OAuthServerConfiguration.class);
when(OAuthServerConfiguration.getInstance()).thenReturn(oAuthServerConfiguration);
when(OAuthServerConfiguration.getInstance().getOAuthTokenGenerator()).thenReturn(oAuthIssuer);
when(OAuthServerConfiguration.getInstance().getSignatureAlgorithm()).thenReturn("SHA256withRSA");
when(OAuthServerConfiguration.getInstance().getHashAlgorithm()).thenReturn("SHA-256");
Map<String, OauthTokenIssuer> oauthTokenIssuerMap = new HashMap<>();
oauthTokenIssuerMap.put(DEFAULT_TOKEN_TYPE, new OauthTokenIssuerImpl());
oauthTokenIssuerMap.put(JWT_TOKEN_TYPE, new JWTTokenIssuer());
when(OAuthServerConfiguration.getInstance().getOauthTokenIssuerMap()).thenReturn(oauthTokenIssuerMap);
mockStatic(IdentityDatabaseUtil.class);
when(IdentityDatabaseUtil.getDBConnection(false)).thenReturn(getDBConnection());
when(IdentityDatabaseUtil.getDBConnection()).thenReturn(getDBConnection());
}
use of org.wso2.carbon.identity.oauth2.token.OauthTokenIssuerImpl in project identity-inbound-auth-oauth by wso2-extensions.
the class AbstractAuthorizationGrantHandlerTest method setUp.
@BeforeMethod
public void setUp() throws IdentityOAuthAdminException, IdentityOAuth2Exception {
authenticatedUser = new AuthenticatedUser() {
};
OAuthComponentServiceHolder.getInstance().setRealmService(IdentityTenantUtil.getRealmService());
authenticatedUser.setUserName("randomUser");
authenticatedUser.setTenantDomain("Homeless");
authenticatedUser.setUserStoreDomain("Street");
authenticatedUser.setUserId("4b4414e1-916b-4475-aaee-6b0751c29ff6");
clientId = UUID.randomUUID().toString();
tokenId = clientId;
appId = clientId;
oauthIssuer = new OauthTokenIssuerImpl();
handler = new MockAuthzGrantHandler();
handler.init();
OAuthAppDAO oAuthAppDAO = new OAuthAppDAO();
oAuthAppDO = new OAuthAppDO();
oAuthAppDO.setApplicationName(appId);
oAuthAppDO.setOauthConsumerKey(clientId);
oAuthAppDO.setUser(authenticatedUser);
oAuthAppDO.setCallbackUrl("http://i.have.nowhere.to.go");
oAuthAppDO.setOauthVersion(OAuthConstants.OAuthVersions.VERSION_2);
oAuthAppDAO.addOAuthApplication(oAuthAppDO);
}
use of org.wso2.carbon.identity.oauth2.token.OauthTokenIssuerImpl in project identity-inbound-auth-oauth by wso2-extensions.
the class SAML2BearerGrantHandlerTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
System.setProperty(CarbonBaseConstants.CARBON_HOME, Paths.get(System.getProperty("user.dir"), "src", "test", "resources").toString());
mockStatic(OAuthServerConfiguration.class);
mockStatic(IdentityUtil.class);
mockStatic(UnmarshallUtils.class);
when(OAuthServerConfiguration.getInstance()).thenReturn(oAuthServerConfiguration);
when(oAuthServerConfiguration.getIdentityOauthTokenIssuer()).thenReturn(oauthIssuer);
when(oAuthServerConfiguration.getPersistenceProcessor()).thenReturn(persistenceProcessor);
federatedAuthenticatorConfig = new FederatedAuthenticatorConfig();
saml2BearerGrantHandler = new SAML2BearerGrantHandler();
saml2BearerGrantHandler.init();
oAuth2AccessTokenReqDTO = new OAuth2AccessTokenReqDTO();
oAuth2AccessTokenReqDTO.setScope(SCOPE_ARRAY);
tokReqMsgCtx = new OAuthTokenReqMessageContext(oAuth2AccessTokenReqDTO);
tokReqMsgCtx.setTenantID(-1234);
oauthIssuer = new OauthTokenIssuerImpl();
}
use of org.wso2.carbon.identity.oauth2.token.OauthTokenIssuerImpl in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuthServerConfiguration method getIdentityOauthTokenIssuer.
/**
* Returns server level default identity oauth token issuer
*
* @return instance of default identity oauth token issuer
*/
public OauthTokenIssuer getIdentityOauthTokenIssuer() {
if (oauthIdentityTokenGenerator == null) {
synchronized (this) {
if (oauthIdentityTokenGenerator == null) {
try {
if (oauthIdentityTokenGeneratorClassName != null) {
Class clazz = this.getClass().getClassLoader().loadClass(oauthIdentityTokenGeneratorClassName);
oauthIdentityTokenGenerator = (OauthTokenIssuer) clazz.newInstance();
log.info("An instance of " + oauthIdentityTokenGeneratorClassName + " is created for Identity OAuth token generation.");
} else {
oauthIdentityTokenGenerator = new OauthTokenIssuerImpl();
log.info("The default Identity OAuth token issuer will be used. No custom token " + "generator is set.");
}
} catch (Exception e) {
String errorMsg = "Error when instantiating the OAuthIssuer : " + tokenPersistenceProcessorClassName + ". Defaulting to OAuthIssuerImpl";
log.error(errorMsg, e);
oauthIdentityTokenGenerator = new OauthTokenIssuerImpl();
}
}
}
}
return oauthIdentityTokenGenerator;
}
Aggregations