}
public static Element createSAMLAssertion(XMLStreamReader reader) throws XWSSecurityException,XMLStreamException{
XMLOutputFactory xof = XMLOutputFactory.newInstance();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
MutableXMLStreamBuffer buffer = new MutableXMLStreamBuffer();
StreamWriterBufferCreator bCreator = new StreamWriterBufferCreator(buffer);
Document doc = null;
try{
XMLStreamWriter writer = xof.createXMLStreamWriter(baos);
XMLStreamWriter writer_tmp = (XMLStreamWriter)bCreator;
while(!(XMLStreamReader.END_DOCUMENT == reader.getEventType())){
com.sun.xml.ws.security.opt.impl.util.StreamUtil.writeCurrentEvent(reader, writer_tmp);
reader.next();
}
buffer.writeToXMLStreamWriter(writer);
writer.close();
try {
baos.close();
} catch (IOException ex) {
throw new XWSSecurityException("Error occurred while trying to convert SAMLAssertion stream into DOM Element", ex);