use of javax.xml.bind.JAXBElement in project OpenAttestation by OpenAttestation.
the class TrustAgentSecureClient method sendHostRequest.
/**
*
* @return an object representing the RESPONSE from the Trust Agent
* @throws UnknownHostException if the IP address of the host could not be determined from local hosts file or DNS
* @throws IOException if there was an error connecting to the host, such as it is not reachable on the network or it dropped the connection
* @throws JAXBException when the response from the host cannot be interpreted properly
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public synchronized HostRequestType sendHostRequest() throws UnknownHostException, IOException, JAXBException, KeyManagementException, NoSuchAlgorithmException {
try {
byte[] buf = sendRequestWithSSLSocket();
log.info("Unmarshalling to Jaxb object.");
JAXBContext jc = JAXBContext.newInstance("com.intel.mountwilson.ta.host.data");
log.debug("Created JAXBContext Instance {}", jc.toString());
//assert jc != null; Expression always true
Unmarshaller u = jc.createUnmarshaller();
log.debug("Created Unmarshaller Instance {}", u.toString());
//assert new String(buf) != null; //Expresion always return null.
assert buf != null;
log.debug("Unmarshalling");
JAXBElement po = (JAXBElement) u.unmarshal(new StringReader(new String(buf).trim()));
log.debug("Unmarshalled");
assert po != null;
HostRequestType response = (HostRequestType) po.getValue();
assert response != null;
checkHostError(response);
log.info("Done reading/writing to/from socket, closing socket.");
return response;
} finally {
}
}
use of javax.xml.bind.JAXBElement in project OpenAttestation by OpenAttestation.
the class TrustAgentSecureClient method sendQuoteRequest.
/**
*
* @return an object representing the RESPONSE from the Trust Agent
* @throws UnknownHostException if the IP address of the host could not be determined from local hosts file or DNS
* @throws IOException if there was an error connecting to the host, such as it is not reachable on the network or it dropped the connection
* @throws JAXBException when the response from the host cannot be interpreted properly
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public synchronized ClientRequestType sendQuoteRequest() throws UnknownHostException, IOException, JAXBException, KeyManagementException, NoSuchAlgorithmException {
try {
byte[] buf = sendRequestWithSSLSocket();
log.info("Unmarshalling to Jaxb object.");
JAXBContext jc = JAXBContext.newInstance("com.intel.mountwilson.ta.data");
assert jc != null;
Unmarshaller u = jc.createUnmarshaller();
assert u != null;
assert new String(buf) != null;
JAXBElement po = (JAXBElement) u.unmarshal(new StringReader(new String(buf).trim()));
assert po != null;
ClientRequestType response = (ClientRequestType) po.getValue();
assert response != null;
checkQuoteError(response);
log.info("Done reading/writing to/from socket, closing socket.");
return response;
} finally {
}
}
use of javax.xml.bind.JAXBElement in project jersey by jersey.
the class JaxbTest method testXmlType.
@Test
public void testXmlType() {
JaxbXmlType t1 = target().path("jaxb/JAXBElement").request().get(JaxbXmlType.class);
JAXBElement<JaxbXmlType> e = new JAXBElement<JaxbXmlType>(new QName("jaxbXmlRootElement"), JaxbXmlType.class, t1);
JaxbXmlType t2 = target().path("jaxb/XmlType").request("application/xml").post(xml(e), JaxbXmlType.class);
assertEquals(t1, t2);
}
use of javax.xml.bind.JAXBElement in project jersey by jersey.
the class XmlMoxyTest method _testListOrArray.
@SuppressWarnings("unchecked")
public void _testListOrArray(final boolean isList, final MediaType mt) {
final Object in = isList ? getJAXBElementList() : getJAXBElementArray();
final GenericType gt = isList ? new GenericType<List<JAXBElement<String>>>() {
} : new GenericType<JAXBElement<String>[]>() {
};
final WebTarget target = target(isList ? "JAXBElementListResource" : "JAXBElementArrayResource");
final Object out = target.request(mt).post(Entity.entity(new GenericEntity(in, gt.getType()), mt), gt);
final List<JAXBElement<String>> inList = isList ? ((List<JAXBElement<String>>) in) : Arrays.asList((JAXBElement<String>[]) in);
final List<JAXBElement<String>> outList = isList ? ((List<JAXBElement<String>>) out) : Arrays.asList((JAXBElement<String>[]) out);
assertEquals("Lengths differ", inList.size(), outList.size());
for (int i = 0; i < inList.size(); i++) {
assertEquals("Names of elements at index " + i + " differ", inList.get(i).getName(), outList.get(i).getName());
assertEquals("Values of elements at index " + i + " differ", inList.get(i).getValue(), outList.get(i).getValue());
}
}
use of javax.xml.bind.JAXBElement in project jersey by jersey.
the class EntityTypesTest method _testListOrArray.
public void _testListOrArray(final boolean isList, final MediaType mt) {
final Object in = isList ? getJAXBElementList() : getJAXBElementArray();
final GenericType gt = isList ? new GenericType<List<JAXBElement<String>>>() {
} : new GenericType<JAXBElement<String>[]>() {
};
final WebTarget target = target(isList ? "JAXBElementListResource" : "JAXBElementArrayResource");
final Object out = target.request(mt).post(Entity.entity(new GenericEntity(in, gt.getType()), mt), gt);
final List<JAXBElement<String>> inList = isList ? ((List<JAXBElement<String>>) in) : Arrays.asList((JAXBElement<String>[]) in);
final List<JAXBElement<String>> outList = isList ? ((List<JAXBElement<String>>) out) : Arrays.asList((JAXBElement<String>[]) out);
assertEquals("Lengths differ", inList.size(), outList.size());
for (int i = 0; i < inList.size(); i++) {
assertEquals("Names of elements at index " + i + " differ", inList.get(i).getName(), outList.get(i).getName());
assertEquals("Values of elements at index " + i + " differ", inList.get(i).getValue(), outList.get(i).getValue());
}
}
Aggregations