KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > authenticate > CredentialsToken


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/authenticate/CredentialsToken.java,v 1.11 2004/07/28 09:38:45 ib Exp $
3  * $Revision: 1.11 $
4  * $Date: 2004/07/28 09:38:45 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.authenticate;
25
26 import java.security.Principal JavaDoc;
27
28 /**
29  * Credentials token class.
30  *
31  */

32 public final class CredentialsToken {
33     
34     
35     // ------------------------------------------------------------ Constructor
36

37     
38     /**
39      * Constructor.
40      *
41      * @param credentials Credentials stored in this token
42      */

43     public CredentialsToken(String JavaDoc credentials) {
44         this.credentials = credentials;
45         this.trusted = false;
46     }
47     
48     
49     /**
50      * Constructor.
51      *
52      * @param principal Principal stored in this token
53      */

54     public CredentialsToken(Principal JavaDoc principal) {
55         this.credentials = principal.getName();
56         this.trusted = true;
57         this.principal = principal;
58     }
59     
60     
61     // ----------------------------------------------------- Instance Variables
62

63     /**
64      * principal instance.
65      */

66     private Principal JavaDoc principal;
67     
68     /**
69      * Credentials, or principal.
70      */

71     private String JavaDoc credentials;
72     
73     
74     /**
75      * Trusted credentials ?
76      */

77     private boolean trusted;
78     
79     
80     // ------------------------------------------------------------- Properties
81

82     
83     /**
84      * Is this credentials token to be trusted ?
85      *
86      * @return boolean
87      */

88     public boolean isTrusted() {
89         return trusted;
90     }
91     
92     
93     /**
94      * Returns the private credentials.
95      *
96      * @return String
97      */

98     public String JavaDoc getPrivateCredentials() {
99         // FIXME ?
100
return credentials;
101     }
102     
103     /**
104      * Returns the current principal
105      *
106      * @return java.security.Principal
107      */

108     public Principal JavaDoc getPrincipal() {
109          return principal;
110     }
111     
112     /**
113      * Returns the public creddentials.
114      *
115      * @return String
116      */

117     public String JavaDoc getPublicCredentials() {
118         return credentials;
119     }
120     
121     
122 }
123
Popular Tags