@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; }
/** * To retrieve oidc claims mapped to an oidc scope. * * @param scope scope * @return list of claims which are mapped to the oidc scope. * @throws IdentityOAuth2Exception if an error occurs when lading oidc claims. */ public String[] getClaims(String scope) throws IdentityOAuthAdminException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { ScopeDTO scopeDTO = OAuthTokenPersistenceFactory.getInstance().getScopeClaimMappingDAO(). getClaims(scope, tenantId); if (scopeDTO != null && ArrayUtils.isNotEmpty(scopeDTO.getClaim())) { return scopeDTO.getClaim(); } else { if (log.isDebugEnabled()) { log.debug("Could not load oidc claims. Hence returning an empty array."); } return new String[0]; } } catch (IdentityOAuth2Exception e) { throw handleError("Error while loading OIDC claims for the scope: " + scope + " in tenant: " + tenantId, e); } }
String[] claims = scopeDTO.getClaim(); try { if (!isScopeExist(scope, tenantId)) {
scopeClaimsMap.put(scope.getName(), Arrays.asList(scope.getClaim()));