1 23 24 package com.sun.enterprise.security.authorize; 25 26 import javax.servlet.http.HttpServletRequest ; 27 import javax.security.jacc.PolicyContextHandler ; 28 import javax.xml.rpc.handler.MessageContext ; 29 import javax.xml.rpc.handler.soap.SOAPMessageContext ; 30 31 import com.sun.ejb.Invocation; 32 import com.sun.enterprise.security.PermissionCacheFactory; 33 import com.sun.enterprise.security.SecurityContext; 34 35 42 public class HandlerData { 43 44 private HttpServletRequest httpReq = null; 45 private Invocation inv = null; 46 47 private HandlerData(){} 48 49 50 public static HandlerData getInstance(){ 51 return new HandlerData(); 52 } 53 54 public void setHttpServletRequest(HttpServletRequest httpReq) { 55 this.httpReq = httpReq; 56 } 57 58 public void setInvocation(Invocation inv) { 59 this.inv = inv; 60 } 61 62 public Object get(String key){ 63 if (PolicyContextHandlerImpl.HTTP_SERVLET_REQUEST.equalsIgnoreCase(key)){ 64 return httpReq; 65 } else if (PolicyContextHandlerImpl.SUBJECT.equalsIgnoreCase(key)){ 66 return SecurityContext.getCurrent().getSubject(); 67 } else if (PolicyContextHandlerImpl.REUSE.equalsIgnoreCase(key)) { 68 PermissionCacheFactory.resetCaches(); 69 return new Integer (0); 70 } 71 72 if (inv == null) { 73 return null; 74 } 75 76 if (PolicyContextHandlerImpl.SOAP_MESSAGE.equalsIgnoreCase(key)){ 77 MessageContext msgContext = inv.messageContext; 78 if(msgContext == null) 79 return null; 80 if(msgContext instanceof SOAPMessageContext ){ 81 SOAPMessageContext smc = (SOAPMessageContext ) msgContext; 82 return smc.getMessage(); 83 } 84 return null; 85 } else if (PolicyContextHandlerImpl.ENTERPRISE_BEAN.equalsIgnoreCase(key)){ 86 return inv.getJaccEjb(); 87 } else if (PolicyContextHandlerImpl.EJB_ARGUMENTS.equalsIgnoreCase(key)){ 88 if (inv.isWebService) { 89 return null; 90 } else { 91 return (inv.methodParams != null) ? 92 inv.methodParams : new Object [0]; 93 } 94 } 95 return null; 96 } 97 } 98 | Popular Tags |