1 16 package org.apache.axis.transport.http; 17 18 import javax.servlet.ServletContext ; 19 import javax.servlet.http.HttpServlet ; 20 import javax.servlet.http.HttpServletRequest ; 21 import javax.servlet.http.HttpSession ; 22 import javax.xml.rpc.handler.MessageContext ; 23 import javax.xml.rpc.server.ServletEndpointContext ; 24 import java.security.Principal ; 25 26 public class ServletEndpointContextImpl implements ServletEndpointContext { 27 28 public HttpSession getHttpSession() { 29 HttpServletRequest srvreq = (HttpServletRequest ) 30 getMessageContext().getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); 31 return (srvreq == null) ? null : srvreq.getSession(); 32 } 33 34 public MessageContext getMessageContext() { 35 return org.apache.axis.MessageContext.getCurrentContext(); 36 } 37 38 public ServletContext getServletContext() { 39 HttpServlet srv = (HttpServlet ) 40 getMessageContext().getProperty(HTTPConstants.MC_HTTP_SERVLET); 41 return (srv == null) ? null : srv.getServletContext(); 42 } 43 44 public boolean isUserInRole(String role) { 45 HttpServletRequest srvreq = (HttpServletRequest ) 46 getMessageContext().getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); 47 return (srvreq == null) ? false : srvreq.isUserInRole(role); 48 } 49 50 public Principal getUserPrincipal() { 51 HttpServletRequest srvreq = (HttpServletRequest ) 52 getMessageContext().getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); 53 54 return (srvreq == null) ? null : srvreq.getUserPrincipal(); 55 } 56 } 57 | Popular Tags |