Search in sources :

Example 1 with FileSecureStoreService

use of io.cdap.cdap.security.store.FileSecureStoreService in project cdap by caskdata.

the class RemoteSecureStoreTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    CConfiguration conf = CConfiguration.create();
    conf.setBoolean(Constants.Security.SSL.INTERNAL_ENABLED, true);
    conf.set(Constants.Security.Store.FILE_PATH, TEMP_FOLDER.newFolder().getAbsolutePath());
    SConfiguration sConf = SConfiguration.create();
    sConf.set(Constants.Security.Store.FILE_PASSWORD, "secret");
    InMemoryNamespaceAdmin namespaceClient = new InMemoryNamespaceAdmin();
    NamespaceMeta namespaceMeta = new NamespaceMeta.Builder().setName(NAMESPACE1).build();
    namespaceClient.create(namespaceMeta);
    FileSecureStoreService fileSecureStoreService = new FileSecureStoreService(conf, sConf, namespaceClient);
    // Starts a mock server to handle remote secure store requests
    httpService = new HttpsEnabler().configureKeyStore(conf, sConf).enable(NettyHttpService.builder("remoteSecureStoreTest").setHttpHandlers(new SecureStoreHandler(fileSecureStoreService, fileSecureStoreService)).setExceptionHandler(new HttpExceptionHandler())).build();
    httpService.start();
    InMemoryDiscoveryService discoveryService = new InMemoryDiscoveryService();
    discoveryService.register(URIScheme.HTTPS.createDiscoverable(Constants.Service.SECURE_STORE_SERVICE, httpService.getBindAddress()));
    RemoteClientFactory remoteClientFactory = new RemoteClientFactory(discoveryService, new DefaultInternalAuthenticator(new AuthenticationTestContext()));
    remoteSecureStore = new RemoteSecureStore(remoteClientFactory);
}
Also used : RemoteClientFactory(io.cdap.cdap.common.internal.remote.RemoteClientFactory) FileSecureStoreService(io.cdap.cdap.security.store.FileSecureStoreService) AuthenticationTestContext(io.cdap.cdap.security.auth.context.AuthenticationTestContext) HttpExceptionHandler(io.cdap.cdap.common.HttpExceptionHandler) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) DefaultInternalAuthenticator(io.cdap.cdap.common.internal.remote.DefaultInternalAuthenticator) InMemoryNamespaceAdmin(io.cdap.cdap.common.namespace.InMemoryNamespaceAdmin) NamespaceMeta(io.cdap.cdap.proto.NamespaceMeta) SConfiguration(io.cdap.cdap.common.conf.SConfiguration) HttpsEnabler(io.cdap.cdap.common.security.HttpsEnabler) SecureStoreHandler(io.cdap.cdap.security.store.SecureStoreHandler) InMemoryDiscoveryService(org.apache.twill.discovery.InMemoryDiscoveryService) BeforeClass(org.junit.BeforeClass)

Aggregations

HttpExceptionHandler (io.cdap.cdap.common.HttpExceptionHandler)1 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)1 SConfiguration (io.cdap.cdap.common.conf.SConfiguration)1 DefaultInternalAuthenticator (io.cdap.cdap.common.internal.remote.DefaultInternalAuthenticator)1 RemoteClientFactory (io.cdap.cdap.common.internal.remote.RemoteClientFactory)1 InMemoryNamespaceAdmin (io.cdap.cdap.common.namespace.InMemoryNamespaceAdmin)1 HttpsEnabler (io.cdap.cdap.common.security.HttpsEnabler)1 NamespaceMeta (io.cdap.cdap.proto.NamespaceMeta)1 AuthenticationTestContext (io.cdap.cdap.security.auth.context.AuthenticationTestContext)1 FileSecureStoreService (io.cdap.cdap.security.store.FileSecureStoreService)1 SecureStoreHandler (io.cdap.cdap.security.store.SecureStoreHandler)1 InMemoryDiscoveryService (org.apache.twill.discovery.InMemoryDiscoveryService)1 BeforeClass (org.junit.BeforeClass)1