KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > server > auth > passthru > PassthruServerDetails


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.filesys.server.auth.passthru;
18
19 import java.net.*;
20 import java.util.*;
21
22 /**
23  * <p>Contains the details of a server used for passthru authentication, the current status of the server
24  * and count of authentications done via this server.
25  *
26  * @author GKSpencer
27  */

28 public class PassthruServerDetails
29 {
30     // Server details
31

32     private String JavaDoc m_name;
33     private String JavaDoc m_domain;
34     private InetAddress m_address;
35     
36     // Server status
37

38     private boolean m_online;
39     
40     // Authentication statistics
41

42     private int m_authCount;
43     private long m_lastAuthTime;
44     
45     /**
46      * Class constructor
47      *
48      * @param name String
49      * @param domain String
50      * @param addr InetAddress
51      * @param online boolean
52      */

53     PassthruServerDetails(String JavaDoc name, String JavaDoc domain, InetAddress addr, boolean online)
54     {
55         m_name = name;
56         m_domain = domain;
57         m_address = addr;
58         m_online = online;
59     }
60     
61     /**
62      * Return the server name
63      *
64      * @return String
65      */

66     public final String JavaDoc getName()
67     {
68         return m_name;
69     }
70     
71     /**
72      * Return the domain name
73      *
74      * @return String
75      */

76     public final String JavaDoc getDomain()
77     {
78         return m_domain;
79     }
80     
81     /**
82      * Return the server address
83      *
84      * @return InetAddress
85      */

86     public final InetAddress getAddress()
87     {
88         return m_address;
89     }
90     
91     /**
92      * Return the online status of the server
93      *
94      * @return boolean
95      */

96     public final boolean isOnline()
97     {
98         return m_online;
99     }
100     
101     /**
102      * Return the authentication count for the server
103      *
104      * @return int
105      */

106     public final int getAuthenticationCount()
107     {
108         return m_authCount;
109     }
110     
111     /**
112      * Return the date/time of the last authentication by this server
113      *
114      * @return long
115      */

116     public final long getAuthenticationDateTime()
117     {
118         return m_lastAuthTime;
119     }
120     
121     /**
122      * Set the online status for the server
123      *
124      * @param online boolean
125      */

126     public final void setOnline(boolean online)
127     {
128         m_online = online;
129     }
130     
131     /**
132      * Update the authentication count and date/time
133      */

134     public synchronized final void incrementAuthenticationCount()
135     {
136         m_authCount++;
137         m_lastAuthTime = System.currentTimeMillis();
138     }
139     
140     /**
141      * Return the hash code for this object
142      *
143      * @return int
144      */

145     public int hashCode()
146     {
147         return m_address.hashCode();
148     }
149     
150     /**
151      * Return the passthru server details as a string
152      *
153      * @return String
154      */

155     public String JavaDoc toString()
156     {
157         StringBuilder JavaDoc str = new StringBuilder JavaDoc();
158         
159         str.append("[");
160         if ( getDomain() != null)
161         {
162             str.append(getDomain());
163             str.append("\\");
164         }
165         str.append(getName());
166         
167         str.append(":");
168         str.append(getAddress().getHostAddress());
169         
170         str.append(isOnline() ? ":Online" : ":Offline");
171         
172         str.append(":");
173         str.append(getAuthenticationCount());
174         str.append(",");
175         str.append(getAuthenticationDateTime() != 0L ? new Date(getAuthenticationDateTime()) : "0");
176         str.append("]");
177         
178         return str.toString();
179     }
180 }
181
Popular Tags