Search in sources :

Example 1 with Service

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

the class CryptoServiceFactory 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 DefaultCryptoService();
        ((DefaultCryptoService) service).setKeystoreService(getKeystoreService(gatewayServices));
        ((DefaultCryptoService) service).setAliasService(getAliasService(gatewayServices));
    }
    return service;
}
Also used : DefaultCryptoService(org.apache.knox.gateway.services.security.impl.DefaultCryptoService) Service(org.apache.knox.gateway.services.Service) DefaultCryptoService(org.apache.knox.gateway.services.security.impl.DefaultCryptoService)

Example 2 with Service

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

the class SslServiceFactory 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 JettySSLService();
        ((JettySSLService) service).setKeystoreService(getKeystoreService(gatewayServices));
        ((JettySSLService) service).setAliasService(getAliasService(gatewayServices));
    }
    return service;
}
Also used : Service(org.apache.knox.gateway.services.Service) JettySSLService(org.apache.knox.gateway.services.security.impl.JettySSLService) JettySSLService(org.apache.knox.gateway.services.security.impl.JettySSLService)

Example 3 with Service

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

the class TokenServiceFactory 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 DefaultTokenAuthorityService();
        ((DefaultTokenAuthorityService) service).setKeystoreService(getKeystoreService(gatewayServices));
        ((DefaultTokenAuthorityService) service).setAliasService(getAliasService(gatewayServices));
    }
    return service;
}
Also used : DefaultTokenAuthorityService(org.apache.knox.gateway.services.token.impl.DefaultTokenAuthorityService) Service(org.apache.knox.gateway.services.Service) DefaultTokenAuthorityService(org.apache.knox.gateway.services.token.impl.DefaultTokenAuthorityService)

Example 4 with Service

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

the class ServiceFactoryTest method shouldReturnCustomImplementation.

private void shouldReturnCustomImplementation(AbstractServiceFactory serviceFactory, ServiceType matchingServiceType) throws Exception {
    final Service service = serviceFactory.create(gatewayServices, matchingServiceType, null, null, "org.apache.knox.gateway.services.TestService");
    assertTrue(service instanceof TestService);
}
Also used : TestService(org.apache.knox.gateway.services.TestService) AliasService(org.apache.knox.gateway.services.security.AliasService) RemoteConfigurationRegistryClientService(org.apache.knox.gateway.services.config.client.RemoteConfigurationRegistryClientService) TestService(org.apache.knox.gateway.services.TestService) MasterService(org.apache.knox.gateway.services.security.MasterService) KeystoreService(org.apache.knox.gateway.services.security.KeystoreService) Service(org.apache.knox.gateway.services.Service)

Example 5 with Service

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

the class ServiceDiscoveryFactory method get.

public static ServiceDiscovery get(String type, Service... gatewayServices) {
    ServiceDiscovery sd = null;
    // Look up the available ServiceDiscovery types
    ServiceLoader<ServiceDiscoveryType> loader = ServiceLoader.load(ServiceDiscoveryType.class);
    for (ServiceDiscoveryType sdt : loader) {
        if (sdt.getType().equalsIgnoreCase(type)) {
            try {
                ServiceDiscovery instance = sdt.newInstance();
                // (is this necessary?)
                if (instance.getType().equalsIgnoreCase(type)) {
                    sd = instance;
                    // Inject any gateway services that were specified, and which are referenced in the impl
                    if (gatewayServices != null && gatewayServices.length > 0) {
                        for (Field field : sd.getClass().getDeclaredFields()) {
                            if (field.getDeclaredAnnotation(GatewayService.class) != null) {
                                for (Service s : gatewayServices) {
                                    if (s != null) {
                                        if (field.getType().isAssignableFrom(s.getClass())) {
                                            field.setAccessible(true);
                                            field.set(sd, s);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    return sd;
}
Also used : Field(java.lang.reflect.Field) Service(org.apache.knox.gateway.services.Service)

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