KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > security > AppservRealm


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.appserv.security;
25
26 import java.util.*;
27
28 import com.sun.enterprise.security.auth.realm.*;
29
30 import java.util.logging.Logger JavaDoc;
31 import java.util.logging.Level JavaDoc;
32 import com.sun.logging.LogDomains;
33 import com.sun.enterprise.util.i18n.StringManager;
34
35
36 /**
37  * Parent class for iAS Realm classes.
38  *
39  * <P>This class provides default implementation for most of the abstract
40  * methods in com.sun.enterprise.security.auth.realm.Realm. Since most
41  * of these abstract methods are not supported by Realms there is
42  * no need for the subclasses to implement them. The default implementations
43  * provided here generally throw an exception if invoked.
44  *
45  * @author Harpreet Singh
46  */

47 public abstract class AppservRealm extends Realm
48 {
49     public static final String JavaDoc JAAS_CONTEXT_PARAM="jaas-context";
50     
51     protected static Logger JavaDoc _logger =
52         LogDomains.getLogger(LogDomains.SECURITY_LOGGER);
53     protected static StringManager sm =
54         StringManager.getManager("com.sun.enterprise.security.auth.realm");
55
56     
57     /**
58      * Returns an AuthenticationHandler object which can be used to
59      * authenticate within this realm.
60      *
61      * <P>This method return null always, since AuthenticationHandlers
62      * are generally not supported by iAS realms. Subclass can override
63      * if necessary.
64      *
65      * @return An AuthenticationHandler object for this realm (always null)
66      *
67      */

68     public AuthenticationHandler getAuthenticationHandler()
69     {
70         _logger.warning("iasrealm.noauth");
71         return null;
72     }
73
74
75     /**
76      * Returns names of all the users in this particular realm.
77      *
78      * <P>This method always throws a BadRealmException since by default
79      * this operation is not supported. Subclasses which support this
80      * method can override.
81      *
82      * @return enumeration of user names (strings)
83      * @exception com.sun.enterprise.security.auth.realm.BadRealmException if realm data structures are bad
84      *
85      */

86     public Enumeration getUserNames() throws BadRealmException
87     {
88         String JavaDoc msg = sm.getString("iasrealm.notsupported");
89         throw new BadRealmException(msg);
90     }
91
92
93     /**
94      * Returns the information recorded about a particular named user.
95      *
96      * <P>This method always throws a BadRealmException since by default
97      * this operation is not supported. Subclasses which support this
98      * method can override.
99      *
100      * @param name name of the user whose information is desired
101      * @return the user object
102      * @exception com.sun.enterprise.security.auth.realm.NoSuchUserException if the user doesn't exist
103      * @exception com.sun.enterprise.security.auth.realm.BadRealmException if realm data structures are bad
104      *
105      */

106     public User getUser(String JavaDoc name)
107         throws NoSuchUserException, BadRealmException
108     {
109         String JavaDoc msg = sm.getString("iasrealm.notsupported");
110         throw new BadRealmException(msg);
111     }
112
113
114     /**
115      * Returns names of all the groups in this particular realm.
116      *
117      * <P>This method always throws a BadRealmException since by default
118      * this operation is not supported. Subclasses which support this
119      * method can override.
120      *
121      * @return enumeration of group names (strings)
122      * @exception com.sun.enterprise.security.auth.realm.BadRealmException if realm data structures are bad
123      *
124      */

125     public Enumeration getGroupNames()
126         throws BadRealmException
127     {
128         String JavaDoc msg = sm.getString("iasrealm.notsupported");
129         throw new BadRealmException(msg);
130     }
131
132
133     /**
134      * Refreshes the realm data so that new users/groups are visible.
135      *
136      * <P>This method always throws a BadRealmException since by default
137      * this operation is not supported. Subclasses which support this
138      * method can override.
139      *
140      * @exception com.sun.enterprise.security.auth.realm.BadRealmException if realm data structures are bad
141      *
142      */

143     public void refresh() throws BadRealmException
144     {
145         String JavaDoc msg = sm.getString("iasrealm.notsupported");
146         throw new BadRealmException(msg);
147     }
148 }
149
Popular Tags