KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > simya > ldap > taglib > Authenticate


1 package net.simya.ldap.taglib;
2
3 import javax.servlet.jsp.tagext.*;
4 import javax.servlet.jsp.*;
5 import javax.naming.NamingException JavaDoc;
6 import net.simya.ldap.beans.*;
7
8 public class Authenticate
9        extends TagSupport
10 {
11     private String JavaDoc dn = null;
12     private String JavaDoc password = null;
13     private String JavaDoc 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 JavaDoc 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 JavaDoc getDn() { return this.dn; }
44     public void setDn(String JavaDoc dn) { this.dn = dn; }
45
46     public String JavaDoc getPassword() { return this.password; }
47     public void setPassword(String JavaDoc dn) { this.password = password; }
48
49     public String JavaDoc getAuthType() { return this.authType; }
50     public void setAuthType(String JavaDoc dn) { this.authType = authType; }
51
52 }
Popular Tags