KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > security > plugins > NoAccessSecurityManager


1 /*
2  * JBoss, Home of Professional Open Source
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.security.plugins;
8
9 import java.io.Serializable JavaDoc;
10 import java.util.HashSet JavaDoc;
11 import java.util.Set JavaDoc;
12 import java.security.Principal JavaDoc;
13 import javax.security.auth.Subject JavaDoc;
14
15 import org.jboss.security.RealmMapping;
16 import org.jboss.security.SubjectSecurityManager;
17 import org.jboss.security.NobodyPrincipal;
18
19
20 /** An implementation of SubjectSecurityManager, RealmMapping does not allow
21  any authentication and every check for a role fails.
22
23 @see #isValid(java.security.Principal, Object, Subject)
24 @see #getPrincipal(java.security.Principal)
25 @see #doesUserHaveRole(java.security.Principal, java.util.Set)
26
27 @author Scott.Stark@jboss.org
28 @version $Revision: 1.1.4.2 $
29 */

30 public class NoAccessSecurityManager
31     implements SubjectSecurityManager, RealmMapping, Serializable JavaDoc
32 {
33     static final long serialVersionUID = -5922913661708382384L;
34     private String JavaDoc securityDomain;
35
36     /** Creates a default JaasSecurityManager for with the
37         given securityDomain name.
38     */

39     public NoAccessSecurityManager(String JavaDoc securityDomain)
40     {
41         this.securityDomain = securityDomain;
42     }
43
44     /** Get the name of the security domain associated with this security mgr.
45         @return Name of the security manager security domain.
46      */

47     public String JavaDoc getSecurityDomain()
48     {
49         return securityDomain;
50     }
51     /** Get the currently authenticated Subject.
52         @return Always returns null.
53      */

54     public Subject JavaDoc getActiveSubject()
55     {
56         return null;
57     }
58
59     /** Validate that the given credential is correct for principal.
60     @return always returns true.
61      */

62     public boolean isValid(Principal JavaDoc principal, Object JavaDoc credential)
63     {
64         return false;
65     }
66     /** Validate that the given credential is correct for principal. This does
67      not populate the activeSubject with any state since no authentication
68      is performed.
69     @return always returns true.
70      */

71     public boolean isValid(Principal JavaDoc principal, Object JavaDoc credential,
72       Subject JavaDoc activeSubject)
73     {
74        return false;
75     }
76
77     /** Always returns the argument principal.
78     @return The argument principal
79      */

80     public Principal JavaDoc getPrincipal(Principal JavaDoc principal)
81     {
82         Principal JavaDoc result = principal;
83         return result;
84     }
85
86     /** Does the current Subject have a role(a Principal) that equates to one
87         of the role names. This method always returns true.
88     @param principal - ignored.
89     @param roleNames - ignored.
90     @return Always returns true.
91     */

92     public boolean doesUserHaveRole(Principal JavaDoc principal, Set JavaDoc roleNames)
93     {
94         boolean hasRole = false;
95         return hasRole;
96     }
97
98     /** Return the set of domain roles the principal has been assigned.
99     @return The Set<Principal> with the NobodyPrincipal as the sole role.
100      */

101     public Set JavaDoc getUserRoles(Principal JavaDoc principal)
102     {
103         HashSet JavaDoc roles = new HashSet JavaDoc();
104         roles.add(NobodyPrincipal.NOBODY_PRINCIPAL);
105         return roles;
106     }
107
108     /** Authenticate principal against credential
109      * @param principal - the user id to authenticate
110      * @param credential - an opaque credential.
111      * @return Always returns true.
112      */

113     private boolean authenticate(Principal JavaDoc principal, Object JavaDoc credential)
114     {
115         boolean authenticated = false;
116         return authenticated;
117     }
118 }
119
Popular Tags