/** * Clone an XMLObject by brute force: * * <p> * 1) Marshall the original object if necessary * 2) Clone the resulting DOM Element * 3) Unmarshall a new XMLObject tree around it. * </p> * * <p> * This method variant is equivalent to <code>cloneXMLObject(originalXMLObject, false).</code> * </p> * * * @param originalXMLObject the object to be cloned * @return a clone of the original object * * @throws MarshallingException if original object can not be marshalled * @throws UnmarshallingException if cloned object tree can not be unmarshalled * * @param <T> the type of object being cloned */ public static <T extends XMLObject> T cloneXMLObject(T originalXMLObject) throws MarshallingException, UnmarshallingException { return cloneXMLObject(originalXMLObject, false); }
/** * Clone an XMLObject by brute force: * * <p> * 1) Marshall the original object if necessary * 2) Clone the resulting DOM Element * 3) Unmarshall a new XMLObject tree around it. * </p> * * <p> * This method variant is equivalent to <code>cloneXMLObject(originalXMLObject, false).</code> * </p> * * * @param originalXMLObject the object to be cloned * @return a clone of the original object * * @throws MarshallingException if original object can not be marshalled * @throws UnmarshallingException if cloned object tree can not be unmarshalled * * @param <T> the type of object being cloned */ public static <T extends XMLObject> T cloneXMLObject(T originalXMLObject) throws MarshallingException, UnmarshallingException { return cloneXMLObject(originalXMLObject, false); }
/** * Get the SAMLObject which will actually be stored in the produced SAMLArtifactMapEntry. * * <p> * This may or may not be the same SAMLObject that is passed in. If the SAMLObject does * not have a parent, the same object will be returned. Otherwise, the object will be cloned * and the cloned instance returned. * </p> * * @param samlMessage the SAML message to process * @return an equivalent SAML Message */ private SAMLObject getStorableSAMLMessage(SAMLObject samlMessage) { if (!samlMessage.hasParent()) { return samlMessage; } else { try { return XMLObjectHelper.cloneXMLObject(samlMessage, true); } catch (MarshallingException e) { throw new XMLRuntimeException("Error during marshalling of SAMLObject", e); } catch (UnmarshallingException e) { throw new XMLRuntimeException("Error during unmarshalling of SAMLObject", e); } } }