Search in sources :

Example 1 with EmbeddedSystemAdministrator

use of org.glassfish.internal.api.EmbeddedSystemAdministrator 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);
    }
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) EmbeddedSystemAdministrator(org.glassfish.internal.api.EmbeddedSystemAdministrator) InserverCommandRunnerHelper(com.sun.enterprise.v3.admin.InserverCommandRunnerHelper) ParameterMap(org.glassfish.api.admin.ParameterMap) ActionReport(org.glassfish.api.ActionReport) PlainTextActionReporter(com.sun.enterprise.admin.report.PlainTextActionReporter)

Aggregations

PlainTextActionReporter (com.sun.enterprise.admin.report.PlainTextActionReporter)1 InserverCommandRunnerHelper (com.sun.enterprise.v3.admin.InserverCommandRunnerHelper)1 ActionReport (org.glassfish.api.ActionReport)1 ParameterMap (org.glassfish.api.admin.ParameterMap)1 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)1 EmbeddedSystemAdministrator (org.glassfish.internal.api.EmbeddedSystemAdministrator)1