1 26 27 package org.objectweb.jonas.security.jacc; 28 29 import javax.ejb.EnterpriseBean ; 30 import javax.security.auth.Subject ; 31 import javax.servlet.http.HttpServletRequest ; 32 33 import org.objectweb.jonas.security.auth.JPrincipal; 34 35 import org.objectweb.security.context.SecurityContext; 36 import org.objectweb.security.context.SecurityCurrent; 37 38 44 public class JPolicyContextHandlerData { 45 46 50 private HttpServletRequest httpServletRequest = null; 51 52 56 private Object [] ejbArguments = null; 57 58 62 private EnterpriseBean processingBean = null; 63 64 67 public JPolicyContextHandlerData() { 68 super(); 69 } 70 71 74 public HttpServletRequest getHttpServletRequest() { 75 return httpServletRequest; 76 } 77 78 81 public void setHttpServletRequest(HttpServletRequest httpServletRequest) { 82 this.httpServletRequest = httpServletRequest; 83 } 84 85 88 public Object [] getEjbArguments() { 89 return ejbArguments; 90 } 91 92 96 public void setEjbArguments(Object [] ejbArguments) { 97 this.ejbArguments = ejbArguments; 98 } 99 100 104 public Subject getContainerSubject() { 105 Subject subject = null; 106 107 SecurityCurrent current = SecurityCurrent.getCurrent(); 108 if (current != null) { 109 SecurityContext ctx = current.getSecurityContext(); 110 if (ctx != null) { 111 subject = new Subject (); 112 String runAsRole = ctx.peekRunAsRole(); 113 if (runAsRole != null) { 114 subject.getPrincipals().add(new JPrincipal(runAsRole)); 115 } else { 116 subject.getPrincipals().add(ctx.getCallerPrincipal(false)); 117 } 118 return subject; 119 } 120 } 121 return subject; 122 } 123 124 127 public EnterpriseBean getProcessingBean() { 128 return processingBean; 129 } 130 131 134 public void setProcessingBean(EnterpriseBean processingBean) { 135 this.processingBean = processingBean; 136 } 137 } | Popular Tags |