use of org.apache.knox.gateway.service.config.remote.RemoteConfigurationRegistryConfig in project knox by apache.
the class CuratorClientService method init.
@Override
public void init(GatewayConfig config, Map<String, String> options) throws ServiceLifecycleException {
List<RemoteConfigurationRegistryConfig> registryConfigs = new ArrayList<>();
// Load the remote registry configurations
registryConfigs.addAll(RemoteConfigurationRegistriesAccessor.getRemoteRegistryConfigurations(config));
// Configure registry authentication
RemoteConfigurationRegistryJAASConfig.configure(registryConfigs, aliasService);
if (registryConfigs.size() > 1) {
// Warn about current limit on number of supported client configurations
log.multipleRemoteRegistryConfigurations();
}
// Create the clients
for (RemoteConfigurationRegistryConfig registryConfig : registryConfigs) {
if (TYPE.equalsIgnoreCase(registryConfig.getRegistryType())) {
RemoteConfigurationRegistryClient registryClient = createClient(registryConfig);
clients.put(registryConfig.getName(), registryClient);
}
}
}
use of org.apache.knox.gateway.service.config.remote.RemoteConfigurationRegistryConfig in project knox by apache.
the class RemoteConfigurationRegistryJAASConfigTest method testZooKeeperDigestContextEntry.
@Test
public void testZooKeeperDigestContextEntry() throws Exception {
List<RemoteConfigurationRegistryConfig> registryConfigs = new ArrayList<>();
final String ENTRY_NAME = "my_digest_context";
final String DIGEST_PRINCIPAL = "myIdentity";
final String DIGEST_PWD_ALIAS = "myAlias";
final String DIGEST_PWD = "mysecret";
AliasService aliasService = EasyMock.createNiceMock(AliasService.class);
EasyMock.expect(aliasService.getPasswordFromAliasForGateway(DIGEST_PWD_ALIAS)).andReturn(DIGEST_PWD.toCharArray()).anyTimes();
EasyMock.replay(aliasService);
registryConfigs.add(createDigestConfig(ENTRY_NAME, DIGEST_PRINCIPAL, DIGEST_PWD_ALIAS));
try {
RemoteConfigurationRegistryJAASConfig jaasConfig = RemoteConfigurationRegistryJAASConfig.configure(registryConfigs, aliasService);
// Make sure there are no entries for an invalid context entry name
assertNull(jaasConfig.getAppConfigurationEntry("invalid"));
// Validate the intended context entry
validateDigestContext(jaasConfig, ENTRY_NAME, RemoteConfigurationRegistryJAASConfig.digestLoginModules.get("ZOOKEEPER"), DIGEST_PRINCIPAL, DIGEST_PWD);
} finally {
Configuration.setConfiguration(null);
}
}
use of org.apache.knox.gateway.service.config.remote.RemoteConfigurationRegistryConfig in project knox by apache.
the class RemoteConfigurationRegistryJAASConfigTest method createDigestConfig.
private static RemoteConfigurationRegistryConfig createDigestConfig(String entryName, String principal, String credentialAlias, String registryType) {
RemoteConfigurationRegistryConfig rc = EasyMock.createNiceMock(RemoteConfigurationRegistryConfig.class);
EasyMock.expect(rc.getRegistryType()).andReturn(registryType).anyTimes();
EasyMock.expect(rc.getName()).andReturn(entryName).anyTimes();
EasyMock.expect(rc.isSecureRegistry()).andReturn(true).anyTimes();
EasyMock.expect(rc.getAuthType()).andReturn("digest").anyTimes();
EasyMock.expect(rc.getPrincipal()).andReturn(principal).anyTimes();
EasyMock.expect(rc.getCredentialAlias()).andReturn(credentialAlias).anyTimes();
EasyMock.replay(rc);
return rc;
}
use of org.apache.knox.gateway.service.config.remote.RemoteConfigurationRegistryConfig in project knox by apache.
the class RemoteConfigurationRegistryJAASConfigTest method createKerberosConfig.
private static RemoteConfigurationRegistryConfig createKerberosConfig(String entryName, String principal, String keyTabPath, Boolean useKeyTab, Boolean useTicketCache, String registryType) {
RemoteConfigurationRegistryConfig rc = EasyMock.createNiceMock(RemoteConfigurationRegistryConfig.class);
EasyMock.expect(rc.getRegistryType()).andReturn(registryType).anyTimes();
EasyMock.expect(rc.getName()).andReturn(entryName).anyTimes();
EasyMock.expect(rc.isSecureRegistry()).andReturn(true).anyTimes();
EasyMock.expect(rc.getAuthType()).andReturn("kerberos").anyTimes();
EasyMock.expect(rc.getPrincipal()).andReturn(principal).anyTimes();
EasyMock.expect(rc.getKeytab()).andReturn(keyTabPath).anyTimes();
EasyMock.expect(rc.isUseKeyTab()).andReturn(useKeyTab != null ? useKeyTab : true).anyTimes();
EasyMock.expect(rc.isUseTicketCache()).andReturn(useTicketCache != null ? useTicketCache : false).anyTimes();
EasyMock.replay(rc);
return rc;
}
use of org.apache.knox.gateway.service.config.remote.RemoteConfigurationRegistryConfig in project knox by apache.
the class RemoteConfigurationRegistryJAASConfigTest method testZooKeeperMultipleContextEntries.
@Test
public void testZooKeeperMultipleContextEntries() throws Exception {
List<RemoteConfigurationRegistryConfig> registryConfigs = new ArrayList<>();
final String KERBEROS_ENTRY_NAME = "my_kerberos_context";
final String KERBEROS_PRINCIPAL = "myKerberosIdentity";
final String DIGEST_ENTRY_NAME = "my_digest_context";
final String DIGEST_PRINCIPAL = "myDigestIdentity";
final String DIGEST_PWD_ALIAS = "myAlias";
final String DIGEST_PWD = "mysecret";
AliasService aliasService = EasyMock.createNiceMock(AliasService.class);
EasyMock.expect(aliasService.getPasswordFromAliasForGateway(DIGEST_PWD_ALIAS)).andReturn(DIGEST_PWD.toCharArray()).anyTimes();
EasyMock.replay(aliasService);
File dummyKeyTab = File.createTempFile("my_context", "keytab");
registryConfigs.add(createKerberosConfig(KERBEROS_ENTRY_NAME, KERBEROS_PRINCIPAL, dummyKeyTab.getAbsolutePath()));
registryConfigs.add(createDigestConfig(DIGEST_ENTRY_NAME, DIGEST_PRINCIPAL, DIGEST_PWD_ALIAS));
try {
RemoteConfigurationRegistryJAASConfig jaasConfig = RemoteConfigurationRegistryJAASConfig.configure(registryConfigs, aliasService);
// Make sure there are no entries for an invalid context entry name
assertNull(jaasConfig.getAppConfigurationEntry("invalid"));
// Validate the kerberos context entry
validateKerberosContext(jaasConfig, KERBEROS_ENTRY_NAME, KERBEROS_PRINCIPAL, dummyKeyTab.getAbsolutePath(), true, false);
// Validate the digest context entry
validateDigestContext(jaasConfig, DIGEST_ENTRY_NAME, RemoteConfigurationRegistryJAASConfig.digestLoginModules.get("ZOOKEEPER"), DIGEST_PRINCIPAL, DIGEST_PWD);
} finally {
Configuration.setConfiguration(null);
}
}
Aggregations