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);
}
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;
}
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);
}
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);
}
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;
}
Aggregations