Search in sources :

Example 26 with IdentityOAuth2ScopeServerException

use of org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeServerException in project identity-inbound-auth-oauth by wso2-extensions.

the class OAuth2ScopeService method getScopes.

/**
 * Retrieve the available scope list.
 *
 * @param startIndex        Start Index of the result set to enforce pagination.
 * @param count             Number of elements in the result set to enforce pagination.
 * @param includeOIDCScopes Include OIDC scopes as well.
 * @param requestedScopes   Requested set of scopes to be return in the response.
 * @param clientId   clientId of Oauth app .
 * @return Scope list.
 */
public Set<Scope> getScopes(Integer startIndex, Integer count, Boolean includeOIDCScopes, String requestedScopes, String clientId) throws IdentityOAuth2ScopeServerException {
    String tenantDomain;
    try {
        OAuthAppDO oAuthAppDO = OAuth2Util.getAppInformationByClientId(clientId);
        tenantDomain = OAuth2Util.getTenantDomainOfOauthApp(oAuthAppDO);
    } catch (IdentityOAuth2Exception | InvalidOAuthClientException e) {
        log.error("Error while getting oauth app for client Id: " + clientId, e);
        throw Oauth2ScopeUtils.generateServerException(Oauth2ScopeConstants.ErrorMessages.ERROR_CODE_FAILED_TO_GET_ALL_SCOPES, e);
    }
    int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
    return getTenantScopes(startIndex, count, includeOIDCScopes, requestedScopes, tenantId);
}
Also used : OAuthAppDO(org.wso2.carbon.identity.oauth.dao.OAuthAppDO) InvalidOAuthClientException(org.wso2.carbon.identity.oauth.common.exception.InvalidOAuthClientException)

Aggregations

IdentityOAuth2ScopeServerException (org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeServerException)13 Scope (org.wso2.carbon.identity.oauth2.bean.Scope)13 Connection (java.sql.Connection)10 SQLException (java.sql.SQLException)10 ArrayList (java.util.ArrayList)8 PreparedStatement (java.sql.PreparedStatement)7 ResultSet (java.sql.ResultSet)7 HashSet (java.util.HashSet)7 NamedPreparedStatement (org.wso2.carbon.identity.oauth2.util.NamedPreparedStatement)7 OAuthScopeCacheKey (org.wso2.carbon.identity.oauth.cache.OAuthScopeCacheKey)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 UserApplicationScopeConsentDO (org.wso2.carbon.identity.oauth2.model.UserApplicationScopeConsentDO)5 IdentityOAuth2Exception (org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception)2 OAuthSystemException (org.apache.oltu.oauth2.common.exception.OAuthSystemException)1 UserIdNotFoundException (org.wso2.carbon.identity.application.authentication.framework.exception.UserIdNotFoundException)1 OAuthScopeBindingCacheKey (org.wso2.carbon.identity.oauth.cache.OAuthScopeBindingCacheKey)1 InvalidOAuthClientException (org.wso2.carbon.identity.oauth.common.exception.InvalidOAuthClientException)1 OAuthAppDO (org.wso2.carbon.identity.oauth.dao.OAuthAppDO)1 ScopeBinding (org.wso2.carbon.identity.oauth2.bean.ScopeBinding)1