Search in sources :

Example 1 with AbstractSecuredService

use of org.nhindirect.common.rest.AbstractSecuredService in project nhin-d by DirectProject.

the class DefaultRESTServiceModule_createServiceTest method testCreateServiceFromModule.

@Test
public void testCreateServiceFromModule() throws Exception {
    final Injector configInjector = Guice.createInjector(DefaultRESTServiceModule.create("http://bogus", new OpenServiceSecurityManager()));
    AbstractSecuredService service = (AbstractSecuredService) configInjector.getInstance(AddressService.class);
    assertTrue(service instanceof DefaultAddressService);
    service = (AbstractSecuredService) configInjector.getInstance(AnchorService.class);
    assertTrue(service instanceof DefaultAnchorService);
    service = (AbstractSecuredService) configInjector.getInstance(CertificateService.class);
    assertTrue(service instanceof DefaultCertificateService);
    service = (AbstractSecuredService) configInjector.getInstance(CertPolicyService.class);
    assertTrue(service instanceof DefaultCertPolicyService);
    service = (AbstractSecuredService) configInjector.getInstance(DNSService.class);
    assertTrue(service instanceof DefaultDNSService);
    service = (AbstractSecuredService) configInjector.getInstance(DomainService.class);
    assertTrue(service instanceof DefaultDomainService);
    service = (AbstractSecuredService) configInjector.getInstance(SettingService.class);
    assertTrue(service instanceof DefaultSettingService);
    service = (AbstractSecuredService) configInjector.getInstance(TrustBundleService.class);
    assertTrue(service instanceof DefaultTrustBundleService);
}
Also used : DefaultAddressService(org.nhind.config.rest.impl.DefaultAddressService) AbstractSecuredService(org.nhindirect.common.rest.AbstractSecuredService) DefaultDNSService(org.nhind.config.rest.impl.DefaultDNSService) DefaultAnchorService(org.nhind.config.rest.impl.DefaultAnchorService) DefaultAddressService(org.nhind.config.rest.impl.DefaultAddressService) AddressService(org.nhind.config.rest.AddressService) DefaultDomainService(org.nhind.config.rest.impl.DefaultDomainService) DefaultCertificateService(org.nhind.config.rest.impl.DefaultCertificateService) DefaultSettingService(org.nhind.config.rest.impl.DefaultSettingService) Injector(com.google.inject.Injector) OpenServiceSecurityManager(org.nhindirect.common.rest.OpenServiceSecurityManager) DefaultCertPolicyService(org.nhind.config.rest.impl.DefaultCertPolicyService) DefaultTrustBundleService(org.nhind.config.rest.impl.DefaultTrustBundleService) Test(org.junit.Test)

Example 2 with AbstractSecuredService

use of org.nhindirect.common.rest.AbstractSecuredService in project nhin-d by DirectProject.

the class BaseTestPlan method getService.

public static AbstractSecuredService getService(String serviceURL, String serviceName) {
    final Class<?> clazz = serviceClassMap.get(serviceName);
    if (clazz == null)
        throw new IllegalArgumentException("Service name " + serviceName + " is an unknown service");
    try {
        final Constructor<?> ctr = clazz.getDeclaredConstructor(String.class, HttpClient.class, ServiceSecurityManager.class);
        final AbstractSecuredService service = (AbstractSecuredService) ctr.newInstance(serviceURL, HttpClientFactory.createHttpClient(), getTestServiceSecurityManager());
        return service;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : AbstractSecuredService(org.nhindirect.common.rest.AbstractSecuredService)

Example 3 with AbstractSecuredService

use of org.nhindirect.common.rest.AbstractSecuredService in project nhin-d by DirectProject.

the class DefaultRESTServiceProvider method get.

@SuppressWarnings("unchecked")
@Override
public T get() {
    AbstractSecuredService retVal = null;
    try {
        final Constructor<?> ctr = clazz.getDeclaredConstructor(String.class, HttpClient.class, ServiceSecurityManager.class);
        retVal = (AbstractSecuredService) ctr.newInstance(serviceURL, client, securityManager);
    } catch (Exception e) {
        throw new IllegalStateException("REST service provider is not configured correctly.");
    }
    return (T) retVal;
}
Also used : AbstractSecuredService(org.nhindirect.common.rest.AbstractSecuredService)

Aggregations

AbstractSecuredService (org.nhindirect.common.rest.AbstractSecuredService)3 Injector (com.google.inject.Injector)1 Test (org.junit.Test)1 AddressService (org.nhind.config.rest.AddressService)1 DefaultAddressService (org.nhind.config.rest.impl.DefaultAddressService)1 DefaultAnchorService (org.nhind.config.rest.impl.DefaultAnchorService)1 DefaultCertPolicyService (org.nhind.config.rest.impl.DefaultCertPolicyService)1 DefaultCertificateService (org.nhind.config.rest.impl.DefaultCertificateService)1 DefaultDNSService (org.nhind.config.rest.impl.DefaultDNSService)1 DefaultDomainService (org.nhind.config.rest.impl.DefaultDomainService)1 DefaultSettingService (org.nhind.config.rest.impl.DefaultSettingService)1 DefaultTrustBundleService (org.nhind.config.rest.impl.DefaultTrustBundleService)1 OpenServiceSecurityManager (org.nhindirect.common.rest.OpenServiceSecurityManager)1