cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Ratcliffe" <a...@mrigitech.com>
Subject RE: Custom authenticator HELP
Date Tue, 21 Dec 2004 11:06:55 GMT
Does your login form action specify your login pipeline 'do-register'?

The login pipeline's auth-login action needs to be invoked so that the
handler's
authentication resource, your custom Authenticator, can be called.

If the login pipeline is being triggered and you're having problems within
your authenticator
you could try setting a breakpoint in its authenticate() method and trace
the problem
through that way.

Cheers
Adam

-----Original Message-----
From: DIV@kreditprombank.com [mailto:DIV@kreditprombank.com]
Sent: Tuesday, 21 December 2004 10:49 p.m.
To: users@cocoon.apache.org
Subject: Custom authenticator HELP


Please, help.

I try to use custom authenticator class in my application. But it seems
that authentication always fails.
Or don't even try to authenticate me. Because I always return to the login
page. Where is a problem.

Here is java class code:

package kpb.authentication;
 import [
....
]

public class MyAuthenticator
    extends AbstractLogEnabled
    implements Contextualizable, Authenticator, Serviceable, ThreadSafe {

    protected Context context;
    protected ServiceManager manager;

    public void contextualize(Context context) throws ContextException {
        this.context = context;
    }

    public void service(ServiceManager manager) throws ServiceException {
        this.manager = manager;
    }

    public AuthenticationResult authenticate(HandlerConfiguration
configuration, SourceParameters parameters)
    throws ProcessingException {
        if(this.getLogger().isDebugEnabled()) {
            this.getLogger().debug("Starting authentication using handler
" + configuration.getName());
        }
        AuthenticationResult result = null;

        if(parameters.getParameter("username") != null) {
            DOMParser parser = null;
            try {
                parser = (DOMParser)this.manager.lookup(DOMParser.ROLE);
                final Document doc = parser.createDocument();
                final Element root = doc.createElement("authentication");
                doc.appendChild(root);
                final Element id = doc.createElement("ID");
 id.appendChild(doc.createTextNode(parameters.getParameter("username")));
                root.appendChild(id);
                result = new AuthenticationResult(true,doc);
            } catch (SAXException se) {
                throw new ProcessingException("Can't create document",
se);
            } catch (ServiceException se) {
                throw new ProcessingException("Can't lookup parser", se);
            } finally {
                this.manager.release(parser);
            }
        }
        if(this.getLogger().isDebugEnabled()) {
            this.getLogger().debug("End authenticator " + result);
        }

        return result;
    }

    public void logout(UserHandler handler) {
        if (this.getLogger().isDebugEnabled() ) {
            this.getLogger().debug("Logout using handler " +
handler.getHandlerName());
        }
    }
}

This class declared in sitemap as follows:
  <map:pipelines>
    <map:component-configurations>
      <authentication-manager>
        <handlers>
          <handler name="shandler">
            <redirect-to uri="login-page.xml"/>
            <authentication
authenticator="kpb.authentication.MyAuthenticator"/>
          </handler>
        </handlers>
      </authentication-manager>
    </map:component-configurations>

And I have folowing pipeline:

    <map:pipeline>

     <map:match pattern="">
       <map:redirect-to uri="login-page.xml"/>
     </map:match>

     <map:match pattern="login-page.xml">

       <map:act type="auth-loggedIn">
         <map:parameter name="handler" value="shandler"/>
         <map:redirect-to uri="application-view.xml"/>
       </map:act>
       <map:select type="request-method">
         <map:when test="GET">
           <map:act type="init-login-form">
             <map:parameter name="form-definition"
value="forms/definitions/login.xml"/>
             <map:parameter name="attribute-name" value="login-form"/>
           </map:act>
         </map:when>
         <map:when test="POST">
           <map:act type="handle-form-submit">
             <map:parameter name="form-definition"
value="forms/definitions/login.xml"/>
             <map:parameter name="attribute-name" value="login-form"/>
             <map:parameter name="formhandler"
value="kpb.forms.FormsHandler"/>
             <map:redirect-to uri="do-register"/>
             <map:serialize/>
           </map:act>
         </map:when>
         <map:otherwise/>
       </map:select>
       <map:generate src="forms/templates/login.xml"/>
       <map:transform type="session"/>
       <map:transform type="forms">
         <map:parameter name="attribute-name" value="login"/>
       </map:transform>
       <map:transform src="stylesheets/forms/forms-styling.xsl"/>
       <map:transform type="encodeURL"/>
       <map:serialize/>
     </map:match>

     <map:match pattern="do-register">
       <map:act type="auth-login">
         <map:parameter name="handler" value="shandler"/>
         <map:parameter name="parameter_username"
value="{request-param:username}"/>
         <map:redirect-to uri="application-view.xml"/>
       </map:act>
       <map:redirect-to uri="login-page.xml"/>
     </map:match>
     .......................
   </map:pipeline>
 </map:pipelines>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message