KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > transport > http > ServletEndpointContextImpl


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

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