use of javax.security.auth.login.AppConfigurationEntry 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 javax.security.auth.login.AppConfigurationEntry 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 javax.security.auth.login.AppConfigurationEntry 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;
}
use of javax.security.auth.login.AppConfigurationEntry in project karaf by apache.
the class ListUsersCommand 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 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 found)");
return null;
}
return doExecute(engine);
}
use of javax.security.auth.login.AppConfigurationEntry in project karaf by apache.
the class ManageRealmCommand method execute.
@SuppressWarnings("unchecked")
@Override
public Object execute() throws Exception {
if (realmName == null && index <= 0) {
System.err.println("A valid realm or the realm index need to be specified");
return null;
}
JaasRealm oldRealm = (JaasRealm) this.session.get(JAAS_REALM);
AppConfigurationEntry oldEntry = (AppConfigurationEntry) this.session.get(JAAS_ENTRY);
if (oldRealm != null && !oldRealm.getName().equals(realmName) && !force) {
System.err.println("Another JAAS Realm is being edited. Cancel/update first, or use the --force option.");
} else if (oldEntry != null && !oldEntry.getLoginModuleName().equals(moduleName) && !force) {
System.err.println("Another JAAS Login Module is being edited. Cancel/update first, or use the --force option.");
} else {
JaasRealm realm = null;
AppConfigurationEntry entry = null;
if (index > 0) {
// user provided the index, get the realm AND entry from the index
List<JaasRealm> realms = getRealms(hidden);
if (realms != null && realms.size() > 0) {
int i = 1;
realms_loop: for (JaasRealm r : realms) {
AppConfigurationEntry[] entries = r.getEntries();
if (entries != null) {
for (AppConfigurationEntry entry1 : entries) {
if (i == index) {
realm = r;
entry = entry1;
break realms_loop;
}
i++;
}
}
}
}
} else {
List<JaasRealm> realms = getRealms(hidden);
if (realms != null && realms.size() > 0) {
for (JaasRealm r : realms) {
if (r.getName().equals(realmName)) {
realm = r;
AppConfigurationEntry[] entries = realm.getEntries();
if (entries != null) {
for (AppConfigurationEntry e : entries) {
String moduleClass = (String) e.getOptions().get(ProxyLoginModule.PROPERTY_MODULE);
if (moduleName == null) {
if (getBackingEngine(e) != null) {
entry = e;
break;
}
} else {
if (moduleName.equals(e.getLoginModuleName()) || moduleName.equals(moduleClass)) {
if (getBackingEngine(e) != null) {
entry = e;
break;
}
}
}
}
if (entry != null) {
break;
}
}
}
}
}
}
if (realm == null) {
System.err.println("JAAS realm has not been found.");
return null;
}
if (entry == null) {
System.err.println("JAAS module has not been found.");
return null;
}
Queue<JaasCommandSupport> commands = null;
commands = (Queue<JaasCommandSupport>) this.session.get(JAAS_CMDS);
if (commands == null) {
commands = new LinkedList<>();
}
this.session.put(JAAS_REALM, realm);
this.session.put(JAAS_ENTRY, entry);
this.session.put(JAAS_CMDS, commands);
}
return null;
}
Aggregations