use of com.sun.enterprise.v3.admin.InserverCommandRunnerHelper in project Payara by payara.
the class RealmUtil method createAuthRealm.
static void createAuthRealm(String name, String realmClass, String loginModule, Properties props) {
ServiceLocator serviceLocator = Globals.getDefaultHabitat();
InserverCommandRunnerHelper commandRunnerHelper = serviceLocator.getService(InserverCommandRunnerHelper.class);
EmbeddedSystemAdministrator administrator = serviceLocator.getService(EmbeddedSystemAdministrator.class);
ParameterMap parameters = new ParameterMap();
parameters.insert("authrealmname", name);
parameters.insert("property", props.entrySet().stream().map(prop -> escapeRealmProperty(prop.getKey().toString()) + '=' + escapeRealmProperty(prop.getValue().toString())).collect(joining(":")));
parameters.insert("classname", realmClass);
if (loginModule != null) {
parameters.insert("login-module", loginModule);
}
ActionReport report = new PlainTextActionReporter();
ActionReport outreport = commandRunnerHelper.runCommand("create-auth-realm", parameters, report, administrator.getSubject());
if (outreport.getActionExitCode() == ActionReport.ExitCode.FAILURE) {
throw new IllegalStateException("Error in creating Auth realm: " + name);
}
}
Aggregations