use of org.apache.jackrabbit.oak.spi.security.authentication.callback.RepositoryCallback in project jackrabbit-oak by apache.
the class AbstractLoginModule method getRoot.
/**
* Tries to obtain a {@code Root} object from the callback handler using
* a new RepositoryCallback and keeps the value as private field.
* If the callback handler isn't able to handle the RepositoryCallback
* this method returns {@code null}.
*
* @return The {@code Root} associated with this {@code LoginModule} or
* {@code null}.
*/
@CheckForNull
protected Root getRoot() {
if (root == null && callbackHandler != null) {
try {
final RepositoryCallback rcb = new RepositoryCallback();
callbackHandler.handle(new Callback[] { rcb });
final ContentRepository repository = rcb.getContentRepository();
if (repository != null) {
systemSession = Subject.doAs(SystemSubject.INSTANCE, new PrivilegedExceptionAction<ContentSession>() {
@Override
public ContentSession run() throws LoginException, NoSuchWorkspaceException {
return repository.login(null, rcb.getWorkspaceName());
}
});
root = systemSession.getLatestRoot();
} else {
log.debug("Unable to retrieve the Root via RepositoryCallback; ContentRepository not available.");
}
} catch (UnsupportedCallbackException | PrivilegedActionException | IOException e) {
log.debug(e.getMessage());
}
}
return root;
}
use of org.apache.jackrabbit.oak.spi.security.authentication.callback.RepositoryCallback in project jackrabbit-oak by apache.
the class AbstractLoginModule method getSecurityProvider.
/**
* Tries to obtain the {@code SecurityProvider} object from the callback
* handler using a new SecurityProviderCallback and keeps the value as
* private field. If the callback handler isn't able to handle the
* SecurityProviderCallback this method returns {@code null}.
*
* @return The {@code SecurityProvider} associated with this
* {@code LoginModule} or {@code null}.
*/
@CheckForNull
protected SecurityProvider getSecurityProvider() {
if (securityProvider == null && callbackHandler != null) {
RepositoryCallback rcb = new RepositoryCallback();
try {
callbackHandler.handle(new Callback[] { rcb });
securityProvider = rcb.getSecurityProvider();
} catch (Exception e) {
log.debug("Unable to retrieve the SecurityProvider via callback", e);
}
}
return securityProvider;
}
use of org.apache.jackrabbit.oak.spi.security.authentication.callback.RepositoryCallback in project jackrabbit-oak by apache.
the class CallbackHandlerImplTest method handleRepositoryCallback.
@Test
public void handleRepositoryCallback() throws Exception {
RepositoryCallback cb = new RepositoryCallback();
callbackHandler.handle(new Callback[] { cb });
assertSame(getContentRepository(), cb.getContentRepository());
assertSame(getSecurityProvider(), cb.getSecurityProvider());
assertEquals(root.getContentSession().getWorkspaceName(), cb.getWorkspaceName());
}
Aggregations