KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > security > authentication > ntlm > NTLMPassthruToken


1 /*
2  * Copyright (C) 2006 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.security.authentication.ntlm;
18
19 /**
20  * <p>Used to provide passthru authentication to a remote Windows server using multiple stages that
21  * allows authentication details to be passed between a client and the remote authenticating server without
22  * the password being known by the authentication provider.
23  *
24  * @author GKSpencer
25  */

26 public class NTLMPassthruToken extends NTLMLocalToken
27 {
28     private static final long serialVersionUID = -4635444888514735368L;
29
30     // Challenge for this session
31

32     private NTLMChallenge m_challenge;
33     
34     // User name, hashed password and algorithm type
35

36     private String JavaDoc m_username;
37     private byte[] m_hashedPassword;
38     private int m_hashType;
39
40     // Time that the authentication session will expire
41

42     private long m_authExpiresAt;
43     
44     /**
45      * Class constructor
46      */

47     public NTLMPassthruToken()
48     {
49         // We do not know the username yet, and will not know the password
50

51         super("", "");
52     }
53     
54     /**
55      * Return the challenge
56      *
57      * @return NTLMChallenge
58      */

59     public final NTLMChallenge getChallenge()
60     {
61         return m_challenge;
62     }
63
64     /**
65      * Return the user account
66      *
67      * @return Object
68      */

69     public final Object JavaDoc getPrincipal()
70     {
71         return m_username;
72     }
73     
74     /**
75      * Return the hashed password
76      *
77      * @return byte[]
78      */

79     public final byte[] getHashedPassword()
80     {
81         return m_hashedPassword;
82     }
83     
84     /**
85      * Return the hashed password type
86      *
87      * @return int
88      */

89     public final int getPasswordType()
90     {
91         return m_hashType;
92     }
93
94     /**
95      * Return the authentication expiry time, this will be zero if the authentication session has not yet
96      * been opened to the server
97      *
98      * @return long
99      */

100     public final long getAuthenticationExpireTime()
101     {
102         return m_authExpiresAt;
103     }
104     
105     /**
106      * Set the hashed password and type
107      *
108      * @param hashedPassword byte[]
109      * @param hashType int
110      */

111     public final void setUserAndPassword(String JavaDoc username, byte[] hashedPassword, int hashType)
112     {
113         m_username = username.toLowerCase();
114         m_hashedPassword = hashedPassword;
115         m_hashType = hashType;
116     }
117     
118     /**
119      * Set the challenge for this token
120      *
121      * @param challenge NTLMChallenge
122      */

123     protected final void setChallenge(NTLMChallenge challenge)
124     {
125         m_challenge = challenge;
126     }
127     
128     /**
129      * Set the authentication expire time, this indicates that an authentication session is associated with this
130      * token and the session will be closed if the authentication is not completed by this time.
131      *
132      * @param startTime long
133      */

134     protected final void setAuthenticationExpireTime(long expireTime)
135     {
136         m_authExpiresAt = expireTime;
137     }
138     
139     /**
140      * Check for object equality
141      *
142      * @param obj Object
143      * @return boolean
144      */

145     public boolean equals(Object JavaDoc obj)
146     {
147         // Only match on the same object
148

149         return this == obj;
150     }
151 }
152
Popular Tags