1 package com.tdsecurities.itracker.security; 2 3 import javax.naming.NamingException ; 4 import javax.naming.directory.Attribute ; 5 import javax.naming.directory.Attributes ; 6 7 import org.apache.log4j.Logger; 8 9 public class LdapDistinguishedName 10 { 11 protected Logger log = Logger.getLogger(LdapDistinguishedName.class); 12 private Attributes attributes = null; 13 private String commonName = null; 14 private String userName = null; 15 private String firstName = null; 16 private String lastName = null; 17 private String email = null; 18 19 public LdapDistinguishedName(Attributes _attributes) 20 throws NamingException 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 getAttribute(String key) throws NamingException 30 { 31 String value = ""; 32 Attribute attr = attributes.get(key); 33 if( attr != null) 34 { 35 Object o = attr.get(0); 36 if( o != null) 37 { 38 value = o.toString(); 39 } 40 } 41 return value; 42 } 43 44 48 public String getFirstName() 49 { 50 return firstName; 51 } 52 53 57 public String getLastName() 58 { 59 return lastName; 60 } 61 62 66 public String getCommonName() 67 { 68 return commonName; 69 } 70 71 75 public String getUserName() 76 { 77 return userName; 78 } 79 80 public void setEmail(String email) 81 { 82 this.email = email; 83 } 84 85 public String getEmail() 86 { 87 return email; 88 } 89 } 90 | Popular Tags |