KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > server > auth > ntlm > TargetInfo


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.ntlm;
18
19 /**
20  * Target Information Class
21  *
22  * <p>Contains the target information from an NTLM message.
23  *
24  * @author GKSpencer
25  */

26 public class TargetInfo
27 {
28     // Target type and name
29

30     private int m_type;
31     private String JavaDoc m_name;
32     
33     /**
34      * Class constructor
35      *
36      * @param type int
37      * @param name String
38      */

39     public TargetInfo(int type, String JavaDoc name)
40     {
41         m_type = type;
42         m_name = name;
43     }
44     
45     /**
46      * Return the target type
47      *
48      * @return int
49      */

50     public final int isType()
51     {
52         return m_type;
53     }
54     
55     /**
56      * Return the target name
57      *
58      * @return String
59      */

60     public final String JavaDoc getName()
61     {
62         return m_name;
63     }
64     
65     /**
66      * Return the target information as a string
67      *
68      * @return String
69      */

70     public String JavaDoc toString()
71     {
72         StringBuilder JavaDoc str = new StringBuilder JavaDoc();
73         
74         str.append("[");
75         str.append(getTypeAsString(isType()));
76         str.append(":");
77         str.append(getName());
78         str.append("]");
79         
80         return str.toString();
81     }
82     
83     /**
84      * Return the target type as a string
85      *
86      * @param typ int
87      * @return String
88      */

89     public final static String JavaDoc getTypeAsString(int typ)
90     {
91         String JavaDoc typStr = null;
92         
93         switch ( typ)
94         {
95         case NTLM.TargetServer:
96             typStr = "Server";
97             break;
98         case NTLM.TargetDomain:
99             typStr = "Domain";
100             break;
101         case NTLM.TargetFullDNS:
102             typStr = "DNS";
103             break;
104         case NTLM.TargetDNSDomain:
105             typStr = "DNS Domain";
106             break;
107         default:
108             typStr = "Unknown 0x" + Integer.toHexString(typ);
109             break;
110         }
111         
112         return typStr;
113     }
114 }
115
Popular Tags