use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenProvider in project jackrabbit-oak by apache.
the class TokenLoginModule method getTokenProvider.
//------------------------------------------------------------< private >---
/**
* Retrieve the token provider
* @return the token provider or {@code null}.
*/
@CheckForNull
private TokenProvider getTokenProvider() {
TokenProvider provider = null;
SecurityProvider securityProvider = getSecurityProvider();
Root root = getRoot();
if (root != null && securityProvider != null) {
TokenConfiguration tokenConfig = securityProvider.getConfiguration(TokenConfiguration.class);
provider = tokenConfig.getTokenProvider(root);
}
if (provider == null && callbackHandler != null) {
try {
TokenProviderCallback tcCallback = new TokenProviderCallback();
callbackHandler.handle(new Callback[] { tcCallback });
provider = tcCallback.getTokenProvider();
} catch (IOException e) {
log.warn(e.getMessage());
} catch (UnsupportedCallbackException e) {
log.warn(e.getMessage());
}
}
return provider;
}
use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenProvider in project jackrabbit-oak by apache.
the class TokenConfigurationImplOSGiTest method testDefaultCredentialsSupport.
@Test
public void testDefaultCredentialsSupport() throws Exception {
TokenProvider tp = tokenConfiguration.getTokenProvider(root);
assertTrue(tp.doCreateToken(sc));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenProvider in project jackrabbit-oak by apache.
the class TokenConfigurationImplOSGiTest method testUnbindCredentialsSupport.
@Test
public void testUnbindCredentialsSupport() {
CredentialsSupport testSupport = new TestCredentialsSupport(sc.getUserID());
ServiceRegistration registration = context.bundleContext().registerService(CredentialsSupport.class.getName(), testSupport, new Hashtable());
TokenProvider tp = tokenConfiguration.getTokenProvider(root);
assertFalse(tp.doCreateToken(sc));
assertTrue(tp.doCreateToken(new TestCredentialsSupport.Creds()));
registration.unregister();
tp = tokenConfiguration.getTokenProvider(root);
assertTrue(tp.doCreateToken(sc));
assertFalse(tp.doCreateToken(new TestCredentialsSupport.Creds()));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenProvider in project jackrabbit-oak by apache.
the class TokenConfigurationImplOSGiTest method testBindCredentialsSupport.
@Test
public void testBindCredentialsSupport() {
context.registerService(CredentialsSupport.class, new TestCredentialsSupport(sc.getUserID()));
TokenProvider tp = tokenConfiguration.getTokenProvider(root);
assertFalse(tp.doCreateToken(sc));
assertTrue(tp.doCreateToken(new TestCredentialsSupport.Creds()));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenProvider in project jackrabbit-oak by apache.
the class TokenLoginModuleTest method testTokenProviderCallback.
@Test
public void testTokenProviderCallback() throws Exception {
TokenProvider tp = new TokenProviderImpl(root, ConfigurationParameters.EMPTY, getUserConfiguration());
TokenLoginModule lm = new TokenLoginModule();
lm.initialize(new Subject(), new TestCallbackHandler(tp), ImmutableMap.<String, Object>of(), ImmutableMap.<String, Object>of());
assertFalse(lm.login());
}
Aggregations