Search in sources :

Example 1 with OAuthTokenSessionMappingEventHandler

use of org.wso2.carbon.identity.oauth.listener.OAuthTokenSessionMappingEventHandler 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)

Aggregations

AbstractEventHandler (org.wso2.carbon.identity.event.handler.AbstractEventHandler)1 OAuthAdminServiceImpl (org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl)1 OAuthServerConfiguration (org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration)1 IdentityOathEventListener (org.wso2.carbon.identity.oauth.listener.IdentityOathEventListener)1 IdentityOauthEventHandler (org.wso2.carbon.identity.oauth.listener.IdentityOauthEventHandler)1 OAuthTokenSessionMappingEventHandler (org.wso2.carbon.identity.oauth.listener.OAuthTokenSessionMappingEventHandler)1 OAuth2Service (org.wso2.carbon.identity.oauth2.OAuth2Service)1