use of javax.security.auth.login.Configuration in project camel by apache.
the class HdfsProducer method doStart.
@Override
protected void doStart() throws Exception {
// need to remember auth as Hadoop will override that, which otherwise means the Auth is broken afterwards
Configuration auth = HdfsComponent.getJAASConfiguration();
try {
super.doStart();
// setup hdfs if configured to do on startup
if (getEndpoint().getConfig().isConnectOnStartup()) {
ostream = setupHdfs(true);
}
SplitStrategy idleStrategy = null;
for (SplitStrategy strategy : config.getSplitStrategies()) {
if (strategy.type == SplitStrategyType.IDLE) {
idleStrategy = strategy;
break;
}
}
if (idleStrategy != null) {
scheduler = getEndpoint().getCamelContext().getExecutorServiceManager().newSingleThreadScheduledExecutor(this, "HdfsIdleCheck");
log.debug("Creating IdleCheck task scheduled to run every {} millis", config.getCheckIdleInterval());
scheduler.scheduleAtFixedRate(new IdleCheck(idleStrategy), config.getCheckIdleInterval(), config.getCheckIdleInterval(), TimeUnit.MILLISECONDS);
}
} finally {
HdfsComponent.setJAASConfiguration(auth);
}
}
use of javax.security.auth.login.Configuration in project camel by apache.
the class HdfsProducer method doStart.
@Override
protected void doStart() throws Exception {
// need to remember auth as Hadoop will override that, which otherwise means the Auth is broken afterwards
Configuration auth = HdfsComponent.getJAASConfiguration();
try {
super.doStart();
// setup hdfs if configured to do on startup
if (getEndpoint().getConfig().isConnectOnStartup()) {
ostream = setupHdfs(true);
}
SplitStrategy idleStrategy = null;
for (SplitStrategy strategy : config.getSplitStrategies()) {
if (strategy.type == SplitStrategyType.IDLE) {
idleStrategy = strategy;
break;
}
}
if (idleStrategy != null) {
scheduler = getEndpoint().getCamelContext().getExecutorServiceManager().newSingleThreadScheduledExecutor(this, "HdfsIdleCheck");
log.debug("Creating IdleCheck task scheduled to run every {} millis", config.getCheckIdleInterval());
scheduler.scheduleAtFixedRate(new IdleCheck(idleStrategy), config.getCheckIdleInterval(), config.getCheckIdleInterval(), TimeUnit.MILLISECONDS);
}
} finally {
HdfsComponent.setJAASConfiguration(auth);
}
}
use of javax.security.auth.login.Configuration in project felix by apache.
the class ITJaasWithConfigBasedLoginModule method testJaasConfigPassing.
/**
* Validates that OSGi config do gets passed as part of options to the LoginModule
*/
@Test
public void testJaasConfigPassing() throws Exception {
String realmName = name.getMethodName();
// 1. Create sample config
org.osgi.service.cm.Configuration config = ca.createFactoryConfiguration("org.apache.felix.jaas.Configuration.factory", null);
Dictionary<String, Object> p = new Hashtable<String, Object>();
p.put("jaas.classname", "org.apache.felix.jaas.integration.sample1.ConfigLoginModule");
p.put("jaas.realmName", realmName);
// Following passed config gets validated in
// org.apache.felix.jaas.integration.sample1.ConfigLoginModule.validateConfig()
p.put("validateConfig", Boolean.TRUE);
p.put("key0", "val0");
p.put("key1", "val1");
p.put("key2", "val2");
// Override the value directly passed in config via options value explicitly
p.put("jaas.options", new String[] { "key3=val3", "key4=val4", "key0=valNew" });
config.update(p);
delay();
// 2. Validate the login passes with this config. LoginModule would validate
// the config also
CallbackHandler handler = new SimpleCallbackHandler("foo", "foo");
Configuration jaasConfig = Configuration.getInstance("JavaLoginConfig", null, "FelixJaasProvider");
Subject s = new Subject();
final ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
LoginContext lc = new LoginContext(realmName, s, handler, jaasConfig);
lc.login();
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
assertFalse(s.getPrincipals().isEmpty());
}
use of javax.security.auth.login.Configuration in project airlift by airlift.
the class SpnegoAuthentication method getSession.
private synchronized Session getSession() throws LoginException, GSSException {
if (clientSession == null || clientSession.getClientCredential().getRemainingLifetime() < MIN_CREDENTIAL_LIFE_TIME.getValue(TimeUnit.SECONDS)) {
// TODO: do we need to call logout() on the LoginContext?
LoginContext loginContext = new LoginContext("", null, null, new Configuration() {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
ImmutableMap.Builder<String, String> optionsBuilder = ImmutableMap.builder();
optionsBuilder.put("refreshKrb5Config", "true");
optionsBuilder.put("doNotPrompt", "true");
optionsBuilder.put("useKeyTab", "true");
if (LOG.isDebugEnabled()) {
optionsBuilder.put("debug", "true");
}
if (keytab != null) {
optionsBuilder.put("keyTab", keytab.getAbsolutePath());
}
if (credentialCache != null) {
optionsBuilder.put("ticketCache", credentialCache.getAbsolutePath());
optionsBuilder.put("useTicketCache", "true");
optionsBuilder.put("renewTGT", "true");
}
if (principal != null) {
optionsBuilder.put("principal", principal);
}
return new AppConfigurationEntry[] { new AppConfigurationEntry(Krb5LoginModule.class.getName(), REQUIRED, optionsBuilder.build()) };
}
});
loginContext.login();
Subject subject = loginContext.getSubject();
Principal clientPrincipal = subject.getPrincipals().iterator().next();
GSSCredential clientCredential = doAs(subject, () -> GSS_MANAGER.createCredential(GSS_MANAGER.createName(clientPrincipal.getName(), NT_USER_NAME), DEFAULT_LIFETIME, KERBEROS_OID, INITIATE_ONLY));
clientSession = new Session(loginContext, clientCredential);
}
return clientSession;
}
use of javax.security.auth.login.Configuration in project simba-os by cegeka.
the class JaasLoginCommandTest method setupJAAS.
private void setupJAAS() {
Configuration configurationMock = mock(Configuration.class);
AppConfigurationEntry entry = new AppConfigurationEntry(TestLoginModule.class.getName(), LoginModuleControlFlag.REQUIRED, Collections.<String, Object>emptyMap());
when(configurationMock.getAppConfigurationEntry(LOGIN_MODULE_NAME)).thenReturn(new AppConfigurationEntry[] { entry });
Configuration.setConfiguration(configurationMock);
}
Aggregations