Package se.litsec.opensaml.utils
Class ObjectUtils
- java.lang.Object
- 
- se.litsec.opensaml.utils.ObjectUtils
 
- 
 public class ObjectUtils extends Object Utility methods for creating OpenSAML objects within directly having to make use of the builders for each object you are creating and methods for marshalling and unmarshalling.- Author:
- Martin Lindström (martin.lindstrom@litsec.se)
 
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T extends SAMLObject>
 TcreateSamlObject(Class<T> clazz)Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.buildXMLObject(QName)insteadstatic <T extends SAMLObject>
 TcreateSamlObject(Class<T> clazz, QName elementName)Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.buildXMLObject(QName, QName)insteadstatic <T extends XMLObject>
 TcreateXMLObject(Class<T> clazz, QName elementName)Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.buildXMLObject(QName)insteadstatic <T extends XMLObject>
 TcreateXMLObject(Class<T> clazz, QName registeredElementName, QName elementNameToAssign)Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.buildXMLObject(QName, QName)insteadstatic <T extends SAMLObject>
 XMLObjectBuilder<T>getBuilder(Class<T> clazz)Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.getBuilder(QName)insteadstatic <T extends XMLObject>
 XMLObjectBuilder<T>getBuilder(QName elementName)Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.getBuilder(QName)insteadstatic <T extends SAMLObject>
 QNamegetDefaultElementName(Class<T> clazz)Returns the default element name for the supplied classstatic <T extends XMLObject>
 Elementmarshall(T object)Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.marshall(XMLObject)insteadstatic <T extends SAMLObject>
 StringtoString(T object)Returns the given SAML object in its "pretty print" XML string form.static <T extends SAMLObject>
 StringtoStringSafe(T object)The same asObject.toString()but the method never throws (returns the empty string instead).static <T extends XMLObject>
 Tunmarshall(InputStream inputStream, Class<T> targetClass)Unmarshalls the supplied input stream into the given type.static <T extends XMLObject>
 Tunmarshall(Element xml, Class<T> targetClass)Unmarshalls the supplied element into the given type.
 
- 
- 
- 
Method Detail- 
createSamlObject@Deprecated(forRemoval=true) public static <T extends SAMLObject> T createSamlObject(Class<T> clazz) Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.buildXMLObject(QName)insteadUtility method for creating an OpenSAMLSAMLObjectusing the default element name of the class.Note: The field DEFAULT_ELEMENT_NAME of the given class will be used as the object's element name. - Type Parameters:
- T- the type of the class to create
- Parameters:
- clazz- the class to create
- Returns:
- the SAML object
- See Also:
- createSamlObject(Class, QName)
 
 - 
createSamlObject@Deprecated(forRemoval=true) public static <T extends SAMLObject> T createSamlObject(Class<T> clazz, QName elementName) Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.buildXMLObject(QName, QName)insteadUtility method for creating an OpenSAMLSAMLObjectgiven its element name.- Type Parameters:
- T- the type
- Parameters:
- clazz- the class to create
- elementName- the element name to assign the object that is created.
- Returns:
- the SAML object
 
 - 
createXMLObject@Deprecated(forRemoval=true) public static <T extends XMLObject> T createXMLObject(Class<T> clazz, QName elementName) Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.buildXMLObject(QName)insteadUtility method for creating anXMLObjectgiven its element name.- Type Parameters:
- T- the type
- Parameters:
- clazz- the class to create
- elementName- the element name for the XML object to create
- Returns:
- the XML object
 
 - 
createXMLObject@Deprecated(forRemoval=true) public static <T extends XMLObject> T createXMLObject(Class<T> clazz, QName registeredElementName, QName elementNameToAssign) Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.buildXMLObject(QName, QName)insteadUtility method for creating anXMLObjectgiven its registered element name but where theelementNameToAssignis assigned to the object created.- Type Parameters:
- T- the type
- Parameters:
- clazz- the class to create
- registeredElementName- the element name that the object is registered under
- elementNameToAssign- the element to assign to the object that is created
- Returns:
- the XML object
 
 - 
getDefaultElementNamepublic static <T extends SAMLObject> QName getDefaultElementName(Class<T> clazz) Returns the default element name for the supplied class- Type Parameters:
- T- the type
- Parameters:
- clazz- class to check
- Returns:
- the default QName
 
 - 
getBuilder@Deprecated(forRemoval=true) public static <T extends SAMLObject> XMLObjectBuilder<T> getBuilder(Class<T> clazz) Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.getBuilder(QName)insteadReturns the builder object that can be used to create objects of the supplied class type.Note: The field DEFAULT_ELEMENT_NAME of the given class will be used as the object's element name. - Type Parameters:
- T- the type
- Parameters:
- clazz- the class which we want a builder for
- Returns:
- a builder object
- See Also:
- getBuilder(QName)
 
 - 
getBuilder@Deprecated(forRemoval=true) public static <T extends XMLObject> XMLObjectBuilder<T> getBuilder(QName elementName) Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.getBuilder(QName)insteadReturns the builder object that can be used to build object for the given element name.- Type Parameters:
- T- the type
- Parameters:
- elementName- the element name for the XML object that the builder should return
- Returns:
- a builder object
 
 - 
marshall@Deprecated(forRemoval=true) public static <T extends XMLObject> Element marshall(T object) throws MarshallingException Deprecated, for removal: This API element is subject to removal in a future version.useXMLObjectSupport.marshall(XMLObject)insteadMarshalls the suppliedXMLObjectinto anElement.- Type Parameters:
- T- the type
- Parameters:
- object- the object to marshall
- Returns:
- an XML element
- Throws:
- MarshallingException- for marshalling errors
 
 - 
unmarshallpublic static <T extends XMLObject> T unmarshall(Element xml, Class<T> targetClass) throws UnmarshallingException Unmarshalls the supplied element into the given type.- Type Parameters:
- T- the type
- Parameters:
- xml- the DOM (XML) to unmarshall
- targetClass- the required class
- Returns:
- an XMLObjectof the given type
- Throws:
- UnmarshallingException- for unmarshalling errors
 
 - 
unmarshallpublic static <T extends XMLObject> T unmarshall(InputStream inputStream, Class<T> targetClass) throws XMLParserException, UnmarshallingException Unmarshalls the supplied input stream into the given type.- Type Parameters:
- T- the type
- Parameters:
- inputStream- the input stream of the XML resource
- targetClass- the required class
- Returns:
- an XMLObjectof the given type
- Throws:
- XMLParserException- for XML parsing errors
- UnmarshallingException- for unmarshalling errors
 
 - 
toStringpublic static <T extends SAMLObject> String toString(T object) throws MarshallingException Returns the given SAML object in its "pretty print" XML string form.- Type Parameters:
- T- the type of object to "print"
- Parameters:
- object- the object to display as a string
- Returns:
- the XML as a string
- Throws:
- MarshallingException- for marshalling errors
 
 - 
toStringSafepublic static <T extends SAMLObject> String toStringSafe(T object) The same asObject.toString()but the method never throws (returns the empty string instead). Useful for logging statements.- Type Parameters:
- T- the type of object to "print"
- Parameters:
- object- the object to display as a string
- Returns:
- the XML as a string
 
 
- 
 
-