KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tdsecurities > itracker > security > LdapDistinguishedName


1 package com.tdsecurities.itracker.security;
2
3 import javax.naming.NamingException JavaDoc;
4 import javax.naming.directory.Attribute JavaDoc;
5 import javax.naming.directory.Attributes JavaDoc;
6
7 import org.apache.log4j.Logger;
8
9 public class LdapDistinguishedName
10 {
11     protected Logger log = Logger.getLogger(LdapDistinguishedName.class);
12     private Attributes JavaDoc attributes = null;
13     private String JavaDoc commonName = null;
14     private String JavaDoc userName = null;
15     private String JavaDoc firstName = null;
16     private String JavaDoc lastName = null;
17     private String JavaDoc email = null;
18
19     public LdapDistinguishedName(Attributes JavaDoc _attributes)
20         throws NamingException JavaDoc
21     {
22         attributes = _attributes;
23         commonName = getAttribute("distinguishedName");
24         firstName = getAttribute("givenName");
25         lastName = getAttribute("sn");
26         email = getAttribute("mail");
27     }
28     
29     protected String JavaDoc getAttribute(String JavaDoc key) throws NamingException JavaDoc
30     {
31         String JavaDoc value = "";
32         Attribute JavaDoc attr = attributes.get(key);
33         if( attr != null)
34         {
35             Object JavaDoc o = attr.get(0);
36             if( o != null)
37             {
38                 value = o.toString();
39             }
40         }
41         return value;
42     }
43
44     /**
45      * Method getFirstName.
46      * @return String
47      */

48     public String JavaDoc getFirstName()
49     {
50         return firstName;
51     }
52     
53     /**
54      * Method getLastName.
55      * @return String
56      */

57     public String JavaDoc getLastName()
58     {
59         return lastName;
60     }
61     
62     /**
63      * Method getCommonName.
64      * @return String
65      */

66     public String JavaDoc getCommonName()
67     {
68         return commonName;
69     }
70
71     /**
72      * Method getUserName.
73      * @return String
74      */

75     public String JavaDoc getUserName()
76     {
77         return userName;
78     }
79
80     public void setEmail(String JavaDoc email)
81     {
82         this.email = email;
83     }
84
85     public String JavaDoc getEmail()
86     {
87         return email;
88     }
89 }
90
Popular Tags