1 55 package org.jboss.axis.transport.http; 56 57 import javax.servlet.ServletContext ; 58 import javax.servlet.http.HttpServlet ; 59 import javax.servlet.http.HttpServletRequest ; 60 import javax.servlet.http.HttpSession ; 61 import javax.xml.rpc.handler.MessageContext ; 62 import javax.xml.rpc.server.ServletEndpointContext ; 63 import java.security.Principal ; 64 65 public class ServletEndpointContextImpl implements ServletEndpointContext 66 { 67 68 public HttpSession getHttpSession() 69 { 70 HttpServletRequest srvreq = (HttpServletRequest ) 71 getMessageContext().getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); 72 return (srvreq == null) ? null : srvreq.getSession(); 73 } 74 75 public MessageContext getMessageContext() 76 { 77 return org.jboss.axis.MessageContext.getCurrentContext(); 78 } 79 80 public ServletContext getServletContext() 81 { 82 HttpServlet srv = (HttpServlet ) 83 getMessageContext().getProperty(HTTPConstants.MC_HTTP_SERVLET); 84 return (srv == null) ? null : srv.getServletContext(); 85 } 86 87 97 public boolean isUserInRole(String role) 98 { 99 HttpServletRequest srvreq = (HttpServletRequest ) 100 getMessageContext().getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); 101 102 return (srvreq == null) ? false : srvreq.isUserInRole(role); 103 } 104 105 public Principal getUserPrincipal() 106 { 107 HttpServletRequest srvreq = (HttpServletRequest ) 108 getMessageContext().getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); 109 110 return (srvreq == null) ? null : srvreq.getUserPrincipal(); 111 } 112 } 113 | Popular Tags |