KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > security > implementation > basic > NameContext


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10
11 package org.mmbase.security.implementation.basic;
12
13 import org.mmbase.security.Rank;
14 import org.mmbase.security.BasicUser;
15 import org.mmbase.security.SecurityException;
16
17 /**
18  * A UserContext implementation based only on user name, which serves as the identifier for the
19  * user.
20  *
21  * @author Eduard Witteveen
22  * @version $Id: NameContext.java,v 1.6 2005/03/01 14:08:33 michiel Exp $
23  */

24 public class NameContext extends BasicUser {
25
26     private String JavaDoc identifier = null;
27     private Rank rank = null;
28
29     public NameContext(Rank rank, String JavaDoc authenticationType) {
30         super(authenticationType);
31         this.rank = rank;
32     }
33
34     public String JavaDoc getIdentifier() {
35         if(identifier == null) {
36             throw new SecurityException JavaDoc("No user name was set by the security implementation. This is required.");
37         }
38         return identifier;
39     }
40
41     public Rank getRank() {
42         if(rank == null) {
43             throw new SecurityException JavaDoc("No rank was provider by the security implementation. This is required.");
44         }
45         return rank;
46     }
47
48     /**
49      * @since MMBase-1.8
50      */

51     void setRank(Rank r) {
52         rank = r;
53     }
54
55     void setIdentifier(String JavaDoc ident) {
56         this.identifier = ident;
57     }
58 }
59
Popular Tags