Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 44404 invoked from network); 21 Oct 2004 22:16:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 21 Oct 2004 22:16:41 -0000 Received: (qmail 33347 invoked by uid 500); 21 Oct 2004 22:16:25 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 33254 invoked by uid 500); 21 Oct 2004 22:16:24 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 33160 invoked by uid 99); 21 Oct 2004 22:16:23 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [150.203.2.43] (HELO anu.edu.au) (150.203.2.43) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 21 Oct 2004 15:16:22 -0700 Received: from anumail.anu.edu.au (adelong.anu.edu.au [150.203.2.90]) by anu.edu.au (8.12.11/8.12.11) with ESMTP id i9LMGHKE018338 for ; Fri, 22 Oct 2004 08:16:17 +1000 (EST) Received: from [150.203.59.101] (sts59101.anu.edu.au [150.203.59.101]) by anumail.anu.edu.au (8.12.10/8.12.10) with ESMTP id i9LMGHln007349 for ; Fri, 22 Oct 2004 08:16:17 +1000 (EST) Message-ID: <4178351A.9030208@anu.edu.au> Date: Fri, 22 Oct 2004 08:15:54 +1000 From: Scott Yeadon User-Agent: Mozilla Thunderbird 0.6 (X11/20040502) X-Accept-Language: en-us, en MIME-Version: 1.0 To: users@cocoon.apache.org Subject: Re: Question on Authenticator References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-PMX-Version: 4.7.0.111621, Antispam-Engine: 2.0.0.0, Antispam-Data: 2004.10.21.2 X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_VERSION 0, __SANE_MSGID 0' X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I haven't seen this error before, but here's the code I used (the PipelineAuthenticator class was what I used as an example, from memory) - I used the Cocoon DOMUtil to create the auth response, hope it's of some use : public class SimpleAuthenticator implements Authenticator, Contextualizable { .... .... public AuthenticationResult authenticate(HandlerConfiguration configuration, SourceParameters parameters) throws ProcessingException { ... .... Document doc = DOMUtil.createDocument(); final Element root = doc.createElementNS(null, "authentication"); AuthenticationResult result; if (loggedIn == true) { doc.appendChild(root); Element element = doc.createElementNS(null, "ID"); root.appendChild(element); Text text = doc.createTextNode(userID); element.appendChild(text); element = doc.createElementNS(null, "data"); root.appendChild(element); text = doc.createTextNode("Successful login"); element.appendChild(text); result = new AuthenticationResult(true, doc); } else { doc.appendChild(root); Element element = doc.createElementNS(null, "data"); root.appendChild(element); Text text = doc.createTextNode("Invalid userid password combination"); element.appendChild(text); result = new AuthenticationResult(false, doc); } return result; } ... ... } Jonny Pony wrote: > Hi, > > I want to implemtent my own authentication-class, based on the > Authenticator-class. > I alway get a NullPointerException. > > Here my code so far: > > ... > public class MyAuthenticator implements Authenticator, Serviceable { > > private ServiceManager serviceManager; > > public void service(ServiceManager manager) throws ServiceException { > this.serviceManager = manager; > } > > public AuthenticationResult authenticate( > HandlerConfiguration configuration, SourceParameters parameters) > throws ProcessingException { > > String userID = parameters.getParameter("userid"); > String password = parameters.getParameter("password"); > Connection conn = null; > Statement stmt = null; > ResultSet rs = null; > > try { > > ServiceSelector dbselector = (ServiceSelector) this.serviceManager > .lookup(DataSourceComponent.ROLE + "Selector"); > DataSourceComponent ds = (DataSourceComponent) dbselector > .select("mysql-pool"); > Connection con = ds.getConnection(); > > stmt = con.createStatement(); > > ... > // some sql > > stmt.close(); > con.close(); > > if (!success) > return new AuthenticationResult(false, null); > } catch (Exception e) { > > } finally { > ... > // close everything > } > > // since I don't know how to build an XML-tree I copied something I > found. > // Create authentication XML tree > > DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); > try { > this.builder = factory.newDocumentBuilder(); > } catch (Exception e) { > } > Document doc = builder.newDocument(); > Element authElement = doc.createElementNS(null, "authentication"); > Element idElement = doc.createElementNS(null, "ID"); > Text text = doc.createTextNode(userID); > idElement.appendChild(text); > authElement.appendChild(idElement); > doc.appendChild(authElement); > > return new AuthenticationResult(true, doc); > } > > public void logout(UserHandler userHandler) { > } > > The error message: > > > java.lang.NullPointerException > > cause: java.lang.NullPointerException > > stacktrace[hide] > > java.lang.NullPointerException > at org.apache.xerces.dom.ElementImpl.normalize(Unknown Source) > at > org.apache.cocoon.webapps.authentication.context.AuthenticationContext.addParametersFromAuthenticationXML(AuthenticationContext.java:716) > > at > org.apache.cocoon.webapps.authentication.context.AuthenticationContext.createParameters(AuthenticationContext.java:683) > > at > org.apache.cocoon.webapps.authentication.context.AuthenticationContext.getContextInfo(AuthenticationContext.java:746) > > at > org.apache.cocoon.webapps.authentication.acting.LoginAction.act(LoginAction.java:87) > > at > org.apache.cocoon.components.treeprocessor.sitemap.ActTypeNode.invoke(ActTypeNode.java:119) > > at > org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:49) > > at > org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130) > > at > org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72) > > at > org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:126) > > ... > > > My guess that the Document I pass is invalid or something like that. > Must the passed xml follow a certain schema? > Is this the right way to produce the xml anyway (and how would it go)? > Other mistakes? > > > Cheers > jonny > > _________________________________________________________________ > Nicht lange suchen � finden! MSN Suche. http://search.msn.de/ Jetzt > testen! > > > --------------------------------------------------------------------- > 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