Search in sources :

Example 11 with NoSuchRealmException

use of com.sun.enterprise.security.auth.realm.NoSuchRealmException in project Payara by payara.

the class ListFileGroup method getFileRealm.

private FileRealm getFileRealm(final SecurityService securityService, AuthRealm fileAuthRealm, ActionReport report) {
    // Get FileRealm class name, match it with what is expected.
    String fileRealmClassName = fileAuthRealm.getClassname();
    // Report error if provided impl is not the one expected
    if (fileRealmClassName != null && !fileRealmClassName.equals("com.sun.enterprise.security.auth.realm.file.FileRealm")) {
        report.setMessage(localStrings.getLocalString("list.file.user.realmnotsupported", "Configured file realm {0} is not supported.", fileRealmClassName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return null;
    }
    // ensure we have the file associated with the authrealm
    String keyFile = null;
    for (Property fileProp : fileAuthRealm.getProperty()) {
        if (fileProp.getName().equals("file"))
            keyFile = fileProp.getValue();
    }
    if (keyFile == null) {
        report.setMessage(localStrings.getLocalString("list.file.user.keyfilenotfound", "There is no physical file associated with this file realm {0} ", authRealmName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return null;
    }
    // We have the right impl so let's try to remove one
    FileRealm fr = null;
    try {
        realmsManager.createRealms(config);
        fr = (FileRealm) realmsManager.getFromLoadedRealms(config.getName(), authRealmName);
        if (fr == null) {
            throw new NoSuchRealmException(authRealmName);
        }
    } catch (NoSuchRealmException e) {
        report.setMessage(localStrings.getLocalString("list.file.user.realmnotsupported", "Configured file realm {0} is not supported.", authRealmName) + "  " + e.getLocalizedMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
    }
    return fr;
}
Also used : NoSuchRealmException(com.sun.enterprise.security.auth.realm.NoSuchRealmException) FileRealm(com.sun.enterprise.security.auth.realm.file.FileRealm) Property(org.jvnet.hk2.config.types.Property)

Example 12 with NoSuchRealmException

use of com.sun.enterprise.security.auth.realm.NoSuchRealmException in project Payara by payara.

the class GetGroupNamesCommand method execute.

@Override
public void execute(AdminCommandContext context) {
    Config tmp = null;
    try {
        tmp = configs.getConfigByName(target);
    } catch (Exception ex) {
    }
    if (tmp != null) {
        config = tmp;
    }
    if (tmp == null) {
        Server targetServer = domain.getServerNamed(target);
        if (targetServer != null) {
            config = domain.getConfigNamed(targetServer.getConfigRef());
        }
        com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
        if (cluster != null) {
            config = domain.getConfigNamed(cluster.getConfigRef());
        }
    }
    ActionReporter report = (ActionReporter) context.getActionReport();
    try {
        String[] list = getGroupNames(realmName, userName);
        List<String> ret = Arrays.asList(list);
        report.setActionExitCode(ExitCode.SUCCESS);
        Properties props = new Properties();
        props.put("groups", ret);
        report.setExtraProperties(props);
        report.setMessage("" + ret);
    } catch (NoSuchRealmException ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    } catch (BadRealmException ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    } catch (InvalidOperationException ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    } catch (NoSuchUserException ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    }
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) Config(com.sun.enterprise.config.serverbeans.Config) NoSuchUserException(com.sun.enterprise.security.auth.realm.NoSuchUserException) Properties(java.util.Properties) BadRealmException(com.sun.enterprise.security.auth.realm.BadRealmException) NoSuchRealmException(com.sun.enterprise.security.auth.realm.NoSuchRealmException) InvalidOperationException(com.sun.enterprise.security.auth.realm.InvalidOperationException) NoSuchUserException(com.sun.enterprise.security.auth.realm.NoSuchUserException) NoSuchRealmException(com.sun.enterprise.security.auth.realm.NoSuchRealmException) BadRealmException(com.sun.enterprise.security.auth.realm.BadRealmException) InvalidOperationException(com.sun.enterprise.security.auth.realm.InvalidOperationException) ActionReporter(com.sun.enterprise.v3.common.ActionReporter)

Example 13 with NoSuchRealmException

use of com.sun.enterprise.security.auth.realm.NoSuchRealmException in project Payara by payara.

the class SupportsUserManagementCommand method execute.

@Override
public void execute(AdminCommandContext context) {
    Config tmp = null;
    try {
        tmp = configs.getConfigByName(target);
    } catch (Exception ex) {
    }
    if (tmp != null) {
        config = tmp;
    }
    if (tmp == null) {
        Server targetServer = domain.getServerNamed(target);
        if (targetServer != null) {
            config = domain.getConfigNamed(targetServer.getConfigRef());
        }
        com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
        if (cluster != null) {
            config = domain.getConfigNamed(cluster.getConfigRef());
        }
    }
    ActionReport report = context.getActionReport();
    report.setActionExitCode(ExitCode.SUCCESS);
    try {
        report.setMessage("" + supportsUserManagement(realmName));
    } catch (BadRealmException ex) {
        // throw new RuntimeException(ex);
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    } catch (NoSuchRealmException ex) {
        // throw new RuntimeException(ex);
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    } catch (Exception ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    }
}
Also used : NoSuchRealmException(com.sun.enterprise.security.auth.realm.NoSuchRealmException) BadRealmException(com.sun.enterprise.security.auth.realm.BadRealmException) Server(com.sun.enterprise.config.serverbeans.Server) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) BadRealmException(com.sun.enterprise.security.auth.realm.BadRealmException) NoSuchRealmException(com.sun.enterprise.security.auth.realm.NoSuchRealmException)

Aggregations

NoSuchRealmException (com.sun.enterprise.security.auth.realm.NoSuchRealmException)13 Property (org.jvnet.hk2.config.types.Property)7 BadRealmException (com.sun.enterprise.security.auth.realm.BadRealmException)5 Properties (java.util.Properties)5 ActionReport (org.glassfish.api.ActionReport)5 AuthRealm (com.sun.enterprise.config.serverbeans.AuthRealm)4 NoSuchUserException (com.sun.enterprise.security.auth.realm.NoSuchUserException)4 Realm (com.sun.enterprise.security.auth.realm.Realm)4 FileRealm (com.sun.enterprise.security.auth.realm.file.FileRealm)4 Config (com.sun.enterprise.config.serverbeans.Config)3 Server (com.sun.enterprise.config.serverbeans.Server)3 InvalidOperationException (com.sun.enterprise.security.auth.realm.InvalidOperationException)3 Enumeration (java.util.Enumeration)3 File (java.io.File)2 LoginException (javax.security.auth.login.LoginException)2 GSSUPName (com.sun.enterprise.common.iiop.security.GSSUPName)1 DigestAlgorithmParameter (com.sun.enterprise.security.auth.digest.api.DigestAlgorithmParameter)1 LoginException (com.sun.enterprise.security.auth.login.common.LoginException)1 CertificateRealm (com.sun.enterprise.security.auth.realm.certificate.CertificateRealm)1 DigestRealm (com.sun.enterprise.security.ee.auth.realm.DigestRealm)1