Search in sources :

Example 1 with JaasRealm

use of org.apache.karaf.jaas.config.JaasRealm 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)

Example 2 with JaasRealm

use of org.apache.karaf.jaas.config.JaasRealm in project karaf by apache.

the class ListPendingCommand method execute.

@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) {
        String moduleClass = (String) entry.getOptions().get(ProxyLoginModule.PROPERTY_MODULE);
        System.out.println(String.format("JAAS Realm %s/JAAS Login Module %s", realm.getName(), moduleClass));
        if (commandQueue != null && !commandQueue.isEmpty()) {
            for (JaasCommandSupport command : commandQueue) {
                System.out.println(command);
            }
        } else {
            System.err.println("No JAAS modification command in queue");
        }
    } else {
        System.err.println("No JAAS Realm/Login Module selected");
    }
    return null;
}
Also used : JaasRealm(org.apache.karaf.jaas.config.JaasRealm) AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) Queue(java.util.Queue)

Example 3 with JaasRealm

use of org.apache.karaf.jaas.config.JaasRealm in project karaf by apache.

the class UpdateCommand 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/Login Module selected");
        return null;
    }
    BackingEngine engine = getBackingEngine(entry);
    if (engine == null) {
        System.err.println("Can't update the JAAS realm (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)

Example 4 with JaasRealm

use of org.apache.karaf.jaas.config.JaasRealm in project karaf by apache.

the class Activator method start.

@Override
public void start(final BundleContext context) throws Exception {
    ProxyLoginModule.init(context.getBundle(0).getBundleContext());
    final OsgiKeystoreManager keystoreManager = new OsgiKeystoreManager();
    keystoreInstanceServiceTracker = new ServiceTracker<>(context, KeystoreInstance.class, new ServiceTrackerCustomizer<KeystoreInstance, KeystoreInstance>() {

        @Override
        public KeystoreInstance addingService(ServiceReference<KeystoreInstance> reference) {
            KeystoreInstance service = context.getService(reference);
            keystoreManager.register(service, null);
            return service;
        }

        @Override
        public void modifiedService(ServiceReference<KeystoreInstance> reference, KeystoreInstance service) {
        }

        @Override
        public void removedService(ServiceReference<KeystoreInstance> reference, KeystoreInstance service) {
            keystoreManager.unregister(service, null);
            context.ungetService(reference);
        }
    });
    keystoreInstanceServiceTracker.open();
    osgiConfiguration = new OsgiConfiguration();
    osgiConfiguration.init();
    jaasRealmServiceTracker = new ServiceTracker<>(context, JaasRealm.class, new ServiceTrackerCustomizer<JaasRealm, JaasRealm>() {

        @Override
        public JaasRealm addingService(ServiceReference<JaasRealm> reference) {
            JaasRealm service = context.getService(reference);
            osgiConfiguration.register(service, null);
            return service;
        }

        @Override
        public void modifiedService(ServiceReference<JaasRealm> reference, JaasRealm service) {
        }

        @Override
        public void removedService(ServiceReference<JaasRealm> reference, JaasRealm service) {
            osgiConfiguration.unregister(service, null);
        }
    });
    jaasRealmServiceTracker.open();
    registration = context.registerService(KeystoreManager.class, keystoreManager, null);
}
Also used : JaasRealm(org.apache.karaf.jaas.config.JaasRealm) KeystoreManager(org.apache.karaf.jaas.config.KeystoreManager) ServiceTrackerCustomizer(org.osgi.util.tracker.ServiceTrackerCustomizer) KeystoreInstance(org.apache.karaf.jaas.config.KeystoreInstance) ServiceReference(org.osgi.framework.ServiceReference)

Example 5 with JaasRealm

use of org.apache.karaf.jaas.config.JaasRealm in project karaf by apache.

the class ListRealmsCommand method execute.

@Override
public Object execute() throws Exception {
    ShellTable table = new ShellTable();
    table.column("Index");
    table.column("Realm Name");
    table.column("Login Module Class Name");
    List<JaasRealm> realms = getRealms(hidden);
    if (realms != null && realms.size() > 0) {
        int index = 1;
        for (JaasRealm realm : realms) {
            String realmName = realm.getName();
            AppConfigurationEntry[] entries = realm.getEntries();
            if (entries != null && entries.length > 0) {
                for (AppConfigurationEntry entry : entries) {
                    String moduleClass = (String) entry.getOptions().get(ProxyLoginModule.PROPERTY_MODULE);
                    table.addRow().addContent(index++, realmName, moduleClass);
                }
            }
        }
    }
    table.print(System.out, !noFormat);
    return null;
}
Also used : JaasRealm(org.apache.karaf.jaas.config.JaasRealm) AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) ShellTable(org.apache.karaf.shell.support.table.ShellTable)

Aggregations

JaasRealm (org.apache.karaf.jaas.config.JaasRealm)17 AppConfigurationEntry (javax.security.auth.login.AppConfigurationEntry)7 Bundle (org.osgi.framework.Bundle)6 Queue (java.util.Queue)3 BackingEngine (org.apache.karaf.jaas.modules.BackingEngine)3 JAASUsernameTokenValidator (org.apache.wss4j.dom.validate.JAASUsernameTokenValidator)2 ClaimsCollection (ddf.security.claims.ClaimsCollection)1 ClaimsHandler (ddf.security.claims.ClaimsHandler)1 ClaimImpl (ddf.security.claims.impl.ClaimImpl)1 ClaimsCollectionImpl (ddf.security.claims.impl.ClaimsCollectionImpl)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Subject (javax.security.auth.Subject)1 LoginException (javax.security.auth.login.LoginException)1 KeystoreInstance (org.apache.karaf.jaas.config.KeystoreInstance)1 KeystoreManager (org.apache.karaf.jaas.config.KeystoreManager)1 Module (org.apache.karaf.jaas.config.impl.Module)1 ShellTable (org.apache.karaf.shell.support.table.ShellTable)1 AuthenticationException (org.apache.shiro.authc.AuthenticationException)1