Search in sources :

Example 6 with Realm

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

the class RealmsImpl method getRealm.

private Realm getRealm(String realmName) {
    loadRealms();
    Realm realm = getRealmsManager().getFromLoadedRealms(realmName);
    if (realm == null) {
        throw new IllegalArgumentException("No such realm: " + realmName);
    }
    return realm;
}
Also used : AuthRealm(com.sun.enterprise.config.serverbeans.AuthRealm) Realm(com.sun.enterprise.security.auth.realm.Realm)

Example 7 with Realm

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

the class RealmsImpl method updateUser.

public void updateUser(String realmName, String existingUser, String newUser, String password, String[] groupList) {
    checkSupportsUserManagement(realmName);
    try {
        Realm realm = getRealm(realmName);
        realm.updateUser(existingUser, newUser, password.toCharArray(), groupList);
        realm.persist();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : AuthRealm(com.sun.enterprise.config.serverbeans.AuthRealm) Realm(com.sun.enterprise.security.auth.realm.Realm)

Example 8 with Realm

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

the class SecurityUtil method addUser.

public void addUser(String realmName, String user, String password, String[] groupList) {
    checkSupportsUserManagement(realmName);
    try {
        Realm realm = getRealm(realmName);
        realm.addUser(user, password.toCharArray(), groupList);
        realm.persist();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Realm(com.sun.enterprise.security.auth.realm.Realm) AuthRealm(com.sun.enterprise.config.serverbeans.AuthRealm)

Example 9 with Realm

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

the class SupportsUserManagementCommand method supportsUserManagement.

private boolean supportsUserManagement(String realmName) throws BadRealmException, NoSuchRealmException {
    Realm realm = realmsManager.getFromLoadedRealms(config.getName(), realmName);
    if (realm != null) {
        return realm.supportsUserManagement();
    }
    List<AuthRealm> authRealmConfigs = config.getSecurityService().getAuthRealm();
    for (AuthRealm authRealm : authRealmConfigs) {
        if (realmName.equals(authRealm.getName())) {
            List<Property> propConfigs = authRealm.getProperty();
            Properties props = new Properties();
            for (Property p : propConfigs) {
                String value = p.getValue();
                props.setProperty(p.getName(), value);
            }
            realm = Realm.instantiate(authRealm.getName(), authRealm.getClassname(), props, config.getName());
            return realm.supportsUserManagement();
        }
    }
    throw new NoSuchRealmException(_localStrings.getLocalString("NO_SUCH_REALM", "No Such Realm: {0}", realmName));
}
Also used : AuthRealm(com.sun.enterprise.config.serverbeans.AuthRealm) NoSuchRealmException(com.sun.enterprise.security.auth.realm.NoSuchRealmException) Properties(java.util.Properties) AuthRealm(com.sun.enterprise.config.serverbeans.AuthRealm) Realm(com.sun.enterprise.security.auth.realm.Realm) Property(org.jvnet.hk2.config.types.Property)

Example 10 with Realm

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

the class SecurityUtil method updateUser.

public void updateUser(String realmName, String existingUser, String newUser, String password, String[] groupList) {
    checkSupportsUserManagement(realmName);
    try {
        Realm realm = getRealm(realmName);
        realm.updateUser(existingUser, newUser, password.toCharArray(), groupList);
        realm.persist();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Realm(com.sun.enterprise.security.auth.realm.Realm) AuthRealm(com.sun.enterprise.config.serverbeans.AuthRealm)

Aggregations

Realm (com.sun.enterprise.security.auth.realm.Realm)15 AuthRealm (com.sun.enterprise.config.serverbeans.AuthRealm)10 NoSuchRealmException (com.sun.enterprise.security.auth.realm.NoSuchRealmException)8 LoginException (com.sun.enterprise.security.auth.login.common.LoginException)5 InvalidOperationException (com.sun.enterprise.security.auth.realm.InvalidOperationException)5 NoSuchUserException (com.sun.enterprise.security.auth.realm.NoSuchUserException)5 CertificateRealm (com.sun.enterprise.security.auth.realm.certificate.CertificateRealm)5 PrivilegedAction (java.security.PrivilegedAction)3 Subject (javax.security.auth.Subject)3 LoginContext (javax.security.auth.login.LoginContext)3 ServerLoginCallbackHandler (com.sun.enterprise.security.auth.login.common.ServerLoginCallbackHandler)2 Enumeration (java.util.Enumeration)2 Properties (java.util.Properties)2 X500Principal (javax.security.auth.x500.X500Principal)2 Group (org.glassfish.security.common.Group)2 Property (org.jvnet.hk2.config.types.Property)2 X500Name (sun.security.x509.X500Name)2 GSSUPName (com.sun.enterprise.common.iiop.security.GSSUPName)1 Config (com.sun.enterprise.config.serverbeans.Config)1 Server (com.sun.enterprise.config.serverbeans.Server)1