use of org.jboss.security.SimpleGroup in project wildfly by wildfly.
the class ExternalLoginModule method getRoleSets.
@Override
protected Group[] getRoleSets() throws LoginException {
Group roles = new SimpleGroup("Roles");
Group[] groups = { roles };
//group mapping would go here
if (getIdentity().getName().equals("anil")) {
roles.addMember(new SimplePrincipal("gooduser"));
}
roles.addMember(getIdentity());
return groups;
}
use of org.jboss.security.SimpleGroup in project adempiere by adempiere.
the class AdempiereLoginModule method commit.
/**
* commit/complete the authentication project, add identity and roles to subject.
*/
public boolean commit() throws LoginException {
//note that jboss require all user role to be put under the group Roles
if (roles == null || roles.length == 0) {
//not authenticated or authentication failed
subject.getPrincipals().add(new SimplePrincipal(unauthenticatedIdentity));
SimpleGroup roleGroup = new SimpleGroup("Roles");
subject.getPrincipals().add(roleGroup);
} else {
subject.getPrincipals().add(new SimplePrincipal(name));
SimpleGroup roleGroup = new SimpleGroup("Roles");
//fixed role use in ejb deployment descriptor
roleGroup.addMember(new SimplePrincipal("adempiereUsers"));
//additional security check
for (int i = 0; i < roles.length; i++) {
roleGroup.addMember(new SimplePrincipal(roles[i].getName()));
}
subject.getPrincipals().add(roleGroup);
}
return true;
}
use of org.jboss.security.SimpleGroup in project wildfly by wildfly.
the class CustomEjbAccessingLoginModule method commit.
public boolean commit() throws LoginException {
Set<Principal> principals = subject.getPrincipals();
Group callerPrincipal = new SimpleGroup("CallerPrincipal");
callerPrincipal.addMember(new SimplePrincipal(username));
principals.add(callerPrincipal);
Group roles = new SimpleGroup("Roles");
if (username.equals("anil")) {
roles.addMember(new SimplePrincipal("gooduser"));
}
if (username.equals("marcus")) {
roles.addMember(new SimplePrincipal("superuser"));
}
principals.add(roles);
return true;
}
use of org.jboss.security.SimpleGroup in project wildfly by wildfly.
the class CustomTestLoginModule method commit.
@Override
public boolean commit() throws LoginException {
Set<Principal> principals = subject.getPrincipals();
Group callerPrincipal = new SimpleGroup("CallerPrincipal");
callerPrincipal.addMember(new SimplePrincipal(username));
principals.add(callerPrincipal);
Group roles = new SimpleGroup("Roles");
if (username.equals("anil")) {
roles.addMember(new SimplePrincipal("gooduser"));
}
if (username.equals("marcus")) {
roles.addMember(new SimplePrincipal("superuser"));
}
principals.add(roles);
return true;
}
use of org.jboss.security.SimpleGroup in project wildfly-swarm by wildfly-swarm.
the class JWTLoginModule method commit.
@Override
public boolean commit() throws LoginException {
subject.getPrincipals().add(jwtPrincipal);
SimpleGroup roles = new SimpleGroup("Roles");
for (String name : jwtPrincipal.getGroups()) {
roles.addMember(new SimplePrincipal(name));
}
subject.getPrincipals().add(roles);
sharedState.put("JsonWebToken", jwtPrincipal);
return super.commit();
}
Aggregations