Java Code Examples for org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration#getInstance()

The following examples show how to use org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OAuthServiceComponent.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
protected void activate(ComponentContext context) {
    // initialize the OAuth Server configuration
    OAuthServerConfiguration oauthServerConfig = OAuthServerConfiguration.getInstance();

    if (oauthServerConfig.isCacheEnabled()) {
        log.debug("OAuth Caching is enabled. Initializing the cache.");
        // initialize the cache
        OAuthCache cache = OAuthCache.getInstance();
        if (cache != null) {
            log.debug("OAuth Cache initialization was successful.");
        } else {
            log.debug("OAuth Cache initialization was unsuccessful.");
        }
    }

    listener = new IdentityOathEventListener();
    serviceRegistration = context.getBundleContext().registerService(UserOperationEventListener.class.getName(),
            listener, null);
    log.debug("Identity Oath Event Listener is enabled");

    if (log.isDebugEnabled()) {
        log.info("Identity OAuth bundle is activated");
    }
}
 
Example 2
Source File: APIMgtDAOTest.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    String dbConfigPath = System.getProperty("APIManagerDBConfigurationPath");
    APIManagerConfiguration config = new APIManagerConfiguration();
    initializeDatabase(dbConfigPath);
    config.load(dbConfigPath);
    ServiceReferenceHolder.getInstance().setAPIManagerConfigurationService(new APIManagerConfigurationServiceImpl
            (config));
    List<Notifier> notifierList = new ArrayList<>();
    SubscriptionsNotifier subscriptionsNotifier = new SubscriptionsNotifier();
    notifierList.add(subscriptionsNotifier);
    ServiceReferenceHolder.getInstance().getNotifiersMap().put(subscriptionsNotifier.getType(), notifierList);
    PowerMockito.mockStatic(KeyManagerHolder.class);
    keyManager = Mockito.mock(KeyManager.class);
    APIMgtDBUtil.initialize();
    apiMgtDAO = ApiMgtDAO.getInstance();
    IdentityTenantUtil.setRealmService(new TestRealmService());
    String identityConfigPath = System.getProperty("IdentityConfigurationPath");
    IdentityConfigParser.getInstance(identityConfigPath);
    OAuthServerConfiguration oAuthServerConfiguration = OAuthServerConfiguration.getInstance();
    ServiceReferenceHolder.getInstance().setOauthServerConfiguration(oAuthServerConfiguration);

}
 
Example 3
Source File: JWTAccessTokenBuilder.java    From msf4j with Apache License 2.0 5 votes vote down vote up
public JWTAccessTokenBuilder() throws IdentityOAuth2Exception {
    if (log.isDebugEnabled()) {
        log.debug("JWT Access token builder is initiated");
    }
    config = OAuthServerConfiguration.getInstance();
    //map signature algorithm from identity.xml to nimbus format, this is a one time configuration
    signatureAlgorithm = mapSignatureAlgorithm(config.getSignatureAlgorithm());
}
 
Example 4
Source File: DefaultIDTokenBuilder.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
public DefaultIDTokenBuilder() throws IdentityOAuth2Exception {

        config = OAuthServerConfiguration.getInstance();
        //map signature algorithm from identity.xml to nimbus format, this is a one time configuration
        signatureAlgorithm = mapSignatureAlgorithm(config.getSignatureAlgorithm());
    }
 
Example 5
Source File: OAuth2ServiceComponent.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
protected void activate(ComponentContext context) {
    //Registering OAuth2Service as a OSGIService
    bundleContext = context.getBundleContext();
    bundleContext.registerService(OAuth2Service.class.getName(), new OAuth2Service(), null);
    // 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);
    if (log.isDebugEnabled()) {
        log.debug("Identity OAuth bundle is activated");
    }

    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.");
    }
}