org.talika.tarsis.security.memory
Class XmlUsersHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.talika.tarsis.security.memory.XmlUsersHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public final class XmlUsersHandler
extends org.xml.sax.helpers.DefaultHandler

Implementation of SAX handlers for Tarsis MVC Users XML files.

Version:
$Revision: 125 $
Author:
Jose M. Palomar

Field Summary
static java.lang.String DTD_CLASSPATH
          DTD class path.
static java.lang.String DTD_PUBLICID
          DTD public id.
static java.lang.String NAME_ATTR
          Name attribute.
static java.lang.String PASSWORD_ATTR
          Password attribute.
static java.lang.String ROLES_ATTR
          Roles attribute.
static java.lang.String ROLES_SEPARATOR
          Roles separator.
static java.lang.String USER_TAG
          <user> tag.
static java.lang.String USERS_TAG
          <tarsis-users> tag.
 
Constructor Summary
XmlUsersHandler()
          Creates a new XmlUsersHandler.
 
Method Summary
 void endDocument()
          Receive notification of the end of a document.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String name)
          Receive notification of the end of an element.
 void error(org.xml.sax.SAXParseException spe)
          Receive notification of a recoverable error.
 void fatalError(org.xml.sax.SAXParseException spe)
          Receive notification of a non-recoverable error.
 java.util.Map getUsers()
          Returns parsed users map.
protected  java.util.Set parseRoles(java.lang.String rolesStr)
          Returns a Set of roles parsed from string.
protected  void processUserTag(org.xml.sax.Attributes atts)
          Process <user> tag.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          Allow the application to resolve external entities.
 void startDocument()
          Receive notification of the beginning of a document.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String name, org.xml.sax.Attributes atts)
          Receive notification of the beginning of an element.
 void warning(org.xml.sax.SAXParseException spe)
          Receive notification of a warning.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USERS_TAG

public static final java.lang.String USERS_TAG
<tarsis-users> tag.

See Also:
Constant Field Values

USER_TAG

public static final java.lang.String USER_TAG
<user> tag.

See Also:
Constant Field Values

NAME_ATTR

public static final java.lang.String NAME_ATTR
Name attribute.

See Also:
Constant Field Values

PASSWORD_ATTR

public static final java.lang.String PASSWORD_ATTR
Password attribute.

See Also:
Constant Field Values

ROLES_ATTR

public static final java.lang.String ROLES_ATTR
Roles attribute.

See Also:
Constant Field Values

ROLES_SEPARATOR

public static final java.lang.String ROLES_SEPARATOR
Roles separator.

See Also:
Constant Field Values

DTD_PUBLICID

public static final java.lang.String DTD_PUBLICID
DTD public id.

See Also:
Constant Field Values

DTD_CLASSPATH

public static final java.lang.String DTD_CLASSPATH
DTD class path.

See Also:
Constant Field Values
Constructor Detail

XmlUsersHandler

public XmlUsersHandler()
Creates a new XmlUsersHandler.

Method Detail

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Receive notification of the beginning of a document.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startDocument()

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Receive notification of the end of a document.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endDocument()

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String name,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Receive notification of the beginning of an element.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
namespaceURI - String The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
localName - String The local name (without prefix), or the empty string if Namespace processing is not being performed.
name - String The qualified name (with prefix), or the empty string if qualified names are not available.
atts - Attributes The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startElement(String, String, String, Attributes)

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String name)
                throws org.xml.sax.SAXException
Receive notification of the end of an element.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
namespaceURI - String The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
localName - String The local name (without prefix), or the empty string if Namespace processing is not being performed.
name - String The qualified name (with prefix), or the empty string if qualified names are not available.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endElement(String, String, String)

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
Allow the application to resolve external entities.

Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Overrides:
resolveEntity in class org.xml.sax.helpers.DefaultHandler
Parameters:
publicId - String The public identifier of the external entity being referenced, or null if none was supplied.
systemId - String The system identifier of the external entity being referenced.
Returns:
InputSource A Java-specific IO exception, possibly the result of creating a new InputStream or Reader for the InputSource.
See Also:
EntityResolver.resolveEntity(String, String)

warning

public void warning(org.xml.sax.SAXParseException spe)
             throws org.xml.sax.SAXException
Receive notification of a warning.

Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler
Parameters:
spe - SAXParseException The warning information encapsulated in a SAX parse exception.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ErrorHandler.warning(SAXParseException)

error

public void error(org.xml.sax.SAXParseException spe)
           throws org.xml.sax.SAXException
Receive notification of a recoverable error.

Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
Parameters:
spe - SAXParseException The error information encapsulated in a SAX parse exception.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ErrorHandler.error(SAXParseException)

fatalError

public void fatalError(org.xml.sax.SAXParseException spe)
                throws org.xml.sax.SAXException
Receive notification of a non-recoverable error.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
Parameters:
spe - SAXParseException The error information encapsulated in a SAX parse exception.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ErrorHandler.fatalError(SAXParseException)

getUsers

public java.util.Map getUsers()
Returns parsed users map.

Returns:
Map parsed users map.

processUserTag

protected void processUserTag(org.xml.sax.Attributes atts)
                       throws org.xml.sax.SAXException
Process <user> tag.

Parameters:
atts - Attributes tag attributes.
Throws:
org.xml.sax.SAXException - if there is an error while processing tag.

parseRoles

protected java.util.Set parseRoles(java.lang.String rolesStr)
Returns a Set of roles parsed from string.

Parameters:
rolesStr - String string to be parsed.
Returns:
Set a Set of roles parsed from string.


Copyright © 2002-2012 Talika Open Source Group. All Rights Reserved.