Search in sources :

Example 1 with PrincipalProviderCallback

use of org.apache.jackrabbit.oak.spi.security.authentication.callback.PrincipalProviderCallback in project jackrabbit-oak by apache.

the class AbstractLoginModule method getPrincipalProvider.

/**
     * Retrieves the {@link PrincipalProvider} that should be used to handle
     * this authentication. If no principal provider has been configure this
     * method returns {@code null}.
     *
     * @return A instance of {@code PrincipalProvider} or {@code null}.
     */
@CheckForNull
protected PrincipalProvider getPrincipalProvider() {
    PrincipalProvider principalProvider = null;
    SecurityProvider sp = getSecurityProvider();
    Root r = getRoot();
    if (r != null && sp != null) {
        PrincipalConfiguration pc = sp.getConfiguration(PrincipalConfiguration.class);
        principalProvider = pc.getPrincipalProvider(r, NamePathMapper.DEFAULT);
    }
    if (principalProvider == null && callbackHandler != null) {
        try {
            PrincipalProviderCallback principalCallBack = new PrincipalProviderCallback();
            callbackHandler.handle(new Callback[] { principalCallBack });
            principalProvider = principalCallBack.getPrincipalProvider();
        } catch (IOException | UnsupportedCallbackException e) {
            log.debug(e.getMessage());
        }
    }
    return principalProvider;
}
Also used : PrincipalProvider(org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider) Root(org.apache.jackrabbit.oak.api.Root) PrincipalConfiguration(org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration) PrincipalProviderCallback(org.apache.jackrabbit.oak.spi.security.authentication.callback.PrincipalProviderCallback) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) IOException(java.io.IOException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) CheckForNull(javax.annotation.CheckForNull)

Aggregations

IOException (java.io.IOException)1 CheckForNull (javax.annotation.CheckForNull)1 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)1 Root (org.apache.jackrabbit.oak.api.Root)1 SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)1 PrincipalProviderCallback (org.apache.jackrabbit.oak.spi.security.authentication.callback.PrincipalProviderCallback)1 PrincipalConfiguration (org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration)1 PrincipalProvider (org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider)1