use of org.wso2.carbon.identity.oauth.scope.endpoint.dto.ScopeDTO 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.oauth.scope.endpoint.dto.ScopeDTO 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.oauth.scope.endpoint.dto.ScopeDTO 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.oauth.scope.endpoint.dto.ScopeDTO in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2Util method getOIDCScopes.
public static List<String> getOIDCScopes(String tenantDomain) {
List<String> scopes = new ArrayList<>();
try {
int tenantId = OAuthComponentServiceHolder.getInstance().getRealmService().getTenantManager().getTenantId(tenantDomain);
// Get the scopes from the cache or the db
List<ScopeDTO> scopesDTOList = OAuthTokenPersistenceFactory.getInstance().getScopeClaimMappingDAO().getScopes(tenantId);
if (CollectionUtils.isNotEmpty(scopesDTOList)) {
for (ScopeDTO scope : scopesDTOList) {
scopes.add(scope.getName());
}
}
} catch (UserStoreException | IdentityOAuth2Exception e) {
log.error("Error while retrieving OIDC scopes.", e);
}
return scopes;
}
use of org.wso2.carbon.identity.oauth.scope.endpoint.dto.ScopeDTO in project carbon-apimgt by wso2.
the class MappingUtil method scopeDto.
/**
* used to convert {@link Scope} to {@link ScopeDTO}
* @param scope scope Object
* @param scopeBindingType type of bindings
* @return ScopeDTO object
*/
public static ScopeDTO scopeDto(Scope scope, String scopeBindingType) {
ScopeDTO scopeDTO = new ScopeDTO();
scopeDTO.setName(scope.getName());
scopeDTO.setDescription(scope.getDescription());
Scope_bindingsDTO scopeBindingsDTO = new Scope_bindingsDTO();
scopeBindingsDTO.setType(scopeBindingType);
if (scope.getBindings() != null) {
scopeBindingsDTO.setValues(scope.getBindings());
} else {
scopeBindingsDTO.setValues(Collections.emptyList());
}
scopeDTO.setBindings(scopeBindingsDTO);
return scopeDTO;
}
Aggregations