1 25 26 package org.objectweb.easybeans.container.info.security; 27 28 import java.security.Principal ; 29 import java.security.acl.Group ; 30 import java.util.ArrayList ; 31 import java.util.List ; 32 33 import javax.security.auth.Subject ; 34 35 import org.objectweb.easybeans.api.bean.info.IMethodSecurityInfo; 36 import org.objectweb.easybeans.api.bean.info.ISecurityInfo; 37 import org.objectweb.easybeans.security.struct.JGroup; 38 import org.objectweb.easybeans.security.struct.JPrincipal; 39 40 44 public class SecurityInfo implements ISecurityInfo { 45 46 49 private List <String > declaredRoles = null; 50 51 54 private List <IMethodSecurityInfo> methodSecurityInfos = null; 55 56 59 private String runAsRole = null; 60 61 64 private Subject runAsSubject = null; 65 66 69 public SecurityInfo() { 70 this.methodSecurityInfos = new ArrayList <IMethodSecurityInfo>(); 71 } 72 73 77 public void addMethodSecurityInfo(final IMethodSecurityInfo methodSecurityInfo) { 78 methodSecurityInfos.add(methodSecurityInfo); 79 } 80 81 84 public List <IMethodSecurityInfo> getMethodSecurityInfos() { 85 return methodSecurityInfos; 86 } 87 88 92 public void setRunAsRole(final String runAsRole) { 93 this.runAsRole = runAsRole; 94 this.runAsSubject = new Subject (); 95 Principal principalName = new JPrincipal(runAsRole); 97 runAsSubject.getPrincipals().add(principalName); 98 99 Group roles = new JGroup("roles"); 101 roles.addMember(new JPrincipal(runAsRole)); 102 runAsSubject.getPrincipals().add(roles); 103 104 } 105 106 110 public String getRunAsRole() { 111 return runAsRole; 112 } 113 114 118 public Subject getRunAsSubject() { 119 return runAsSubject; 120 } 121 122 126 public void addDeclaredRole(final String roleName) { 127 declaredRoles.add(roleName); 128 } 129 130 133 public List <String > getDeclaredRoles() { 134 return declaredRoles; 135 } 136 137 141 public void setDeclaredRole(final List <String > declaredRoles) { 142 this.declaredRoles = declaredRoles; 143 } 144 } 145 | Popular Tags |