1 package net.simya.ldap.taglib; 2 3 import javax.servlet.jsp.tagext.*; 4 import javax.servlet.jsp.*; 5 import javax.naming.NamingException ; 6 import net.simya.ldap.beans.*; 7 8 public class Authenticate 9 extends TagSupport 10 { 11 private String dn = null; 12 private String password = null; 13 private String authType = "simple"; 14 15 public int doStartTag() 16 throws JspException 17 { 18 Connect connectTag = (Connect) getParent(); 19 if ( connectTag == null ) 20 throw new JspTagException( "<authenticate> tag should be child node of <connect> tag." ); 21 22 LdapAuthenticateBean authBean = new LdapAuthenticateBean(); 23 authBean.setContext( connectTag.getContext() ); 24 authBean.setDN( dn ); 25 authBean.setPassword(password); 26 authBean.setAuthType(authType); 27 28 try 29 { 30 authBean.authenticate(); 31 } catch ( NamingException ex ) 32 { 33 throw new LdapTaglibException( ex ); 34 } 35 return EVAL_PAGE; 36 } 37 38 public void release() 39 { 40 dn = null; 41 } 42 43 public String getDn() { return this.dn; } 44 public void setDn(String dn) { this.dn = dn; } 45 46 public String getPassword() { return this.password; } 47 public void setPassword(String dn) { this.password = password; } 48 49 public String getAuthType() { return this.authType; } 50 public void setAuthType(String dn) { this.authType = authType; } 51 52 } | Popular Tags |