Search in sources :

Example 31 with AppConfigurationEntry

use of javax.security.auth.login.AppConfigurationEntry in project jackrabbit-oak by apache.

the class TokenDefaultLoginModuleTest method getConfiguration.

@Override
protected Configuration getConfiguration() {
    return new Configuration() {

        @Override
        public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
            AppConfigurationEntry tokenEntry = new AppConfigurationEntry(TokenLoginModule.class.getName(), AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT, Collections.<String, Object>emptyMap());
            AppConfigurationEntry defaultEntry = new AppConfigurationEntry(LoginModuleImpl.class.getName(), AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, Collections.<String, Object>emptyMap());
            return new AppConfigurationEntry[] { tokenEntry, defaultEntry };
        }
    };
}
Also used : AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) LoginModuleImpl(org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl) Configuration(javax.security.auth.login.Configuration)

Example 32 with AppConfigurationEntry

use of javax.security.auth.login.AppConfigurationEntry in project jackrabbit by apache.

the class AuthContextProvider method getModuleConfig.

/**
     * @return options configured for the LoginModules to use.
     */
public Properties[] getModuleConfig() {
    Properties[] props = new Properties[0];
    if (isLocal()) {
        props = new Properties[] { config.getParameters() };
    } else {
        AppConfigurationEntry[] entries = getJAASConfig();
        if (entries != null) {
            List<Properties> tmp = new ArrayList<Properties>(entries.length);
            for (AppConfigurationEntry entry : entries) {
                Map opt = entry.getOptions();
                if (opt != null) {
                    Properties prop = new Properties();
                    prop.putAll(opt);
                    tmp.add(prop);
                }
            }
            props = tmp.toArray(new Properties[tmp.size()]);
        }
    }
    return props;
}
Also used : AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) ArrayList(java.util.ArrayList) Properties(java.util.Properties) Map(java.util.Map)

Example 33 with AppConfigurationEntry

use of javax.security.auth.login.AppConfigurationEntry in project jackrabbit-oak by apache.

the class GuestDefaultLoginModuleTest method getConfiguration.

@Override
protected Configuration getConfiguration() {
    return new Configuration() {

        @Override
        public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
            AppConfigurationEntry guestEntry = new AppConfigurationEntry(GuestLoginModule.class.getName(), AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL, Collections.<String, Object>emptyMap());
            AppConfigurationEntry defaultEntry = new AppConfigurationEntry(LoginModuleImpl.class.getName(), AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, Collections.<String, Object>emptyMap());
            return new AppConfigurationEntry[] { guestEntry, defaultEntry };
        }
    };
}
Also used : AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) LoginModuleImpl(org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl) Configuration(javax.security.auth.login.Configuration) GuestLoginModule(org.apache.jackrabbit.oak.spi.security.authentication.GuestLoginModule)

Example 34 with AppConfigurationEntry

use of javax.security.auth.login.AppConfigurationEntry in project karaf by apache.

the class JaasCommandSupport method execute.

/**
     * Add the command to the command queue.
     */
@Override
public Object execute() throws Exception {
    JaasRealm realm = (JaasRealm) session.get(JAAS_REALM);
    AppConfigurationEntry entry = (AppConfigurationEntry) session.get(JAAS_ENTRY);
    @SuppressWarnings("unchecked") Queue<JaasCommandSupport> commandQueue = (Queue<JaasCommandSupport>) session.get(JAAS_CMDS);
    if (realm != null && entry != null) {
        if (commandQueue != null) {
            commandQueue.add(this);
        }
    } else {
        System.err.println("No JAAS Realm / Module has been selected");
    }
    return null;
}
Also used : JaasRealm(org.apache.karaf.jaas.config.JaasRealm) AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) Queue(java.util.Queue)

Example 35 with AppConfigurationEntry

use of javax.security.auth.login.AppConfigurationEntry in project karaf by apache.

the class ListGroupsCommand method execute.

@Override
public Object execute() throws Exception {
    JaasRealm realm = (JaasRealm) session.get(JAAS_REALM);
    AppConfigurationEntry entry = (AppConfigurationEntry) session.get(JAAS_ENTRY);
    if (realm == null || entry == null) {
        System.err.println("No JAAS Realm / Module has been selected.");
        return null;
    }
    BackingEngine engine = getBackingEngine(entry);
    if (engine == null) {
        System.err.println("Can't get the list of users (no backing engine service registered)");
        return null;
    }
    return doExecute(engine);
}
Also used : JaasRealm(org.apache.karaf.jaas.config.JaasRealm) BackingEngine(org.apache.karaf.jaas.modules.BackingEngine) AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry)

Aggregations

AppConfigurationEntry (javax.security.auth.login.AppConfigurationEntry)76 HashMap (java.util.HashMap)31 Configuration (javax.security.auth.login.Configuration)26 Map (java.util.Map)13 Test (org.junit.Test)11 Subject (javax.security.auth.Subject)10 LoginContext (javax.security.auth.login.LoginContext)10 SSOException (com.iplanet.sso.SSOException)7 SMSException (com.sun.identity.sm.SMSException)7 HashSet (java.util.HashSet)7 JaasRealm (org.apache.karaf.jaas.config.JaasRealm)7 Set (java.util.Set)6 LoginException (javax.security.auth.login.LoginException)5 IOException (java.io.IOException)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 CallbackHandler (javax.security.auth.callback.CallbackHandler)4 LoginModuleControlFlag (javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag)4 LoginModuleImpl (org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl)4 File (java.io.File)3 Principal (java.security.Principal)3