1 16 package org.apache.cocoon.portal.tools.userManagement; 17 18 import org.apache.cocoon.webapps.authentication.context.AuthenticationContext; 19 import org.w3c.dom.DocumentFragment ; 20 import org.w3c.dom.Node ; 21 22 28 public class ContextGrabber { 29 30 36 public UserBean grab (AuthenticationContext context) { 37 UserBean ub = new UserBean (); 38 DocumentFragment df = null; 39 try { 40 df = context.getXML ("/authentication/"); 41 } catch (Exception e) {} 42 43 grabAuthContext (df.getFirstChild(),ub); 44 45 return ub; 46 } 47 48 private void grabAuthContext (Node node, UserBean ub) { 49 50 while (node != null) { 51 52 if (!node.getNodeName().equals("#text")) { 53 if (node.getFirstChild() != null) { 54 grabAuthContext (node.getFirstChild () ,ub); 55 ub.addContext(node.getNodeName(),node.getFirstChild().getNodeValue()); 56 } else { 57 ub.addContext(node.getNodeName(),""); 58 } 59 } 60 node = node.getNextSibling(); 61 } 62 } 63 64 } 65 | Popular Tags |