use of org.wso2.carbon.identity.openidconnect.cache.OIDCScopeClaimCacheEntry in project identity-inbound-auth-oauth by wso2-extensions.
the class OpenIDConnectClaimFilterImplTest method testGetClaimsFilteredByOIDCScopes.
@Test(dataProvider = "testGetClaimsFilteredByOIDCScopes")
public void testGetClaimsFilteredByOIDCScopes(String requestedScope, int numberOfClaims, String claim) throws Exception {
requestedScopes = new HashSet<>();
requestedScopes.add(requestedScope);
OIDCScopeClaimCacheEntry oidcScopeClaimCacheEntry = new OIDCScopeClaimCacheEntry();
oidcScopeClaimCacheEntry.setScopeClaimMapping(getScopeDTOList());
OIDCScopeClaimCache.getInstance().addScopeClaimMap(-1234, oidcScopeClaimCacheEntry);
List claims = openIDConnectClaimFilter.getClaimsFilteredByOIDCScopes(requestedScopes, SP_TENANT_DOMAIN);
Assert.assertEquals(claims.size(), numberOfClaims);
Assert.assertEquals(claims.get(0), claim);
}
use of org.wso2.carbon.identity.openidconnect.cache.OIDCScopeClaimCacheEntry in project identity-inbound-auth-oauth by wso2-extensions.
the class CacheBackedScopeClaimMappingDAOImpl method initScopeClaimMapping.
@Override
public void initScopeClaimMapping(int tenantId, List<ScopeDTO> scopeClaims) throws IdentityOAuth2Exception {
scopeClaimMappingDAOImpl.initScopeClaimMapping(tenantId, scopeClaims);
OIDCScopeClaimCacheEntry oidcScopeClaimCacheEntry = new OIDCScopeClaimCacheEntry();
oidcScopeClaimCacheEntry.setScopeClaimMapping(scopeClaims);
oidcScopeClaimCache.addScopeClaimMap(tenantId, oidcScopeClaimCacheEntry);
if (log.isDebugEnabled()) {
log.debug("The cache oidcScopeClaimCache is initialized for the tenant : " + tenantId);
}
}
use of org.wso2.carbon.identity.openidconnect.cache.OIDCScopeClaimCacheEntry in project identity-inbound-auth-oauth by wso2-extensions.
the class CacheBackedScopeClaimMappingDAOImpl method getClaims.
@Override
public ScopeDTO getClaims(String scope, int tenantId) throws IdentityOAuth2Exception {
OIDCScopeClaimCacheEntry oidcScopeClaimCacheEntry = oidcScopeClaimCache.getScopeClaimMap(tenantId);
oidcScopeClaimCacheEntry = loadOIDCScopeClaims(tenantId, oidcScopeClaimCacheEntry);
ScopeDTO scopeDTO = new ScopeDTO();
for (ScopeDTO scopeObj : oidcScopeClaimCacheEntry.getScopeClaimMapping()) {
if (scope.equals(scopeObj.getName()) && scopeObj.getClaim() != null) {
scopeDTO = scopeObj;
}
}
return scopeDTO;
}
use of org.wso2.carbon.identity.openidconnect.cache.OIDCScopeClaimCacheEntry in project identity-inbound-auth-oauth by wso2-extensions.
the class CacheBackedScopeClaimMappingDAOImpl method addScopes.
@Override
public void addScopes(int tenantId, List<ScopeDTO> scopeClaimsMap) throws IdentityOAuth2Exception {
scopeClaimMappingDAOImpl.addScopes(tenantId, scopeClaimsMap);
OIDCScopeClaimCacheEntry oidcScopeClaimCacheEntry = new OIDCScopeClaimCacheEntry();
oidcScopeClaimCacheEntry.setScopeClaimMapping(scopeClaimsMap);
oidcScopeClaimCache.addScopeClaimMap(tenantId, oidcScopeClaimCacheEntry);
if (log.isDebugEnabled()) {
log.debug("The cache oidcScopeClaimCache is added for the tenant : " + tenantId);
}
}
use of org.wso2.carbon.identity.openidconnect.cache.OIDCScopeClaimCacheEntry in project identity-inbound-auth-oauth by wso2-extensions.
the class OpenIDConnectClaimFilterImplTest method testHandleUpdatedAtClaim.
@Test
public void testHandleUpdatedAtClaim() {
String date = "2021-10-27T11:34:13.791Z";
claims = new HashMap<>();
claims.put("updated_at", date);
String[] requestedScopes = { "profile" };
OIDCScopeClaimCacheEntry oidcScopeClaimCacheEntry = new OIDCScopeClaimCacheEntry();
oidcScopeClaimCacheEntry.setScopeClaimMapping(getScopeDTOList());
OIDCScopeClaimCache.getInstance().addScopeClaimMap(-1234, oidcScopeClaimCacheEntry);
Map<String, Object> filteredClaims = openIDConnectClaimFilter.getClaimsFilteredByOIDCScopes(claims, requestedScopes, CLIENT_ID, SP_TENANT_DOMAIN);
// Due to the effect of time zone during time conversion, considering only the seconds during comparison
// Check is to ensure this claim is in seconds not milliseconds
String filteredDate = String.valueOf(filteredClaims.get("updated_at"));
Assert.assertEquals(filteredDate.substring(8), "53");
}
Aggregations