use of javax.security.auth.login.Configuration in project cxf by apache.
the class JAASLoginInterceptorTest method createTestJaasLoginInterceptor.
private JAASLoginInterceptor createTestJaasLoginInterceptor() {
JAASLoginInterceptor jaasInt = new JAASLoginInterceptor();
jaasInt.setReportFault(true);
Configuration config = new Configuration() {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
Map<String, String> options = new HashMap<>();
AppConfigurationEntry configEntry = new AppConfigurationEntry(TestUserPasswordLoginModule.class.getName(), LoginModuleControlFlag.REQUIRED, options);
return Collections.singleton(configEntry).toArray(new AppConfigurationEntry[] {});
}
};
jaasInt.setLoginConfig(config);
return jaasInt;
}
use of javax.security.auth.login.Configuration in project knox by apache.
the class RemoteConfigurationRegistryClientServiceTest method setupAndStartSecureTestZooKeeper.
/**
* Setup and start a secure test ZooKeeper cluster.
*/
private TestingCluster setupAndStartSecureTestZooKeeper(String principal, String digestPassword) throws Exception {
final boolean applyAuthentication = (principal != null);
// Configure security for the ZK cluster instances
Map<String, Object> customInstanceSpecProps = new HashMap<>();
if (applyAuthentication) {
customInstanceSpecProps.put("authProvider.1", "org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
customInstanceSpecProps.put("requireClientAuthScheme", "sasl");
}
// Define the test cluster
List<InstanceSpec> instanceSpecs = new ArrayList<>();
for (int i = 0; i < 3; i++) {
InstanceSpec is = new InstanceSpec(null, -1, -1, -1, false, (i + 1), -1, -1, customInstanceSpecProps);
instanceSpecs.add(is);
}
TestingCluster zkCluster = new TestingCluster(instanceSpecs);
if (applyAuthentication) {
// Setup ZooKeeper server SASL
Map<String, String> digestOptions = new HashMap<>();
digestOptions.put("user_" + principal, digestPassword);
final AppConfigurationEntry[] serverEntries = { new AppConfigurationEntry("org.apache.zookeeper.server.auth.DigestLoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, digestOptions) };
Configuration.setConfiguration(new Configuration() {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
return ("Server".equalsIgnoreCase(name)) ? serverEntries : null;
}
});
}
// Start the cluster
zkCluster.start();
return zkCluster;
}
use of javax.security.auth.login.Configuration in project wildfly-camel by wildfly-extras.
the class LoginContextBuilder method getClientLoginContext.
// Provides a RunAs client login context
private LoginContext getClientLoginContext() throws LoginException {
Configuration config = new Configuration() {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
Map<String, String> options = new HashMap<String, String>();
options.put("multi-threaded", "true");
options.put("restore-login-identity", "true");
AppConfigurationEntry clmEntry = new AppConfigurationEntry(ClientLoginModule.class.getName(), LoginModuleControlFlag.REQUIRED, options);
return new AppConfigurationEntry[] { clmEntry };
}
};
return getLoginContext(config);
}
use of javax.security.auth.login.Configuration in project jackrabbit-oak by apache.
the class JaasLoginContextTest method before.
@Before
public void before() {
Configuration c = ConfigurationUtil.getDefaultConfiguration(ConfigurationParameters.EMPTY);
Configuration.setConfiguration(c);
}
use of javax.security.auth.login.Configuration in project polymap4-core by Polymap4.
the class SpnegoFilterConfig method doClientModule.
private void doClientModule(final String moduleName) {
assert moduleExists("client", moduleName);
this.clientLoginModule = moduleName;
// client must not have any options
// confirm that runtime loaded the login file
final Configuration config = Configuration.getConfiguration();
// we only expect one entry
final AppConfigurationEntry entry = config.getAppConfigurationEntry(moduleName)[0];
// get login module options
final Map<String, ?> opt = entry.getOptions();
// assert
if (!opt.isEmpty()) {
for (Map.Entry<String, ?> option : opt.entrySet()) {
// unless they are jboss options
if (!option.getKey().startsWith("jboss")) {
throw new UnsupportedOperationException("Login Module for client must not " + "specify any options: " + opt.size() + "; moduleName=" + moduleName + "; options=" + opt.toString());
}
}
}
}
Aggregations