use of org.wso2.carbon.identity.oauth.cache.OAuthScopeBindingCacheKey in project identity-inbound-auth-oauth by wso2-extensions.
the class JDBCPermissionBasedInternalScopeValidator method getScopesOfPermissionType.
private Set<Scope> getScopesOfPermissionType(int tenantId) throws IdentityOAuth2ScopeServerException {
if (Oauth2ScopeUtils.isSystemLevelInternalSystemScopeManagementEnabled()) {
List<Scope> oauthScopeBinding = OAuth2ServiceComponentHolder.getInstance().getOauthScopeBinding();
return new HashSet<>(oauthScopeBinding);
}
Scope[] scopesFromCache = OAuthScopeBindingCache.getInstance().getValueFromCache(new OAuthScopeBindingCacheKey(PERMISSION_BINDING_TYPE), tenantId);
Set<Scope> allScopes;
if (scopesFromCache != null) {
allScopes = Arrays.stream(scopesFromCache).collect(Collectors.toSet());
} else {
allScopes = OAuthTokenPersistenceFactory.getInstance().getOAuthScopeDAO().getScopes(tenantId, PERMISSION_BINDING_TYPE);
if (CollectionUtils.isNotEmpty(allScopes)) {
OAuthScopeBindingCache.getInstance().addToCache(new OAuthScopeBindingCacheKey(PERMISSION_BINDING_TYPE), allScopes.toArray(new Scope[0]), tenantId);
}
}
return allScopes;
}
Aggregations