Search in sources :

Example 6 with Service

use of org.apache.knox.gateway.services.Service in project knox by apache.

the class AliasServiceFactory 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)) {
        final AliasService defaultAliasService = new DefaultAliasService();
        ((DefaultAliasService) defaultAliasService).setMasterService(getMasterService(gatewayServices));
        ((DefaultAliasService) defaultAliasService).setKeystoreService(getKeystoreService(gatewayServices));
        // invoking init on DefaultAliasService twice is ok (in case implementation is set to 'default')
        defaultAliasService.init(gatewayConfig, options);
        if (matchesImplementation(implementation, DefaultAliasService.class, true)) {
            service = defaultAliasService;
        } else if (matchesImplementation(implementation, HashicorpVaultAliasService.class)) {
            service = new HashicorpVaultAliasService(defaultAliasService);
        } else if (matchesImplementation(implementation, RemoteAliasService.class)) {
            service = new RemoteAliasService(defaultAliasService, getMasterService(gatewayServices));
        } else if (matchesImplementation(implementation, ZookeeperRemoteAliasService.class)) {
            service = new ZookeeperRemoteAliasServiceProvider().newInstance(gatewayServices, defaultAliasService, getMasterService(gatewayServices));
        }
        logServiceUsage(implementation, serviceType);
    }
    return service;
}
Also used : HashicorpVaultAliasService(org.apache.knox.gateway.backend.hashicorp.vault.HashicorpVaultAliasService) AliasService(org.apache.knox.gateway.services.security.AliasService) DefaultAliasService(org.apache.knox.gateway.services.security.impl.DefaultAliasService) ZookeeperRemoteAliasService(org.apache.knox.gateway.services.security.impl.ZookeeperRemoteAliasService) RemoteAliasService(org.apache.knox.gateway.services.security.impl.RemoteAliasService) DefaultAliasService(org.apache.knox.gateway.services.security.impl.DefaultAliasService) ZookeeperRemoteAliasService(org.apache.knox.gateway.services.security.impl.ZookeeperRemoteAliasService) HashicorpVaultAliasService(org.apache.knox.gateway.backend.hashicorp.vault.HashicorpVaultAliasService) AliasService(org.apache.knox.gateway.services.security.AliasService) DefaultAliasService(org.apache.knox.gateway.services.security.impl.DefaultAliasService) ZookeeperRemoteAliasService(org.apache.knox.gateway.services.security.impl.ZookeeperRemoteAliasService) RemoteAliasService(org.apache.knox.gateway.services.security.impl.RemoteAliasService) Service(org.apache.knox.gateway.services.Service) HashicorpVaultAliasService(org.apache.knox.gateway.backend.hashicorp.vault.HashicorpVaultAliasService) ZookeeperRemoteAliasService(org.apache.knox.gateway.services.security.impl.ZookeeperRemoteAliasService) RemoteAliasService(org.apache.knox.gateway.services.security.impl.RemoteAliasService) ZookeeperRemoteAliasServiceProvider(org.apache.knox.gateway.services.security.impl.ZookeeperRemoteAliasServiceProvider)

Example 7 with Service

use of org.apache.knox.gateway.services.Service in project knox by apache.

the class KeystoreServiceFactory 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)) {
        service = new DefaultKeystoreService();
        ((DefaultKeystoreService) service).setMasterService(getMasterService(gatewayServices));
    }
    return service;
}
Also used : DefaultKeystoreService(org.apache.knox.gateway.services.security.impl.DefaultKeystoreService) DefaultKeystoreService(org.apache.knox.gateway.services.security.impl.DefaultKeystoreService) Service(org.apache.knox.gateway.services.Service)

Example 8 with Service

use of org.apache.knox.gateway.services.Service in project knox by apache.

the class ServiceRegistryServiceFactory 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)) {
        service = new DefaultServiceRegistryService();
        ((DefaultServiceRegistryService) service).setCryptoService(gatewayServices.getService(ServiceType.CRYPTO_SERVICE));
    }
    return service;
}
Also used : DefaultServiceRegistryService(org.apache.knox.gateway.services.registry.impl.DefaultServiceRegistryService) DefaultServiceRegistryService(org.apache.knox.gateway.services.registry.impl.DefaultServiceRegistryService) Service(org.apache.knox.gateway.services.Service)

Example 9 with Service

use of org.apache.knox.gateway.services.Service in project knox by apache.

the class AbstractServiceFactory method create.

@Override
public Service create(GatewayServices gatewayServices, ServiceType serviceType, GatewayConfig gatewayConfig, Map<String, String> options, String implementation) throws ServiceLifecycleException {
    Service service = null;
    if (getServiceType() == serviceType) {
        service = createService(gatewayServices, serviceType, gatewayConfig, options, implementation);
        if (service == null && StringUtils.isNotBlank(implementation)) {
            // no known service implementation created, try to create the custom one
            try {
                service = (Service) Class.forName(implementation).newInstance();
                logServiceUsage(implementation, serviceType);
            } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
                throw new ServiceLifecycleException("Error while instantiating " + serviceType.getShortName() + " service implementation " + implementation, e);
            }
        }
    }
    return service;
}
Also used : AliasService(org.apache.knox.gateway.services.security.AliasService) MasterService(org.apache.knox.gateway.services.security.MasterService) KeystoreService(org.apache.knox.gateway.services.security.KeystoreService) Service(org.apache.knox.gateway.services.Service) ServiceLifecycleException(org.apache.knox.gateway.services.ServiceLifecycleException)

Example 10 with Service

use of org.apache.knox.gateway.services.Service in project knox by apache.

the class ClusterConfigurationMonitorServiceFactory 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)) {
        service = new DefaultClusterConfigurationMonitorService();
        ((DefaultClusterConfigurationMonitorService) service).setAliasService(getAliasService(gatewayServices));
        ((DefaultClusterConfigurationMonitorService) service).setKeystoreService(getKeystoreService(gatewayServices));
    }
    return service;
}
Also used : DefaultClusterConfigurationMonitorService(org.apache.knox.gateway.services.topology.impl.DefaultClusterConfigurationMonitorService) Service(org.apache.knox.gateway.services.Service) DefaultClusterConfigurationMonitorService(org.apache.knox.gateway.services.topology.impl.DefaultClusterConfigurationMonitorService)

Aggregations

Service (org.apache.knox.gateway.services.Service)15 AliasService (org.apache.knox.gateway.services.security.AliasService)5 KeystoreService (org.apache.knox.gateway.services.security.KeystoreService)3 MasterService (org.apache.knox.gateway.services.security.MasterService)3 Field (java.lang.reflect.Field)2 ServiceLifecycleException (org.apache.knox.gateway.services.ServiceLifecycleException)2 RemoteConfigurationRegistryClientService (org.apache.knox.gateway.services.config.client.RemoteConfigurationRegistryClientService)2 BufferedWriter (java.io.BufferedWriter)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 StringWriter (java.io.StringWriter)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Files (java.nio.file.Files)1 ArrayList (java.util.ArrayList)1