use of org.apache.jackrabbit.oak.spi.security.authentication.PreAuthContext in project jackrabbit-oak by apache.
the class LoginContextProviderImpl method getLoginContext.
@Override
@Nonnull
public LoginContext getLoginContext(Credentials credentials, String workspaceName) throws LoginException {
Subject subject = getSubject();
if (subject != null && credentials == null) {
log.debug("Found pre-authenticated subject: No further login actions required.");
return new PreAuthContext(subject);
}
if (subject == null) {
subject = new Subject();
}
CallbackHandler handler = getCallbackHandler(credentials, workspaceName);
return new JaasLoginContext(appName, subject, handler, getConfiguration());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.PreAuthContext in project jackrabbit-oak by apache.
the class LoginContextProviderImplTest method testGetPreAuthLoginContext.
@Test
public void testGetPreAuthLoginContext() {
Subject subject = new Subject(true, ImmutableSet.<Principal>of(), ImmutableSet.of(), ImmutableSet.of());
LoginContext ctx = Subject.doAs(subject, new PrivilegedAction<LoginContext>() {
@Override
public LoginContext run() {
try {
return lcProvider.getLoginContext(null, null);
} catch (LoginException e) {
throw new RuntimeException();
}
}
});
assertTrue(ctx instanceof PreAuthContext);
assertSame(subject, ctx.getSubject());
}
Aggregations