Class MSVValidator
- java.lang.Object
-
- com.sun.identity.saml2.jaxb.assertion.impl.runtime.MSVValidator
-
- All Implemented Interfaces:
XMLSerializer,com.sun.msv.grammar.IDContextProvider2,org.relaxng.datatype.ValidationContext
public class MSVValidator extends Object implements XMLSerializer, com.sun.msv.grammar.IDContextProvider2
XMLSerializer that calls the native interface of MSV and performs validation. Used in a pair with a ValidationContext.- Author:
- Kohsuke Kawaguchi
-
-
Field Summary
Fields Modifier and Type Field Description static StringDUMMY_ELEMENT_NSnamespace URI of dummy elements.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchildAsAttributes(com.sun.xml.bind.JAXBObject o, String fieldName)This method is called when an JAXBObject object is found while the marshaller is in the "attribute" mode (i.e. marshalling attributes of an element)voidchildAsBody(com.sun.xml.bind.JAXBObject o, String fieldName)This method is called when an JAXBObject object is found while the marshaller is in the "element" mode (i.e. marshalling a content model of an element)voidchildAsURIs(com.sun.xml.bind.JAXBObject o, String fieldName)This method is called when an JAXBObject object is found while the marshaller is in the "URI" mode.voidendAttribute()voidendAttributes()Switches to the mode to marshal child texts/elements.voidendElement()Ends marshalling of an element.voidendNamespaceDecls()Switches to the mode to marshal attribute values.StringgetBaseUri()NamespaceContext2getNamespaceContext()Obtains a namespace context object, which is used to declare/obtain namespace bindings.booleanisNotation(String notation)booleanisUnparsedEntity(String entityName)StringonID(com.sun.xml.bind.marshaller.IdentifiableObject owner, String value)Notifies the serializer that an ID value has just marshalled.voidonID(org.relaxng.datatype.Datatype dt, com.sun.msv.verifier.regexp.StringToken s)StringonIDREF(com.sun.xml.bind.marshaller.IdentifiableObject value)Notifies the serializer that an IDREF value has just marshalled.voidreportError(ValidationEvent e)Errors detected by the XMLSerializable should be either thrown asSAXExceptionor reported through this method.voidreportMissingObjectError(String fieldName)StringresolveNamespacePrefix(String prefix)voidstartAttribute(String uri, String local)Starts marshalling of an attribute.voidstartElement(String uri, String local)Starts marshalling of an element.voidtext(String text, String fieldName)Marshalls text.static voidvalidate(DefaultJAXBContextImpl jaxbCtx, com.sun.identity.saml2.jaxb.assertion.impl.runtime.ValidationContext context, ValidatableObject vo)Validates the specified object and reports any error to the context.
-
-
-
Field Detail
-
DUMMY_ELEMENT_NS
public static final String DUMMY_ELEMENT_NS
namespace URI of dummy elements. TODO: allocate one namespace URI for this.- See Also:
- Constant Field Values
-
-
Method Detail
-
getNamespaceContext
public NamespaceContext2 getNamespaceContext()
Description copied from interface:XMLSerializerObtains a namespace context object, which is used to declare/obtain namespace bindings.- Specified by:
getNamespaceContextin interfaceXMLSerializer
-
validate
public static void validate(DefaultJAXBContextImpl jaxbCtx, com.sun.identity.saml2.jaxb.assertion.impl.runtime.ValidationContext context, ValidatableObject vo) throws SAXException
Validates the specified object and reports any error to the context.- Throws:
SAXException
-
endNamespaceDecls
public void endNamespaceDecls() throws SAXExceptionDescription copied from interface:XMLSerializerSwitches to the mode to marshal attribute values. This method has to be called after the 1st pass is completed.- Specified by:
endNamespaceDeclsin interfaceXMLSerializer- Throws:
SAXException
-
endAttributes
public void endAttributes() throws SAXExceptionDescription copied from interface:XMLSerializerSwitches to the mode to marshal child texts/elements. This method has to be called after the 2nd pass is completed.- Specified by:
endAttributesin interfaceXMLSerializer- Throws:
SAXException
-
text
public final void text(String text, String fieldName) throws SAXException
Description copied from interface:XMLSerializerMarshalls text.This method can be called (i) after the startAttribute method and (ii) before the endAttribute method, to marshal attribute values. If the method is called more than once, those texts are considered as separated by whitespaces. For example,
c.startAttribute(); c.text("abc"); c.text("def"); c.endAttribute("","foo");will generate foo="abc def".Similarly, this method can be called after the endAttributes method to marshal texts inside elements. The same rule about multiple invokations apply to this case, too. For example,
c.startElement("","foo"); c.endNamespaceDecls(); c.endAttributes(); c.text("abc"); c.text("def"); c.startElement("","bar"); c.endAttributes(); c.endElement(); c.text("ghi"); c.endElement();will generate<foo>abc def<bar/>ghi</foo>.- Specified by:
textin interfaceXMLSerializer- Throws:
SAXException
-
reportMissingObjectError
public void reportMissingObjectError(String fieldName) throws SAXException
- Throws:
SAXException
-
startAttribute
public void startAttribute(String uri, String local)
Description copied from interface:XMLSerializerStarts marshalling of an attribute. The marshalling of an attribute will be done by- call the startAttribute method
- call the text method (several times if necessary)
- call the endAttribute method
- Specified by:
startAttributein interfaceXMLSerializer
-
endAttribute
public void endAttribute() throws SAXException- Specified by:
endAttributein interfaceXMLSerializer- Throws:
SAXException
-
startElement
public void startElement(String uri, String local) throws SAXException
Description copied from interface:XMLSerializerStarts marshalling of an element. Calling this method will push the internal state into the internal stack.- Specified by:
startElementin interfaceXMLSerializer- Throws:
SAXException
-
endElement
public void endElement() throws SAXExceptionDescription copied from interface:XMLSerializerEnds marshalling of an element. Pops the internal stack.- Specified by:
endElementin interfaceXMLSerializer- Throws:
SAXException
-
childAsAttributes
public void childAsAttributes(com.sun.xml.bind.JAXBObject o, String fieldName) throws SAXExceptionDescription copied from interface:XMLSerializerThis method is called when an JAXBObject object is found while the marshaller is in the "attribute" mode (i.e. marshalling attributes of an element)- Specified by:
childAsAttributesin interfaceXMLSerializerfieldName- property name of the parent objeect from which 'o' comes. Used as a part of the error message in case anything goes wrong with 'o'.- Throws:
SAXException
-
childAsURIs
public void childAsURIs(com.sun.xml.bind.JAXBObject o, String fieldName) throws SAXExceptionDescription copied from interface:XMLSerializerThis method is called when an JAXBObject object is found while the marshaller is in the "URI" mode.- Specified by:
childAsURIsin interfaceXMLSerializerfieldName- property name of the parent objeect from which 'o' comes. Used as a part of the error message in case anything goes wrong with 'o'.- Throws:
SAXException
-
childAsBody
public void childAsBody(com.sun.xml.bind.JAXBObject o, String fieldName) throws SAXExceptionDescription copied from interface:XMLSerializerThis method is called when an JAXBObject object is found while the marshaller is in the "element" mode (i.e. marshalling a content model of an element)- Specified by:
childAsBodyin interfaceXMLSerializerfieldName- property name of the parent objeect from which 'o' comes. Used as a part of the error message in case anything goes wrong with 'o'.- Throws:
SAXException
-
reportError
public void reportError(ValidationEvent e) throws com.sun.xml.bind.serializer.AbortSerializationException
Description copied from interface:XMLSerializerErrors detected by the XMLSerializable should be either thrown asSAXExceptionor reported through this method. The callee should report an error to the client application and- Specified by:
reportErrorin interfaceXMLSerializer- Throws:
com.sun.xml.bind.serializer.AbortSerializationException
-
onID
public String onID(com.sun.xml.bind.marshaller.IdentifiableObject owner, String value) throws SAXException
Description copied from interface:XMLSerializerNotifies the serializer that an ID value has just marshalled. The serializer may or may not check the consistency of ID/IDREFs and may throw a SAXException.- Specified by:
onIDin interfaceXMLSerializer- Parameters:
owner- JAXB content object that posesses the ID.value- The value of the ID.- Returns:
- Return the value parameter without any modification, so that the invocation of this method can be done transparently by a transducer.
- Throws:
SAXException
-
onIDREF
public String onIDREF(com.sun.xml.bind.marshaller.IdentifiableObject value) throws SAXException
Description copied from interface:XMLSerializerNotifies the serializer that an IDREF value has just marshalled. The serializer may or may not check the consistency of ID/IDREFs and may throw a SAXException.- Specified by:
onIDREFin interfaceXMLSerializer- Returns:
- Return the value parameter without any modification. so that the invocation of this method can be done transparently by a transducer.
- Throws:
SAXException
-
getBaseUri
public String getBaseUri()
- Specified by:
getBaseUriin interfaceorg.relaxng.datatype.ValidationContext
-
isUnparsedEntity
public boolean isUnparsedEntity(String entityName)
- Specified by:
isUnparsedEntityin interfaceorg.relaxng.datatype.ValidationContext
-
isNotation
public boolean isNotation(String notation)
- Specified by:
isNotationin interfaceorg.relaxng.datatype.ValidationContext
-
onID
public void onID(org.relaxng.datatype.Datatype dt, com.sun.msv.verifier.regexp.StringToken s)- Specified by:
onIDin interfacecom.sun.msv.grammar.IDContextProvider2
-
-