use of javax.xml.bind.Marshaller in project OpenAM by OpenRock.
the class CreateWSFedMetaDataTemplate method createStandardMetaTemplate.
public static String createStandardMetaTemplate(String entityId, Map mapParams, String url) throws JAXBException, CertificateEncodingException {
JAXBContext jc = WSFederationMetaUtils.getMetaJAXBContext();
com.sun.identity.wsfederation.jaxb.wsfederation.ObjectFactory objFactory = new com.sun.identity.wsfederation.jaxb.wsfederation.ObjectFactory();
FederationElement fed = objFactory.createFederationElement();
fed.setFederationID(entityId);
String idpAlias = (String) mapParams.get(MetaTemplateParameters.P_IDP);
if (idpAlias != null) {
addWSFedIdentityProviderTemplate(entityId, objFactory, fed, mapParams, url);
}
String spAlias = (String) mapParams.get(MetaTemplateParameters.P_SP);
if (spAlias != null) {
addWSFedServiceProviderTemplate(entityId, objFactory, fed, mapParams, url);
}
Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
StringWriter pw = new StringWriter();
m.marshal(fed, pw);
return pw.toString();
}
use of javax.xml.bind.Marshaller in project midpoint by Evolveum.
the class ToolsUtils method serializeObject.
public static void serializeObject(Object object, Writer writer) throws JAXBException {
if (object == null) {
return;
}
Marshaller marshaller = JAXB_CONTEXT.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_ENCODING, StandardCharsets.UTF_8.name());
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
if (object instanceof ObjectType) {
object = new JAXBElement(C_OBJECT, Object.class, object);
}
marshaller.marshal(object, writer);
}
use of javax.xml.bind.Marshaller in project OpenAM by OpenRock.
the class WSFederationMetaUtils method convertJAXBToOutputStream.
/**
* Converts a JAXB object and writes to an <code>OutputStream</code> object.
* @param jaxbObj a JAXB object
* @param os an <code>OutputStream</code> object
* @exception JAXBException if an error occurs while converting JAXB object
*/
public static void convertJAXBToOutputStream(Object jaxbObj, OutputStream os) throws JAXBException {
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(PROP_JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.setProperty(PROP_NAMESPACE_PREFIX_MAPPER, nsPrefixMapper);
marshaller.marshal(jaxbObj, os);
}
use of javax.xml.bind.Marshaller in project OpenAM by OpenRock.
the class SMDiscoEntryData method convertDiscoEntryToXmlStr.
private String convertDiscoEntryToXmlStr(DiscoEntryElement de) throws JAXBException {
JAXBContext jc = JAXBContext.newInstance(Utils.getJAXBPackages());
Marshaller m = jc.createMarshaller();
StringWriter sw = new StringWriter();
m.marshal(de, sw);
return sw.getBuffer().toString();
}
use of javax.xml.bind.Marshaller in project opennms by OpenNMS.
the class BundleContextHistoryManager method toXML.
private String toXML(SavedHistory hist) {
StringWriter writer = new StringWriter();
Marshaller marshaller;
try {
JAXBContext context = JAXBContext.newInstance(SavedHistory.class);
marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);
marshaller.marshal(hist, writer);
} catch (JAXBException e) {
LoggerFactory.getLogger(getClass()).error("Could not marshall SavedHistory object to String", e);
}
return writer.toString();
}
Aggregations