Search in sources :

Example 6 with OIDCScopeClaimCacheEntry

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

the class CacheBackedScopeClaimMappingDAOImpl method getScopeNames.

@Override
public List<String> getScopeNames(int tenantId) throws IdentityOAuth2Exception {
    OIDCScopeClaimCacheEntry oidcScopeClaimCacheEntry = oidcScopeClaimCache.getScopeClaimMap(tenantId);
    oidcScopeClaimCacheEntry = loadOIDCScopeClaims(tenantId, oidcScopeClaimCacheEntry);
    List<String> scopes = new ArrayList<>();
    for (ScopeDTO scopeDTO : oidcScopeClaimCacheEntry.getScopeClaimMapping()) {
        scopes.add(scopeDTO.getName());
    }
    return scopes;
}
Also used : OIDCScopeClaimCacheEntry(org.wso2.carbon.identity.openidconnect.cache.OIDCScopeClaimCacheEntry) ScopeDTO(org.wso2.carbon.identity.oauth.dto.ScopeDTO) ArrayList(java.util.ArrayList)

Example 7 with OIDCScopeClaimCacheEntry

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

the class CacheBackedScopeClaimMappingDAOImpl method getScopes.

@Override
public List<ScopeDTO> getScopes(int tenantId) throws IdentityOAuth2Exception {
    OIDCScopeClaimCacheEntry oidcScopeClaimCacheEntry = oidcScopeClaimCache.getScopeClaimMap(tenantId);
    oidcScopeClaimCacheEntry = loadOIDCScopeClaims(tenantId, oidcScopeClaimCacheEntry);
    return oidcScopeClaimCacheEntry.getScopeClaimMapping();
}
Also used : OIDCScopeClaimCacheEntry(org.wso2.carbon.identity.openidconnect.cache.OIDCScopeClaimCacheEntry)

Example 8 with OIDCScopeClaimCacheEntry

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

the class CacheBackedScopeClaimMappingDAOImpl method loadOIDCScopeClaims.

private OIDCScopeClaimCacheEntry loadOIDCScopeClaims(int tenantId, OIDCScopeClaimCacheEntry oidcScopeClaimCacheEntry) throws IdentityOAuth2Exception {
    if (oidcScopeClaimCacheEntry == null || oidcScopeClaimCacheEntry.getScopeClaimMapping().size() == 0) {
        if (log.isDebugEnabled()) {
            log.debug("Cache miss for OIDC scopes claims mapping for tenant: " + tenantId);
        }
        oidcScopeClaimCacheEntry = new OIDCScopeClaimCacheEntry();
        List<ScopeDTO> scopeClaims = scopeClaimMappingDAOImpl.getScopes(tenantId);
        oidcScopeClaimCacheEntry.setScopeClaimMapping(scopeClaims);
        oidcScopeClaimCache.addScopeClaimMap(tenantId, oidcScopeClaimCacheEntry);
        if (log.isDebugEnabled()) {
            log.debug("OIDC scopes and mapped claims are loaded from the database and inserted to the cache for " + "the tenant : " + tenantId);
        }
    }
    return oidcScopeClaimCacheEntry;
}
Also used : OIDCScopeClaimCacheEntry(org.wso2.carbon.identity.openidconnect.cache.OIDCScopeClaimCacheEntry) ScopeDTO(org.wso2.carbon.identity.oauth.dto.ScopeDTO)

Aggregations

OIDCScopeClaimCacheEntry (org.wso2.carbon.identity.openidconnect.cache.OIDCScopeClaimCacheEntry)8 ScopeDTO (org.wso2.carbon.identity.oauth.dto.ScopeDTO)3 ArrayList (java.util.ArrayList)2 Test (org.testng.annotations.Test)2 List (java.util.List)1 Matchers.anyString (org.mockito.Matchers.anyString)1