1 package net.simya.ldap.beans; 2 3 import javax.naming.*; 4 import javax.naming.directory.*; 5 6 8 13 public class LdapAuthenticateBean 14 { 15 16 private DirContext ctx = null; 17 18 private String authType="simple", 19 DN, 20 password; 21 22 public void setContext (DirContext ctx) 23 { 24 this.ctx = ctx; 25 } 26 27 public void setAuthType ( String authType) 28 { 29 this.authType = authType; 30 } 31 32 public void setDN (String dn) 33 { 34 this.DN = dn; 35 } 36 37 public void setPassword ( String password) 38 { 39 this.password = password; 40 } 41 42 public void authenticate () 43 throws NamingException 44 { 45 46 ctx.addToEnvironment(Context.SECURITY_AUTHENTICATION, authType); 48 49 ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, DN); 51 ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, password); 52 53 String tempurl = (String ) (ctx.getEnvironment()).get(ctx.PROVIDER_URL) ; 56 ctx.lookup(tempurl); 57 58 } 59 60 61 } | Popular Tags |