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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]