1 package org.jbpm.security.authenticator; 2 3 import java.security.AccessController ; 4 import java.security.Principal ; 5 import java.util.Set ; 6 7 import javax.security.auth.Subject ; 8 9 import org.jbpm.JbpmConfiguration; 10 import org.jbpm.instantiation.ClassLoaderUtil; 11 12 20 public class SubjectAuthenticator implements Authenticator { 21 22 private static final String principalClassName = JbpmConfiguration.getString("jbpm.authenticator.principal.classname"); 23 private static Class principalClass = ClassLoaderUtil.loadClass(principalClassName); 24 25 public String getAuthenticatedActorId() { 26 String authenticatedActorId = null; 27 Subject subject = Subject.getSubject(AccessController.getContext()); 28 Set principals = subject.getPrincipals(principalClass); 29 if ( (principals!=null) 30 && (!principals.isEmpty()) 31 ) { 32 Principal principal = (Principal ) principals.iterator().next(); 33 authenticatedActorId = principal.getName(); 34 } 35 return authenticatedActorId; 36 } 37 } 38 | Popular Tags |