use of org.glassfish.security.common.PrincipalImpl in project Payara by payara.
the class SubjectUtilTest method createSub.
public static Subject createSub(String username, String[] groups) {
Set<Principal> pset = new HashSet<Principal>();
if (username != null) {
Principal u = new PrincipalImpl(username);
pset.add(u);
}
if (groups != null) {
for (String g : groups) {
if (g != null) {
Principal p = new org.glassfish.security.common.Group(g);
pset.add(p);
}
}
}
Set prvSet = new HashSet();
Set<Object> pubSet = new HashSet<Object>();
Subject sub = new Subject(false, pset, pubSet, prvSet);
return sub;
}
use of org.glassfish.security.common.PrincipalImpl in project Payara by payara.
the class ConnectorStarter method getAccessController.
public JMXAuthenticator getAccessController() {
// needed by the system.
return new JMXAuthenticator() {
/**
* We actually wait for the first authentication request to delegate/
* @param credentials
* @return
*/
public Subject authenticate(Object credentials) {
// lazy init...
// todo : lloyd, if this becomes a performance bottleneck, we should cache
// on first access.
JMXAuthenticator controller = mHabitat.getService(JMXAuthenticator.class);
Subject adminSubject = controller.authenticate(credentials);
if (adminSubject != null) {
// extract the principal name and create a JMXPrincipal and add to the subject PAYARA-1251
Set<PrincipalImpl> principals = adminSubject.getPrincipals(PrincipalImpl.class);
for (PrincipalImpl principal : principals) {
if (!(principal instanceof Group) && !(principal instanceof Role)) {
adminSubject.getPrincipals().add(new JMXPrincipal(principal.getName()));
}
}
}
return adminSubject;
}
};
}
Aggregations