KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > security > servlet > ServletAuthenticatedUser


1 /*
2  * Copyright 2001-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
17 package org.apache.axis.security.servlet;
18
19 import org.apache.axis.security.AuthenticatedUser;
20
21 import javax.servlet.http.HttpServletRequest JavaDoc;
22 import java.security.Principal JavaDoc;
23
24 /**
25  * ServletAuthenticatedUser is a sligtly odd implementation of
26  * AuthenticatedUser. It serves to store an HttpServletRequest,
27  * so that request can be used by the ServletSecurityProvider to
28  * check roles.
29  *
30  * @author Glen Daniels (gdaniels@apache.org)
31  */

32 public class ServletAuthenticatedUser implements AuthenticatedUser {
33     private String JavaDoc name;
34     private HttpServletRequest JavaDoc req;
35
36     public ServletAuthenticatedUser(HttpServletRequest JavaDoc req)
37     {
38         this.req = req;
39         Principal JavaDoc principal = req.getUserPrincipal();
40         this.name = (principal == null) ? null : principal.getName();
41     }
42
43     /** Return a string representation of the user's name.
44      *
45      * @return the user's name as a String.
46      */

47     public String JavaDoc getName() {
48         return name;
49     }
50
51     public HttpServletRequest JavaDoc getRequest()
52     {
53         return req;
54     }
55 }
56
Popular Tags