Search in sources :

Example 1 with DefaultTokenStateService

use of org.apache.knox.gateway.services.token.impl.DefaultTokenStateService in project knox by apache.

the class TokenStateServiceFactoryTest method shouldReturnDefaultTokenStateService.

@Test
public void shouldReturnDefaultTokenStateService() throws Exception {
    TokenStateService tokenStateService = (TokenStateService) serviceFactory.create(gatewayServices, ServiceType.TOKEN_STATE_SERVICE, gatewayConfig, options, DefaultTokenStateService.class.getName());
    assertTrue(tokenStateService instanceof DefaultTokenStateService);
}
Also used : DefaultTokenStateService(org.apache.knox.gateway.services.token.impl.DefaultTokenStateService) DefaultTokenStateService(org.apache.knox.gateway.services.token.impl.DefaultTokenStateService) AliasBasedTokenStateService(org.apache.knox.gateway.services.token.impl.AliasBasedTokenStateService) JournalBasedTokenStateService(org.apache.knox.gateway.services.token.impl.JournalBasedTokenStateService) ZookeeperTokenStateService(org.apache.knox.gateway.services.token.impl.ZookeeperTokenStateService) TokenStateService(org.apache.knox.gateway.services.security.token.TokenStateService) Test(org.junit.Test)

Example 2 with DefaultTokenStateService

use of org.apache.knox.gateway.services.token.impl.DefaultTokenStateService in project knox by apache.

the class TokenStateServiceFactory method createService.

@Override
protected Service createService(GatewayServices gatewayServices, ServiceType serviceType, GatewayConfig gatewayConfig, Map<String, String> options, String implementation) throws ServiceLifecycleException {
    Service service = null;
    if (shouldCreateService(implementation)) {
        if (matchesImplementation(implementation, DefaultTokenStateService.class)) {
            service = new DefaultTokenStateService();
        } else if (matchesImplementation(implementation, AliasBasedTokenStateService.class, true)) {
            service = new AliasBasedTokenStateService();
            ((AliasBasedTokenStateService) service).setAliasService(getAliasService(gatewayServices));
        } else if (matchesImplementation(implementation, JournalBasedTokenStateService.class)) {
            service = new JournalBasedTokenStateService();
        } else if (matchesImplementation(implementation, ZookeeperTokenStateService.class)) {
            service = new ZookeeperTokenStateService(gatewayServices);
        } else if (matchesImplementation(implementation, JDBCTokenStateService.class)) {
            try {
                service = new JDBCTokenStateService();
                ((JDBCTokenStateService) service).setAliasService(getAliasService(gatewayServices));
                service.init(gatewayConfig, options);
            } catch (ServiceLifecycleException e) {
                LOG.errorInitializingService(implementation, e.getMessage(), e);
                service = new AliasBasedTokenStateService();
                ((AliasBasedTokenStateService) service).setAliasService(getAliasService(gatewayServices));
            }
        }
        logServiceUsage(isEmptyDefaultImplementation(implementation) ? AliasBasedTokenStateService.class.getName() : implementation, serviceType);
    }
    return service;
}
Also used : DefaultTokenStateService(org.apache.knox.gateway.services.token.impl.DefaultTokenStateService) AliasBasedTokenStateService(org.apache.knox.gateway.services.token.impl.AliasBasedTokenStateService) JDBCTokenStateService(org.apache.knox.gateway.services.token.impl.JDBCTokenStateService) DefaultTokenStateService(org.apache.knox.gateway.services.token.impl.DefaultTokenStateService) AliasBasedTokenStateService(org.apache.knox.gateway.services.token.impl.AliasBasedTokenStateService) ZookeeperTokenStateService(org.apache.knox.gateway.services.token.impl.ZookeeperTokenStateService) JournalBasedTokenStateService(org.apache.knox.gateway.services.token.impl.JournalBasedTokenStateService) Service(org.apache.knox.gateway.services.Service) JDBCTokenStateService(org.apache.knox.gateway.services.token.impl.JDBCTokenStateService) ServiceLifecycleException(org.apache.knox.gateway.services.ServiceLifecycleException) JournalBasedTokenStateService(org.apache.knox.gateway.services.token.impl.JournalBasedTokenStateService) ZookeeperTokenStateService(org.apache.knox.gateway.services.token.impl.ZookeeperTokenStateService)

Aggregations

AliasBasedTokenStateService (org.apache.knox.gateway.services.token.impl.AliasBasedTokenStateService)2 DefaultTokenStateService (org.apache.knox.gateway.services.token.impl.DefaultTokenStateService)2 JournalBasedTokenStateService (org.apache.knox.gateway.services.token.impl.JournalBasedTokenStateService)2 ZookeeperTokenStateService (org.apache.knox.gateway.services.token.impl.ZookeeperTokenStateService)2 Service (org.apache.knox.gateway.services.Service)1 ServiceLifecycleException (org.apache.knox.gateway.services.ServiceLifecycleException)1 TokenStateService (org.apache.knox.gateway.services.security.token.TokenStateService)1 JDBCTokenStateService (org.apache.knox.gateway.services.token.impl.JDBCTokenStateService)1 Test (org.junit.Test)1