Search in sources :

Example 1 with OAuth2Service

use of io.trino.server.security.oauth2.OAuth2Service in project identity-inbound-auth-oauth by wso2-extensions.

the class OAuthServiceComponent method activate.

protected void activate(ComponentContext context) {
    try {
        // initialize the OAuth Server configuration
        OAuthServerConfiguration oauthServerConfig = OAuthServerConfiguration.getInstance();
        if (OAuthCache.getInstance().isEnabled()) {
            log.debug("OAuth Caching is enabled. Initializing the cache.");
        }
        IdentityOathEventListener listener = new IdentityOathEventListener();
        serviceRegistration = context.getBundleContext().registerService(UserOperationEventListener.class.getName(), listener, null);
        log.debug("Identity Oath Event Listener is enabled");
        context.getBundleContext().registerService(AbstractEventHandler.class.getName(), new IdentityOauthEventHandler(), null);
        if (log.isDebugEnabled()) {
            log.debug("Identity Oauth Event handler is enabled");
        }
        OAuth2Service oauth2Service = new OAuth2Service();
        context.getBundleContext().registerService(OAuth2Service.class.getName(), oauth2Service, null);
        OAuthComponentServiceHolder.getInstance().setOauth2Service(oauth2Service);
        // We need to explicitly populate the OAuthTokenIssuerMap since it's used for token validation.
        oauthServerConfig.populateOAuthTokenIssuerMap();
        OAuthAdminServiceImpl oauthAdminService = new OAuthAdminServiceImpl();
        OAuthComponentServiceHolder.getInstance().setOAuthAdminService(oauthAdminService);
        OAuth2ServiceComponentHolder.getInstance().setOAuthAdminService(oauthAdminService);
        context.getBundleContext().registerService(OAuthEventInterceptor.class, new OAuthTokenSessionMappingEventHandler(), null);
        if (log.isDebugEnabled()) {
            log.debug("OAuthTokenSessionMapping Event Handler is enabled");
        }
        context.getBundleContext().registerService(OAuthAdminServiceImpl.class.getName(), oauthAdminService, null);
        if (log.isDebugEnabled()) {
            log.debug("Identity OAuth bundle is activated");
        }
    } catch (Throwable e) {
        String errMsg = "Error occurred while activating OAuth Service Component";
        log.error(errMsg, e);
        throw new RuntimeException(errMsg, e);
    }
}
Also used : OAuth2Service(org.wso2.carbon.identity.oauth2.OAuth2Service) IdentityOauthEventHandler(org.wso2.carbon.identity.oauth.listener.IdentityOauthEventHandler) AbstractEventHandler(org.wso2.carbon.identity.event.handler.AbstractEventHandler) IdentityOathEventListener(org.wso2.carbon.identity.oauth.listener.IdentityOathEventListener) OAuthAdminServiceImpl(org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl) OAuthServerConfiguration(org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration) OAuthTokenSessionMappingEventHandler(org.wso2.carbon.identity.oauth.listener.OAuthTokenSessionMappingEventHandler)

Example 2 with OAuth2Service

use of io.trino.server.security.oauth2.OAuth2Service in project trino by trinodb.

the class OAuth2Service method startOAuth2Challenge.

public Response startOAuth2Challenge(URI callbackUri, Optional<String> handlerState) {
    Instant challengeExpiration = now().plus(challengeTimeout);
    String state = newJwtBuilder().signWith(stateHmac).setAudience(STATE_AUDIENCE_UI).claim(HANDLER_STATE_CLAIM, handlerState.orElse(null)).setExpiration(Date.from(challengeExpiration)).compact();
    Optional<String> nonce;
    // since this scope is required in order to obtain the ID token which carriers the nonce back to the server
    if (scopes.contains(OPENID_SCOPE)) {
        nonce = Optional.of(randomNonce());
    } else {
        nonce = Optional.empty();
    }
    Response.ResponseBuilder response = Response.seeOther(client.getAuthorizationUri(state, callbackUri, nonce.map(OAuth2Service::hashNonce)));
    nonce.ifPresent(nce -> response.cookie(NonceCookie.create(nce, challengeExpiration)));
    return response.build();
}
Also used : OAuth2Response(io.trino.server.security.oauth2.OAuth2Client.OAuth2Response) Response(javax.ws.rs.core.Response) Instant(java.time.Instant)

Example 3 with OAuth2Service

use of io.trino.server.security.oauth2.OAuth2Service in project identity-inbound-auth-oauth by wso2-extensions.

the class OAuth2ServiceComponent method activate.

protected void activate(ComponentContext context) {
    try {
        if (OAuth2ServiceComponentHolder.getInstance().getScopeClaimMappingDAO() == null) {
            OAuth2ServiceComponentHolder.getInstance().setScopeClaimMappingDAO(new ScopeClaimMappingDAOImpl());
        }
        loadScopeConfigFile();
        loadOauthScopeBinding();
        int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
        boolean isRecordExist = OAuthTokenPersistenceFactory.getInstance().getScopeClaimMappingDAO().hasScopesPopulated(tenantId);
        if (!isRecordExist) {
            OAuth2Util.initiateOIDCScopes(tenantId);
        }
        TenantCreationEventListener scopeTenantMgtListener = new TenantCreationEventListener();
        bundleContext = context.getBundleContext();
        // Registering TenantCreationEventListener
        ServiceRegistration scopeTenantMgtListenerSR = bundleContext.registerService(TenantMgtListener.class.getName(), scopeTenantMgtListener, null);
        if (scopeTenantMgtListenerSR != null) {
            if (log.isDebugEnabled()) {
                log.debug(" TenantMgtListener is registered");
            }
        } else {
            log.error("TenantMgtListener could not be registered");
        }
        // iniating oauth scopes
        OAuth2Util.initiateOAuthScopePermissionsBindings(tenantId);
        // exposing server configuration as a service
        OAuthServerConfiguration oauthServerConfig = OAuthServerConfiguration.getInstance();
        bundleContext.registerService(OAuthServerConfiguration.class.getName(), oauthServerConfig, null);
        OAuth2TokenValidationService tokenValidationService = new OAuth2TokenValidationService();
        bundleContext.registerService(OAuth2TokenValidationService.class.getName(), tokenValidationService, null);
        OAuthClientAuthnService clientAuthnService = new OAuthClientAuthnService();
        bundleContext.registerService(OAuthClientAuthnService.class.getName(), clientAuthnService, null);
        BasicAuthClientAuthenticator basicAuthClientAuthenticator = new BasicAuthClientAuthenticator();
        bundleContext.registerService(OAuthClientAuthenticator.class.getName(), basicAuthClientAuthenticator, null);
        PublicClientAuthenticator publicClientAuthenticator = new PublicClientAuthenticator();
        bundleContext.registerService(OAuthClientAuthenticator.class.getName(), publicClientAuthenticator, null);
        // Register cookie based access token binder.
        CookieBasedTokenBinder cookieBasedTokenBinder = new CookieBasedTokenBinder();
        bundleContext.registerService(TokenBinderInfo.class.getName(), cookieBasedTokenBinder, null);
        // SSO session based access token binder.
        SSOSessionBasedTokenBinder ssoSessionBasedTokenBinder = new SSOSessionBasedTokenBinder();
        bundleContext.registerService(TokenBinderInfo.class.getName(), ssoSessionBasedTokenBinder, null);
        if (log.isDebugEnabled()) {
            log.debug("Identity OAuth bundle is activated");
        }
        if (OAuth2ServiceComponentHolder.getKeyIDProvider() == null) {
            KeyIDProvider defaultKeyIDProvider = new DefaultKeyIDProviderImpl();
            OAuth2ServiceComponentHolder.setKeyIDProvider(defaultKeyIDProvider);
            if (log.isDebugEnabled()) {
                log.debug("Key ID Provider " + DefaultKeyIDProviderImpl.class.getSimpleName() + " registered as the default Key ID Provider implementation.");
            }
        }
        ServiceRegistration tenantMgtListenerSR = bundleContext.registerService(TenantMgtListener.class.getName(), new OAuthTenantMgtListenerImpl(), null);
        if (tenantMgtListenerSR != null) {
            if (log.isDebugEnabled()) {
                log.debug("OAuth - TenantMgtListener registered.");
            }
        } else {
            log.error("OAuth - TenantMgtListener could not be registered.");
        }
        ServiceRegistration userStoreConfigEventSR = bundleContext.registerService(UserStoreConfigListener.class.getName(), new OAuthUserStoreConfigListenerImpl(), null);
        if (userStoreConfigEventSR != null) {
            if (log.isDebugEnabled()) {
                log.debug("OAuth - UserStoreConfigListener registered.");
            }
        } else {
            log.error("OAuth - UserStoreConfigListener could not be registered.");
        }
        ServiceRegistration oauthApplicationMgtListenerSR = bundleContext.registerService(ApplicationMgtListener.class.getName(), new OAuthApplicationMgtListener(), null);
        if (oauthApplicationMgtListenerSR != null) {
            if (log.isDebugEnabled()) {
                log.debug("OAuth - ApplicationMgtListener registered.");
            }
        } else {
            log.error("OAuth - ApplicationMgtListener could not be registered.");
        }
        // PKCE enabled by default.
        OAuth2ServiceComponentHolder.setPkceEnabled(true);
        // Register device auth service.
        ServiceRegistration deviceAuthService = bundleContext.registerService(DeviceAuthService.class.getName(), new DeviceAuthServiceImpl(), null);
        if (deviceAuthService != null) {
            if (log.isDebugEnabled()) {
                log.debug("DeviceAuthService registered.");
            }
        } else {
            log.error("DeviceAuthService could not be registered.");
        }
        // Register the default OpenIDConnect claim filter
        bundleContext.registerService(OpenIDConnectClaimFilter.class, new OpenIDConnectClaimFilterImpl(), null);
        if (log.isDebugEnabled()) {
            log.debug("Default OpenIDConnect Claim filter registered successfully.");
        }
        bundleContext.registerService(AbstractEventHandler.class.getName(), new TokenBindingExpiryEventHandler(), null);
        if (log.isDebugEnabled()) {
            log.debug("TokenBindingExpiryEventHandler is successfully registered.");
        }
        // Registering OAuth2Service as a OSGIService
        bundleContext.registerService(OAuth2Service.class.getName(), new OAuth2Service(), null);
        // Registering OAuth2ScopeService as a OSGIService
        bundleContext.registerService(OAuth2ScopeService.class.getName(), new OAuth2ScopeService(), null);
    // Note : DO NOT add any activation related code below this point,
    // to make sure the server doesn't start up if any activation failures occur
    } catch (Throwable e) {
        String errMsg = "Error while activating OAuth2ServiceComponent.";
        log.error(errMsg, e);
        throw new RuntimeException(errMsg, e);
    }
    if (checkAudienceEnabled()) {
        if (log.isDebugEnabled()) {
            log.debug("OAuth - OIDC audiences enabled.");
        }
        OAuth2ServiceComponentHolder.setAudienceEnabled(true);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("OAuth - OIDC audiences disabled.");
        }
        OAuth2ServiceComponentHolder.setAudienceEnabled(false);
    }
    if (checkIDPIdColumnAvailable()) {
        if (log.isDebugEnabled()) {
            log.debug("IDP_ID column is available in all relevant tables. " + "Setting isIDPIdColumnEnabled to true.");
        }
        OAuth2ServiceComponentHolder.setIDPIdColumnEnabled(true);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("IDP_ID column is not available in all relevant tables. " + "Setting isIDPIdColumnEnabled to false.");
        }
        OAuth2ServiceComponentHolder.setIDPIdColumnEnabled(false);
    }
}
Also used : TokenBindingExpiryEventHandler(org.wso2.carbon.identity.oauth2.token.bindings.handlers.TokenBindingExpiryEventHandler) KeyIDProvider(org.wso2.carbon.identity.oauth2.keyidprovider.KeyIDProvider) OAuthServerConfiguration(org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration) TokenBinderInfo(org.wso2.carbon.identity.oauth.common.token.bindings.TokenBinderInfo) ApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener) OAuth2ScopeService(org.wso2.carbon.identity.oauth2.OAuth2ScopeService) TenantMgtListener(org.wso2.carbon.stratos.common.listeners.TenantMgtListener) CookieBasedTokenBinder(org.wso2.carbon.identity.oauth2.token.bindings.impl.CookieBasedTokenBinder) SSOSessionBasedTokenBinder(org.wso2.carbon.identity.oauth2.token.bindings.impl.SSOSessionBasedTokenBinder) ServiceRegistration(org.osgi.framework.ServiceRegistration) OAuthClientAuthenticator(org.wso2.carbon.identity.oauth2.client.authentication.OAuthClientAuthenticator) OAuth2Service(org.wso2.carbon.identity.oauth2.OAuth2Service) OAuthClientAuthnService(org.wso2.carbon.identity.oauth2.client.authentication.OAuthClientAuthnService) DefaultKeyIDProviderImpl(org.wso2.carbon.identity.oauth2.keyidprovider.DefaultKeyIDProviderImpl) UserStoreConfigListener(org.wso2.carbon.identity.user.store.configuration.listener.UserStoreConfigListener) TenantCreationEventListener(org.wso2.carbon.identity.oauth2.listener.TenantCreationEventListener) PublicClientAuthenticator(org.wso2.carbon.identity.oauth2.client.authentication.PublicClientAuthenticator) BasicAuthClientAuthenticator(org.wso2.carbon.identity.oauth2.client.authentication.BasicAuthClientAuthenticator) ScopeClaimMappingDAOImpl(org.wso2.carbon.identity.openidconnect.dao.ScopeClaimMappingDAOImpl) OpenIDConnectClaimFilterImpl(org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl) DeviceAuthService(org.wso2.carbon.identity.oauth2.device.api.DeviceAuthService) AbstractEventHandler(org.wso2.carbon.identity.event.handler.AbstractEventHandler) OAuth2TokenValidationService(org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService) DeviceAuthServiceImpl(org.wso2.carbon.identity.oauth2.device.api.DeviceAuthServiceImpl)

Example 4 with OAuth2Service

use of io.trino.server.security.oauth2.OAuth2Service in project identity-inbound-auth-oauth by wso2-extensions.

the class OAuth2AuthzEndpoint method getTokenBinder.

private Optional<TokenBinder> getTokenBinder(String clientId) throws OAuthSystemException {
    OAuthAppDO oAuthAppDO;
    try {
        oAuthAppDO = OAuth2Util.getAppInformationByClientId(clientId);
    } catch (IdentityOAuth2Exception | InvalidOAuthClientException e) {
        throw new OAuthSystemException("Failed to retrieve OAuth application with client id: " + clientId, e);
    }
    if (oAuthAppDO == null || StringUtils.isBlank(oAuthAppDO.getTokenBindingType())) {
        return Optional.empty();
    }
    OAuth2Service oAuth2Service = getOAuth2Service();
    List<TokenBinder> supportedTokenBinders = oAuth2Service.getSupportedTokenBinders();
    if (supportedTokenBinders == null || supportedTokenBinders.isEmpty()) {
        return Optional.empty();
    }
    return supportedTokenBinders.stream().filter(t -> t.getBindingType().equals(oAuthAppDO.getTokenBindingType())).findAny();
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) OAuthServerConfiguration(org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration) Arrays(java.util.Arrays) Produces(javax.ws.rs.Produces) AuthorizationGrantCache(org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCache) Enumeration(java.util.Enumeration) FrameworkConstants(org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants) IdentityOAuth2ScopeException(org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeException) CarbonOAuthAuthzRequest(org.wso2.carbon.identity.oauth2.model.CarbonOAuthAuthzRequest) JSONException(org.json.JSONException) MediaType(javax.ws.rs.core.MediaType) OAuthError(org.apache.oltu.oauth2.common.error.OAuthError) AuthenticationResult(org.wso2.carbon.identity.application.authentication.framework.model.AuthenticationResult) Map(java.util.Map) SessionDataCacheEntry(org.wso2.carbon.identity.oauth.cache.SessionDataCacheEntry) OpenIDConnectClaimFilterImpl(org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl) NONCE(org.wso2.carbon.identity.openidconnect.model.Constants.NONCE) ServiceURLBuilder(org.wso2.carbon.identity.core.ServiceURLBuilder) OpenIDConnectUserRPStore(org.wso2.carbon.identity.oauth.endpoint.util.OpenIDConnectUserRPStore) OIDCRequestObjectUtil(org.wso2.carbon.identity.openidconnect.OIDCRequestObjectUtil) OAuth2Util(org.wso2.carbon.identity.oauth2.util.OAuth2Util) URIBuilder(org.apache.http.client.utils.URIBuilder) AuthenticatorFlowStatus(org.wso2.carbon.identity.application.authentication.framework.AuthenticatorFlowStatus) SCOPE(org.wso2.carbon.identity.openidconnect.model.Constants.SCOPE) InvalidRequestException(org.wso2.carbon.identity.oauth.endpoint.exception.InvalidRequestException) EndpointUtil.validateParams(org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.validateParams) Set(java.util.Set) SignedJWT(com.nimbusds.jwt.SignedJWT) StandardCharsets(java.nio.charset.StandardCharsets) InvalidOAuthClientException(org.wso2.carbon.identity.oauth.common.exception.InvalidOAuthClientException) REQUESTED_CLAIMS(org.wso2.carbon.identity.application.authentication.endpoint.util.Constants.REQUESTED_CLAIMS) UserIdNotFoundException(org.wso2.carbon.identity.application.authentication.framework.exception.UserIdNotFoundException) ConsentHandlingFailedException(org.wso2.carbon.identity.oauth.endpoint.exception.ConsentHandlingFailedException) PASSTHROUGH_TO_COMMONAUTH(org.wso2.carbon.identity.oauth.endpoint.state.OAuthAuthorizeState.PASSTHROUGH_TO_COMMONAUTH) LogFactory(org.apache.commons.logging.LogFactory) TENANT_DOMAIN(org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.RequestParams.TENANT_DOMAIN) REQUEST_PARAM_SP(org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.REQUEST_PARAM_SP) RequestedClaim(org.wso2.carbon.identity.openidconnect.model.RequestedClaim) GET(javax.ws.rs.GET) HttpRequestHeaderHandler(org.wso2.carbon.identity.oauth2.model.HttpRequestHeaderHandler) OAuthRequestWrapper(org.wso2.carbon.identity.oauth.endpoint.OAuthRequestWrapper) EndpointUtil.getOAuthServerConfiguration(org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getOAuthServerConfiguration) ArrayList(java.util.ArrayList) InvalidRequestParentException(org.wso2.carbon.identity.oauth.endpoint.exception.InvalidRequestParentException) ClaimMetadataException(org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException) HttpServletRequest(javax.servlet.http.HttpServletRequest) Encode(org.owasp.encoder.Encode) RequestObject(org.wso2.carbon.identity.openidconnect.model.RequestObject) IdentityOAuthAdminException(org.wso2.carbon.identity.oauth.IdentityOAuthAdminException) RequestObjectException(org.wso2.carbon.identity.oauth2.RequestObjectException) IdentityOAuth2Exception(org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception) CommonAuthRequestWrapper(org.wso2.carbon.identity.application.authentication.framework.model.CommonAuthRequestWrapper) IdentityTenantUtil(org.wso2.carbon.identity.core.util.IdentityTenantUtil) LinkedHashSet(java.util.LinkedHashSet) MAX_AGE(org.wso2.carbon.identity.openidconnect.model.Constants.MAX_AGE) Files(java.nio.file.Files) ID_TOKEN_HINT(org.wso2.carbon.identity.openidconnect.model.Constants.ID_TOKEN_HINT) IOException(java.io.IOException) AUTHENTICATION_RESPONSE(org.wso2.carbon.identity.oauth.endpoint.state.OAuthAuthorizeState.AUTHENTICATION_RESPONSE) USER_CLAIMS_CONSENT_ONLY(org.wso2.carbon.identity.application.authentication.endpoint.util.Constants.USER_CLAIMS_CONSENT_ONLY) STATE(org.wso2.carbon.identity.openidconnect.model.Constants.STATE) EndpointUtil.getErrorPageURL(org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getErrorPageURL) OAuthMessage(org.wso2.carbon.identity.oauth.endpoint.message.OAuthMessage) Paths(java.nio.file.Paths) PROMPT(org.wso2.carbon.identity.openidconnect.model.Constants.PROMPT) ServletException(javax.servlet.ServletException) OAuth(org.apache.oltu.oauth2.common.OAuth) SessionDataCacheKey(org.wso2.carbon.identity.oauth.cache.SessionDataCacheKey) URISyntaxException(java.net.URISyntaxException) HttpServletRequestWrapper(javax.servlet.http.HttpServletRequestWrapper) Path(javax.ws.rs.Path) Scanner(java.util.Scanner) AUTH_TIME(org.wso2.carbon.identity.openidconnect.model.Constants.AUTH_TIME) JSONObject(org.json.JSONObject) OIDCConstants(org.wso2.carbon.identity.openidconnect.OIDCConstants) USER_CONSENT_RESPONSE(org.wso2.carbon.identity.oauth.endpoint.state.OAuthAuthorizeState.USER_CONSENT_RESPONSE) OAuth2ErrorCodes(org.wso2.carbon.identity.oauth.common.OAuth2ErrorCodes) Consumes(javax.ws.rs.Consumes) LOGIN_HINT(org.wso2.carbon.identity.openidconnect.model.Constants.LOGIN_HINT) URLBuilderException(org.wso2.carbon.identity.core.URLBuilderException) URI(java.net.URI) ParseException(java.text.ParseException) INITIAL_REQUEST(org.wso2.carbon.identity.oauth.endpoint.state.OAuthAuthorizeState.INITIAL_REQUEST) EndpointUtil.getOAuth2Service(org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getOAuth2Service) OIDCSessionState(org.wso2.carbon.identity.oidc.session.OIDCSessionState) AuthenticationResultCacheEntry(org.wso2.carbon.identity.application.authentication.framework.cache.AuthenticationResultCacheEntry) Context(javax.ws.rs.core.Context) EndpointUtil.retrieveStateForErrorURL(org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.retrieveStateForErrorURL) OAuth2Parameters(org.wso2.carbon.identity.oauth2.model.OAuth2Parameters) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) OAuthASResponse(org.apache.oltu.oauth2.as.response.OAuthASResponse) OAuth2AuthorizeRespDTO(org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeRespDTO) CommonAuthResponseWrapper(org.wso2.carbon.identity.application.authentication.framework.model.CommonAuthResponseWrapper) UUID(java.util.UUID) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) OIDCSessionManagementUtil(org.wso2.carbon.identity.oidc.session.util.OIDCSessionManagementUtil) List(java.util.List) IdentityConstants(org.wso2.carbon.identity.base.IdentityConstants) HttpHeaders(javax.ws.rs.core.HttpHeaders) OAuth2Service(org.wso2.carbon.identity.oauth2.OAuth2Service) Response(javax.ws.rs.core.Response) OAuthAuthzRequest(org.apache.oltu.oauth2.as.request.OAuthAuthzRequest) Optional(java.util.Optional) CommonAuthenticationHandler(org.wso2.carbon.identity.application.authentication.framework.CommonAuthenticationHandler) SSOConsentServiceException(org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.exception.SSOConsentServiceException) NameValuePair(org.apache.http.NameValuePair) AuthHistory(org.wso2.carbon.identity.application.authentication.framework.context.AuthHistory) FrameworkUtils(org.wso2.carbon.identity.application.authentication.framework.util.FrameworkUtils) OAuth2ClientValidationResponseDTO(org.wso2.carbon.identity.oauth2.dto.OAuth2ClientValidationResponseDTO) UnsupportedEncodingException(java.io.UnsupportedEncodingException) EndpointUtil.getSSOConsentService(org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getSSOConsentService) ServiceProviderProperty(org.wso2.carbon.identity.application.common.model.ServiceProviderProperty) OAuthProblemException(org.apache.oltu.oauth2.common.exception.OAuthProblemException) REDIRECT_URI(org.wso2.carbon.identity.oauth.common.OAuthConstants.OAuth20Params.REDIRECT_URI) SessionContext(org.wso2.carbon.identity.application.authentication.framework.context.SessionContext) OAuthAppDO(org.wso2.carbon.identity.oauth.dao.OAuthAppDO) HashMap(java.util.HashMap) EndpointUtil(org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil) Claim(org.wso2.carbon.identity.application.common.model.Claim) HashSet(java.util.HashSet) CarbonUtils(org.wso2.carbon.utils.CarbonUtils) ClaimMapping(org.wso2.carbon.identity.application.common.model.ClaimMapping) CollectionUtils(org.apache.commons.collections.CollectionUtils) OAuthResponse(org.apache.oltu.oauth2.common.message.OAuthResponse) ExternalClaim(org.wso2.carbon.identity.claim.metadata.mgt.model.ExternalClaim) LoggerUtils(org.wso2.carbon.identity.central.log.mgt.utils.LoggerUtils) OAuthErrorDTO(org.wso2.carbon.identity.oauth.dto.OAuthErrorDTO) ClaimMetaData(org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.ClaimMetaData) SessionDataCache(org.wso2.carbon.identity.oauth.cache.SessionDataCache) Cookie(javax.servlet.http.Cookie) ConsentClaimsData(org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.ConsentClaimsData) UUIDGenerator(org.wso2.carbon.registry.core.utils.UUIDGenerator) EndpointUtil.getLoginPageURL(org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getLoginPageURL) DISPLAY(org.wso2.carbon.identity.openidconnect.model.Constants.DISPLAY) IdentityOAuth2ClientException(org.wso2.carbon.identity.oauth2.IdentityOAuth2ClientException) POST(javax.ws.rs.POST) MapUtils(org.apache.commons.collections.MapUtils) OAuthConstants(org.wso2.carbon.identity.oauth.common.OAuthConstants) HttpServletResponse(javax.servlet.http.HttpServletResponse) OAuth2AuthorizeReqDTO(org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeReqDTO) ClaimMetadataHandler(org.wso2.carbon.identity.claim.metadata.mgt.ClaimMetadataHandler) AuthorizationGrantCacheEntry(org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheEntry) AuthorizationGrantCacheKey(org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCacheKey) MANDATORY_CLAIMS(org.wso2.carbon.identity.application.authentication.endpoint.util.Constants.MANDATORY_CLAIMS) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) TokenBinder(org.wso2.carbon.identity.oauth2.token.bindings.TokenBinder) URLEncoder(java.net.URLEncoder) AuthenticatedUser(org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser) OAuthSystemException(org.apache.oltu.oauth2.common.exception.OAuthSystemException) StringJoiner(java.util.StringJoiner) IdentityUtil(org.wso2.carbon.identity.core.util.IdentityUtil) Log(org.apache.commons.logging.Log) DigestUtils(org.apache.commons.codec.digest.DigestUtils) Collections(java.util.Collections) ArrayUtils(org.apache.commons.lang.ArrayUtils) EndpointUtil.getOAuth2Service(org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getOAuth2Service) OAuth2Service(org.wso2.carbon.identity.oauth2.OAuth2Service) OAuthAppDO(org.wso2.carbon.identity.oauth.dao.OAuthAppDO) IdentityOAuth2Exception(org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception) OAuthSystemException(org.apache.oltu.oauth2.common.exception.OAuthSystemException) InvalidOAuthClientException(org.wso2.carbon.identity.oauth.common.exception.InvalidOAuthClientException) TokenBinder(org.wso2.carbon.identity.oauth2.token.bindings.TokenBinder)

Example 5 with OAuth2Service

use of io.trino.server.security.oauth2.OAuth2Service in project identity-inbound-auth-oauth by wso2-extensions.

the class EndpointUtilTest method mockPrivilegedCarbonContext.

private void mockPrivilegedCarbonContext() {
    mockStatic(PrivilegedCarbonContext.class);
    when(PrivilegedCarbonContext.getThreadLocalCarbonContext()).thenReturn(mockedPrivilegedCarbonContext);
    when(mockedPrivilegedCarbonContext.getOSGiService(OAuthServerConfiguration.class, null)).thenReturn(mockedOAuthServerConfiguration);
    when(mockedPrivilegedCarbonContext.getOSGiService(WebFingerProcessor.class, null)).thenReturn(DefaultWebFingerProcessor.getInstance());
    when(mockedPrivilegedCarbonContext.getOSGiService(OIDCProviderRequestBuilder.class, null)).thenReturn(new DefaultOIDCProviderRequestBuilder());
    when(mockedPrivilegedCarbonContext.getOSGiService(OIDCProcessor.class, null)).thenReturn(DefaultOIDCProcessor.getInstance());
    when(mockedPrivilegedCarbonContext.getOSGiService(OAuth2Service.class, null)).thenReturn(new OAuth2Service());
    when(mockedPrivilegedCarbonContext.getOSGiService(OAuth2TokenValidationService.class, null)).thenReturn(new OAuth2TokenValidationService());
}
Also used : OAuth2Service(org.wso2.carbon.identity.oauth2.OAuth2Service) DefaultOIDCProviderRequestBuilder(org.wso2.carbon.identity.discovery.builders.DefaultOIDCProviderRequestBuilder) OAuth2TokenValidationService(org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService)

Aggregations

OAuth2Service (org.wso2.carbon.identity.oauth2.OAuth2Service)4 OAuthServerConfiguration (org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration)3 OAuth2TokenValidationService (org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService)2 OpenIDConnectClaimFilterImpl (org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl)2 SignedJWT (com.nimbusds.jwt.SignedJWT)1 OAuth2Response (io.trino.server.security.oauth2.OAuth2Client.OAuth2Response)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URLEncoder (java.net.URLEncoder)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1 ParseException (java.text.ParseException)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Enumeration (java.util.Enumeration)1