Search in sources :

Example 1 with OpenIDConnectClaimFilterImpl

use of org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl in project identity-inbound-auth-oauth by wso2-extensions.

the class UserInfoJWTResponseTest method setup.

@BeforeClass
public void setup() throws Exception {
    OAuth2ServiceComponentHolder.getInstance().setScopeClaimMappingDAO(new ScopeClaimMappingDAOImpl());
    TestUtils.initiateH2Base();
    con = TestUtils.getConnection();
    userInfoJWTResponse = new UserInfoJWTResponse();
    RequestObjectService requestObjectService = Mockito.mock(RequestObjectService.class);
    List<RequestedClaim> requestedClaims = Collections.EMPTY_LIST;
    when(requestObjectService.getRequestedClaimsForIDToken(anyString())).thenReturn(requestedClaims);
    when(requestObjectService.getRequestedClaimsForUserInfo(anyString())).thenReturn(requestedClaims);
    OpenIDConnectServiceComponentHolder.getInstance().getOpenIDConnectClaimFilters().add(new OpenIDConnectClaimFilterImpl());
    OpenIDConnectServiceComponentHolder.setRequestObjectService(requestObjectService);
}
Also used : OpenIDConnectClaimFilterImpl(org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl) RequestedClaim(org.wso2.carbon.identity.openidconnect.model.RequestedClaim) ScopeClaimMappingDAOImpl(org.wso2.carbon.identity.openidconnect.dao.ScopeClaimMappingDAOImpl) RequestObjectService(org.wso2.carbon.identity.openidconnect.RequestObjectService) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with OpenIDConnectClaimFilterImpl

use of org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl in project identity-inbound-auth-oauth by wso2-extensions.

the class UserInfoJSONResponseBuilderTest method setUpRequestObjectService.

private void setUpRequestObjectService() throws RequestObjectException {
    List<RequestedClaim> requestedClaims = Collections.emptyList();
    when(requestObjectService.getRequestedClaimsForIDToken(anyString())).thenReturn(requestedClaims);
    when(requestObjectService.getRequestedClaimsForUserInfo(anyString())).thenReturn(requestedClaims);
    OpenIDConnectServiceComponentHolder.getInstance().getOpenIDConnectClaimFilters().add(new OpenIDConnectClaimFilterImpl());
    OpenIDConnectServiceComponentHolder.setRequestObjectService(requestObjectService);
}
Also used : OpenIDConnectClaimFilterImpl(org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl) RequestedClaim(org.wso2.carbon.identity.openidconnect.model.RequestedClaim)

Example 3 with OpenIDConnectClaimFilterImpl

use of org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl in project identity-inbound-auth-oauth by wso2-extensions.

the class OpenIDConnectClaimFilterImplTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    openIDConnectClaimFilter = new OpenIDConnectClaimFilterImpl();
    scopeClaimMappingDAO = new ScopeClaimMappingDAOImpl();
    ServiceProvider serviceProvider = new ServiceProvider();
    ssoConsentService = mock(SSOConsentServiceImpl.class);
    ClaimMetadataManagementService claimMetadataManagementService = mock(ClaimMetadataManagementService.class);
    applicationMgtService = mock(ApplicationManagementService.class);
    OAuth2ServiceComponentHolder.setApplicationMgtService(applicationMgtService);
    when(applicationMgtService.getServiceProviderByClientId(CLIENT_ID, IdentityApplicationConstants.OAuth2.NAME, SP_TENANT_DOMAIN)).thenReturn(serviceProvider);
    OpenIDConnectServiceComponentHolder.getInstance().setClaimMetadataManagementService(claimMetadataManagementService);
    OpenIDConnectServiceComponentHolder.getInstance().setSsoConsentService(ssoConsentService);
    RegistryService registryService = mock(RegistryService.class);
    UserRegistry userRegistry = mock(UserRegistry.class);
    resource = new ResourceImpl();
    OAuth2ServiceComponentHolder.setRegistryService(registryService);
    when(registryService.getConfigSystemRegistry(anyInt())).thenReturn(userRegistry);
    when(userRegistry.get(anyString())).thenReturn(resource);
    List externalClaims = new ArrayList<>();
    ExternalClaim externalClaim = new ExternalClaim("testUserClaimURI", "testUserClaimURI", "testUserClaimURI");
    externalClaims.add(externalClaim);
    when(claimMetadataManagementService.getExternalClaims(anyString(), anyString())).thenReturn(externalClaims);
    List claimsWithConsent = getClaimsWithConsent();
    when(ssoConsentService.getClaimsWithConsents(any(), any())).thenReturn(claimsWithConsent);
}
Also used : ResourceImpl(org.wso2.carbon.registry.core.ResourceImpl) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) ExternalClaim(org.wso2.carbon.identity.claim.metadata.mgt.model.ExternalClaim) ArrayList(java.util.ArrayList) UserRegistry(org.wso2.carbon.registry.core.session.UserRegistry) ArrayList(java.util.ArrayList) List(java.util.List) ApplicationManagementService(org.wso2.carbon.identity.application.mgt.ApplicationManagementService) RegistryService(org.wso2.carbon.registry.core.service.RegistryService) ScopeClaimMappingDAOImpl(org.wso2.carbon.identity.openidconnect.dao.ScopeClaimMappingDAOImpl) SSOConsentServiceImpl(org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.SSOConsentServiceImpl) ClaimMetadataManagementService(org.wso2.carbon.identity.claim.metadata.mgt.ClaimMetadataManagementService) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with OpenIDConnectClaimFilterImpl

use of org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl in project identity-inbound-auth-oauth by wso2-extensions.

the class OAuth2ServiceComponent method activate.

protected void activate(ComponentContext context) {
    try {
        if (OAuth2ServiceComponentHolder.getInstance().getScopeClaimMappingDAO() == null) {
            OAuth2ServiceComponentHolder.getInstance().setScopeClaimMappingDAO(new ScopeClaimMappingDAOImpl());
        }
        loadScopeConfigFile();
        loadOauthScopeBinding();
        int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
        boolean isRecordExist = OAuthTokenPersistenceFactory.getInstance().getScopeClaimMappingDAO().hasScopesPopulated(tenantId);
        if (!isRecordExist) {
            OAuth2Util.initiateOIDCScopes(tenantId);
        }
        TenantCreationEventListener scopeTenantMgtListener = new TenantCreationEventListener();
        bundleContext = context.getBundleContext();
        // Registering TenantCreationEventListener
        ServiceRegistration scopeTenantMgtListenerSR = bundleContext.registerService(TenantMgtListener.class.getName(), scopeTenantMgtListener, null);
        if (scopeTenantMgtListenerSR != null) {
            if (log.isDebugEnabled()) {
                log.debug(" TenantMgtListener is registered");
            }
        } else {
            log.error("TenantMgtListener could not be registered");
        }
        // iniating oauth scopes
        OAuth2Util.initiateOAuthScopePermissionsBindings(tenantId);
        // exposing server configuration as a service
        OAuthServerConfiguration oauthServerConfig = OAuthServerConfiguration.getInstance();
        bundleContext.registerService(OAuthServerConfiguration.class.getName(), oauthServerConfig, null);
        OAuth2TokenValidationService tokenValidationService = new OAuth2TokenValidationService();
        bundleContext.registerService(OAuth2TokenValidationService.class.getName(), tokenValidationService, null);
        OAuthClientAuthnService clientAuthnService = new OAuthClientAuthnService();
        bundleContext.registerService(OAuthClientAuthnService.class.getName(), clientAuthnService, null);
        BasicAuthClientAuthenticator basicAuthClientAuthenticator = new BasicAuthClientAuthenticator();
        bundleContext.registerService(OAuthClientAuthenticator.class.getName(), basicAuthClientAuthenticator, null);
        PublicClientAuthenticator publicClientAuthenticator = new PublicClientAuthenticator();
        bundleContext.registerService(OAuthClientAuthenticator.class.getName(), publicClientAuthenticator, null);
        // Register cookie based access token binder.
        CookieBasedTokenBinder cookieBasedTokenBinder = new CookieBasedTokenBinder();
        bundleContext.registerService(TokenBinderInfo.class.getName(), cookieBasedTokenBinder, null);
        // SSO session based access token binder.
        SSOSessionBasedTokenBinder ssoSessionBasedTokenBinder = new SSOSessionBasedTokenBinder();
        bundleContext.registerService(TokenBinderInfo.class.getName(), ssoSessionBasedTokenBinder, null);
        if (log.isDebugEnabled()) {
            log.debug("Identity OAuth bundle is activated");
        }
        if (OAuth2ServiceComponentHolder.getKeyIDProvider() == null) {
            KeyIDProvider defaultKeyIDProvider = new DefaultKeyIDProviderImpl();
            OAuth2ServiceComponentHolder.setKeyIDProvider(defaultKeyIDProvider);
            if (log.isDebugEnabled()) {
                log.debug("Key ID Provider " + DefaultKeyIDProviderImpl.class.getSimpleName() + " registered as the default Key ID Provider implementation.");
            }
        }
        ServiceRegistration tenantMgtListenerSR = bundleContext.registerService(TenantMgtListener.class.getName(), new OAuthTenantMgtListenerImpl(), null);
        if (tenantMgtListenerSR != null) {
            if (log.isDebugEnabled()) {
                log.debug("OAuth - TenantMgtListener registered.");
            }
        } else {
            log.error("OAuth - TenantMgtListener could not be registered.");
        }
        ServiceRegistration userStoreConfigEventSR = bundleContext.registerService(UserStoreConfigListener.class.getName(), new OAuthUserStoreConfigListenerImpl(), null);
        if (userStoreConfigEventSR != null) {
            if (log.isDebugEnabled()) {
                log.debug("OAuth - UserStoreConfigListener registered.");
            }
        } else {
            log.error("OAuth - UserStoreConfigListener could not be registered.");
        }
        ServiceRegistration oauthApplicationMgtListenerSR = bundleContext.registerService(ApplicationMgtListener.class.getName(), new OAuthApplicationMgtListener(), null);
        if (oauthApplicationMgtListenerSR != null) {
            if (log.isDebugEnabled()) {
                log.debug("OAuth - ApplicationMgtListener registered.");
            }
        } else {
            log.error("OAuth - ApplicationMgtListener could not be registered.");
        }
        // PKCE enabled by default.
        OAuth2ServiceComponentHolder.setPkceEnabled(true);
        // Register device auth service.
        ServiceRegistration deviceAuthService = bundleContext.registerService(DeviceAuthService.class.getName(), new DeviceAuthServiceImpl(), null);
        if (deviceAuthService != null) {
            if (log.isDebugEnabled()) {
                log.debug("DeviceAuthService registered.");
            }
        } else {
            log.error("DeviceAuthService could not be registered.");
        }
        // Register the default OpenIDConnect claim filter
        bundleContext.registerService(OpenIDConnectClaimFilter.class, new OpenIDConnectClaimFilterImpl(), null);
        if (log.isDebugEnabled()) {
            log.debug("Default OpenIDConnect Claim filter registered successfully.");
        }
        bundleContext.registerService(AbstractEventHandler.class.getName(), new TokenBindingExpiryEventHandler(), null);
        if (log.isDebugEnabled()) {
            log.debug("TokenBindingExpiryEventHandler is successfully registered.");
        }
        // Registering OAuth2Service as a OSGIService
        bundleContext.registerService(OAuth2Service.class.getName(), new OAuth2Service(), null);
        // Registering OAuth2ScopeService as a OSGIService
        bundleContext.registerService(OAuth2ScopeService.class.getName(), new OAuth2ScopeService(), null);
    // Note : DO NOT add any activation related code below this point,
    // to make sure the server doesn't start up if any activation failures occur
    } catch (Throwable e) {
        String errMsg = "Error while activating OAuth2ServiceComponent.";
        log.error(errMsg, e);
        throw new RuntimeException(errMsg, e);
    }
    if (checkAudienceEnabled()) {
        if (log.isDebugEnabled()) {
            log.debug("OAuth - OIDC audiences enabled.");
        }
        OAuth2ServiceComponentHolder.setAudienceEnabled(true);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("OAuth - OIDC audiences disabled.");
        }
        OAuth2ServiceComponentHolder.setAudienceEnabled(false);
    }
    if (checkIDPIdColumnAvailable()) {
        if (log.isDebugEnabled()) {
            log.debug("IDP_ID column is available in all relevant tables. " + "Setting isIDPIdColumnEnabled to true.");
        }
        OAuth2ServiceComponentHolder.setIDPIdColumnEnabled(true);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("IDP_ID column is not available in all relevant tables. " + "Setting isIDPIdColumnEnabled to false.");
        }
        OAuth2ServiceComponentHolder.setIDPIdColumnEnabled(false);
    }
}
Also used : TokenBindingExpiryEventHandler(org.wso2.carbon.identity.oauth2.token.bindings.handlers.TokenBindingExpiryEventHandler) KeyIDProvider(org.wso2.carbon.identity.oauth2.keyidprovider.KeyIDProvider) OAuthServerConfiguration(org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration) TokenBinderInfo(org.wso2.carbon.identity.oauth.common.token.bindings.TokenBinderInfo) ApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener) OAuth2ScopeService(org.wso2.carbon.identity.oauth2.OAuth2ScopeService) TenantMgtListener(org.wso2.carbon.stratos.common.listeners.TenantMgtListener) CookieBasedTokenBinder(org.wso2.carbon.identity.oauth2.token.bindings.impl.CookieBasedTokenBinder) SSOSessionBasedTokenBinder(org.wso2.carbon.identity.oauth2.token.bindings.impl.SSOSessionBasedTokenBinder) ServiceRegistration(org.osgi.framework.ServiceRegistration) OAuthClientAuthenticator(org.wso2.carbon.identity.oauth2.client.authentication.OAuthClientAuthenticator) OAuth2Service(org.wso2.carbon.identity.oauth2.OAuth2Service) OAuthClientAuthnService(org.wso2.carbon.identity.oauth2.client.authentication.OAuthClientAuthnService) DefaultKeyIDProviderImpl(org.wso2.carbon.identity.oauth2.keyidprovider.DefaultKeyIDProviderImpl) UserStoreConfigListener(org.wso2.carbon.identity.user.store.configuration.listener.UserStoreConfigListener) TenantCreationEventListener(org.wso2.carbon.identity.oauth2.listener.TenantCreationEventListener) PublicClientAuthenticator(org.wso2.carbon.identity.oauth2.client.authentication.PublicClientAuthenticator) BasicAuthClientAuthenticator(org.wso2.carbon.identity.oauth2.client.authentication.BasicAuthClientAuthenticator) ScopeClaimMappingDAOImpl(org.wso2.carbon.identity.openidconnect.dao.ScopeClaimMappingDAOImpl) OpenIDConnectClaimFilterImpl(org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl) DeviceAuthService(org.wso2.carbon.identity.oauth2.device.api.DeviceAuthService) AbstractEventHandler(org.wso2.carbon.identity.event.handler.AbstractEventHandler) OAuth2TokenValidationService(org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService) DeviceAuthServiceImpl(org.wso2.carbon.identity.oauth2.device.api.DeviceAuthServiceImpl)

Example 5 with OpenIDConnectClaimFilterImpl

use of org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl in project identity-inbound-auth-oauth by wso2-extensions.

the class DefaultIDTokenBuilderTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    user = getDefaultAuthenticatedLocalUser();
    messageContext = getTokenReqMessageContextForUser(user, CLIENT_ID);
    messageContext.addProperty(AUTHORIZATION_CODE, AUTHORIZATION_CODE_VALUE);
    tokenRespDTO = new OAuth2AccessTokenRespDTO();
    tokenRespDTO.setAccessToken(ACCESS_TOKEN);
    IdentityProvider idp = new IdentityProvider();
    idp.setIdentityProviderName("LOCAL");
    idp.setEnable(true);
    Map<String, Object> configuration = new HashMap<>();
    configuration.put("SSOService.EntityId", "LOCAL");
    configuration.put("SSOService.SAMLECPEndpoint", "https://localhost:9443/samlecp");
    configuration.put("SSOService.ArtifactResolutionEndpoint", "https://localhost:9443/samlartresolve");
    configuration.put("OAuth.OpenIDConnect.IDTokenIssuerID", "https://localhost:9443/oauth2/token");
    WhiteboxImpl.setInternalState(IdentityUtil.class, "configuration", configuration);
    IdentityProviderManager.getInstance().addResidentIdP(idp, SUPER_TENANT_DOMAIN_NAME);
    defaultIDTokenBuilder = new DefaultIDTokenBuilder();
    Map<ClaimMapping, String> userAttributes = new HashMap<>();
    userAttributes.put(SAML2BearerGrantHandlerTest.buildClaimMapping("username"), "username");
    userAttributes.put(SAML2BearerGrantHandlerTest.buildClaimMapping("email"), "email");
    userAttributes.put(SAML2BearerGrantHandlerTest.buildClaimMapping(PHONE_NUMBER_VERIFIED), "phone");
    LinkedHashSet acrValuesHashSet = new LinkedHashSet<>();
    acrValuesHashSet.add(new Object());
    AuthorizationGrantCacheEntry authorizationGrantCacheEntry = new AuthorizationGrantCacheEntry(userAttributes);
    authorizationGrantCacheEntry.setSubjectClaim(messageContext.getAuthorizedUser().getUserName());
    authorizationGrantCacheEntry.setNonceValue("nonce");
    authorizationGrantCacheEntry.addAmr("amr");
    authorizationGrantCacheEntry.setSessionContextIdentifier("idp");
    authorizationGrantCacheEntry.setAuthTime(1000);
    authorizationGrantCacheEntry.setSelectedAcrValue("acr");
    authorizationGrantCacheEntry.setSubjectClaim("user@carbon.super");
    authorizationGrantCacheEntry.setEssentialClaims(getEssentialClaims());
    AuthorizationGrantCacheKey authorizationGrantCacheKey = new AuthorizationGrantCacheKey(AUTHORIZATION_CODE_VALUE);
    AuthorizationGrantCacheKey authorizationGrantCacheKeyForAccessToken = new AuthorizationGrantCacheKey("2sa9a678f890877856y66e75f605d456");
    AuthorizationGrantCache.getInstance().addToCacheByToken(authorizationGrantCacheKey, authorizationGrantCacheEntry);
    AuthorizationGrantCache.getInstance().addToCacheByToken(authorizationGrantCacheKeyForAccessToken, authorizationGrantCacheEntry);
    ServiceProviderProperty serviceProviderProperty = new ServiceProviderProperty();
    ServiceProviderProperty[] serviceProviders = new ServiceProviderProperty[] { serviceProviderProperty };
    ServiceProvider serviceProvider = new ServiceProvider();
    serviceProvider.setSpProperties(serviceProviders);
    serviceProvider.setCertificateContent("MIIDWTCCAkGgAwIBAgIEcZgeVDANBgkqhkiG9w0BAQsFADBcMQswCQYDVQQGEwJG\n" + "UjEMMAoGA1UECBMDTVBMMQwwCgYDVQQHEwNNUEwxDTALBgNVBAoTBHRlc3QxDTAL\n" + "BgNVBAsTBHRlc3QxEzARBgNVBAMMCioudGVzdC5jb20wIBcNMjEwNTEwMTcwODU4\n" + "WhgPMjA1MTA1MDMxNzA4NThaMFwxCzAJBgNVBAYTAkZSMQwwCgYDVQQIEwNNUEwx\n" + "DDAKBgNVBAcTA01QTDENMAsGA1UEChMEdGVzdDENMAsGA1UECxMEdGVzdDETMBEG\n" + "A1UEAwwKKi50ZXN0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" + "AIkuoEuR/or5oL4h6TZ7r90Qyb1xAK6qrAHGCGWz5k1dnmCdvM39zBZF5EDGVKKe\n" + "p+BQWNgG+FST19Z2l71YJllKxVsI0syw3r9PXcAfVLahs3fn8HEa5uJqIdHRsVzz\n" + "uO+rEWYn7kx4jmwwqtb8HBnhlVgn32OWQ6X4mLll/1n87cWGMsNouVP5TCySFNyD\n" + "BFPzC3+gYiVVy7Aj1NBw6Ft4i4r0UIOZ8BPGfHrd7zB4Zmnc9KwyRNj+S3bvJECm\n" + "D1/9hMiHcIj46qnvLJw69f/HmL3LTmp1oQJUnFlA0hykrUcwjVjUEptcBMu627j4\n" + "kfY2xsI613k5NLi6eHlwx7cCAwEAAaMhMB8wHQYDVR0OBBYEFIg+fWViskGrce5K\n" + "48Oy9x1Mh0GTMA0GCSqGSIb3DQEBCwUAA4IBAQB76yS+Wkt2RBh4XEihiMsrgn9L\n" + "2RkxAvDldfVEZTtQHm0uOkjT53AG8RSK5tedWdETJnEa0cq9SGLBjuTB5ojjP18g\n" + "R3fT2HXiP2QDfqnEhj7SYOEPp+QjcgW7rPBpMVOe9qKU6BWw0/ufEFq/SgSb9/xV\n" + "dZa4puEYDVEJ4pu6uJuh/oXgvwcIcL6xURDav1gqTDuMrLnJrKui+FsabnWeC+XB\n" + "1mRWtpZPay9xB5kVWAEVdMtGePP0/wz2zxQU9uCmjwvIsIfx307CpBI54sjomXPU\n" + "DldsCG6l8QRJ3NvijWa/0olA/7BpaOtbNS6S5dBSfPScpUvVQiBYFFvMXbmd\n");
    ApplicationManagementService applicationMgtService = mock(ApplicationManagementService.class);
    OAuth2ServiceComponentHolder.setApplicationMgtService(applicationMgtService);
    Map<String, ServiceProvider> fileBasedSPs = CommonTestUtils.getFileBasedSPs();
    setFinalStatic(ApplicationManagementServiceComponent.class.getDeclaredField("fileBasedSPs"), fileBasedSPs);
    when(applicationMgtService.getApplicationExcludingFileBasedSPs(TEST_APPLICATION_NAME, SUPER_TENANT_DOMAIN_NAME)).thenReturn(fileBasedSPs.get(TEST_APPLICATION_NAME));
    when(applicationMgtService.getServiceProviderNameByClientId(anyString(), anyString(), anyString())).thenReturn(TEST_APPLICATION_NAME);
    when(applicationMgtService.getServiceProviderByClientId(anyString(), anyString(), anyString())).thenReturn(serviceProvider);
    AuthenticationMethodNameTranslator authenticationMethodNameTranslator = new AuthenticationMethodNameTranslatorImpl();
    OAuth2ServiceComponentHolder.setAuthenticationMethodNameTranslator(authenticationMethodNameTranslator);
    RealmService realmService = IdentityTenantUtil.getRealmService();
    HashMap<String, String> claims = new HashMap<>();
    claims.put("http://wso2.org/claims/username", TestConstants.USER_NAME);
    realmService.getTenantUserRealm(SUPER_TENANT_ID).getUserStoreManager().addUser(TestConstants.USER_NAME, TestConstants.PASSWORD, new String[0], claims, TestConstants.DEFAULT_PROFILE);
    Map<Integer, Certificate> publicCerts = new ConcurrentHashMap<>();
    publicCerts.put(SUPER_TENANT_ID, ReadCertStoreSampleUtil.createKeyStore(getClass()).getCertificate("wso2carbon"));
    setFinalStatic(OAuth2Util.class.getDeclaredField("publicCerts"), publicCerts);
    Map<Integer, Key> privateKeys = new ConcurrentHashMap<>();
    privateKeys.put(SUPER_TENANT_ID, ReadCertStoreSampleUtil.createKeyStore(getClass()).getKey("wso2carbon", "wso2carbon".toCharArray()));
    setFinalStatic(OAuth2Util.class.getDeclaredField("privateKeys"), privateKeys);
    OpenIDConnectServiceComponentHolder.getInstance().getOpenIDConnectClaimFilters().add(new OpenIDConnectClaimFilterImpl());
    RequestObjectService requestObjectService = Mockito.mock(RequestObjectService.class);
    List<RequestedClaim> requestedClaims = Collections.EMPTY_LIST;
    when(requestObjectService.getRequestedClaimsForIDToken(anyString())).thenReturn(requestedClaims);
    when(requestObjectService.getRequestedClaimsForUserInfo(anyString())).thenReturn(requestedClaims);
    OpenIDConnectServiceComponentHolder.getInstance().getOpenIDConnectClaimFilters().add(new OpenIDConnectClaimFilterImpl());
    OpenIDConnectServiceComponentHolder.setRequestObjectService(requestObjectService);
    OAuth2ServiceComponentHolder.setKeyIDProvider(new DefaultKeyIDProviderImpl());
    ClaimProvider claimProvider = new OpenIDConnectSystemClaimImpl();
    List claimProviders = new ArrayList();
    claimProviders.add(claimProvider);
    WhiteboxImpl.setInternalState(OpenIDConnectServiceComponentHolder.getInstance(), "claimProviders", claimProviders);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) RequestedClaim(org.wso2.carbon.identity.openidconnect.model.RequestedClaim) AuthenticationMethodNameTranslatorImpl(org.wso2.carbon.identity.application.authentication.framework.internal.impl.AuthenticationMethodNameTranslatorImpl) ArrayList(java.util.ArrayList) ApplicationManagementServiceComponent(org.wso2.carbon.identity.application.mgt.internal.ApplicationManagementServiceComponent) Matchers.anyString(org.mockito.Matchers.anyString) OAuth2AccessTokenRespDTO(org.wso2.carbon.identity.oauth2.dto.OAuth2AccessTokenRespDTO) AuthorizationGrantCacheKey(org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey) List(java.util.List) ArrayList(java.util.ArrayList) ApplicationManagementService(org.wso2.carbon.identity.application.mgt.ApplicationManagementService) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ServiceProviderProperty(org.wso2.carbon.identity.application.common.model.ServiceProviderProperty) DefaultKeyIDProviderImpl(org.wso2.carbon.identity.oauth2.keyidprovider.DefaultKeyIDProviderImpl) AuthenticationMethodNameTranslator(org.wso2.carbon.identity.application.authentication.framework.AuthenticationMethodNameTranslator) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) ClaimMapping(org.wso2.carbon.identity.application.common.model.ClaimMapping) AuthorizationGrantCacheEntry(org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheEntry) RealmService(org.wso2.carbon.user.core.service.RealmService) WithRealmService(org.wso2.carbon.identity.common.testng.WithRealmService) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) JSONObject(org.json.JSONObject) OAuth2Util(org.wso2.carbon.identity.oauth2.util.OAuth2Util) RSAPrivateKey(java.security.interfaces.RSAPrivateKey) Key(java.security.Key) AuthorizationGrantCacheKey(org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey) Certificate(java.security.cert.Certificate) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

BeforeClass (org.testng.annotations.BeforeClass)5 OpenIDConnectClaimFilterImpl (org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl)4 ScopeClaimMappingDAOImpl (org.wso2.carbon.identity.openidconnect.dao.ScopeClaimMappingDAOImpl)4 RequestedClaim (org.wso2.carbon.identity.openidconnect.model.RequestedClaim)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)2 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)2 ApplicationManagementService (org.wso2.carbon.identity.application.mgt.ApplicationManagementService)2 DefaultKeyIDProviderImpl (org.wso2.carbon.identity.oauth2.keyidprovider.DefaultKeyIDProviderImpl)2 Key (java.security.Key)1 Certificate (java.security.cert.Certificate)1 RSAPrivateKey (java.security.interfaces.RSAPrivateKey)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)1 JSONObject (org.json.JSONObject)1 Matchers.anyString (org.mockito.Matchers.anyString)1 ServiceRegistration (org.osgi.framework.ServiceRegistration)1