Search in sources :

Example 1 with HostRequestType

use of com.intel.mountwilson.ta.host.data.HostRequestType in project OpenAttestation by OpenAttestation.

the class TrustAgentSecureClient method getHostAttributes.

public String getHostAttributes() {
    try {
        log.info("Sending Generate Identity");
        byte[] identityInput = "<host_info_request></host_info_request>".getBytes();
        this.data = identityInput;
        HostRequestType response = sendHostRequest();
        //ClientRequestType response = sendQuoteRequest();
        String hardware_uuid = response.getHardware_uuid();
        // TODO:  ensure certificate is propertly formatted.  If missing a line after the header, insert it.  Or decode it, and re-encode as base-64 blob with no line endings.
        return hardware_uuid;
    //return certificate;
    } catch (ASException ase) {
        throw ase;
    } catch (UnknownHostException e) {
        throw new ASException(e, ErrorCode.AS_HOST_COMMUNICATION_ERROR, this.serverHostname);
    } catch (Exception e) {
        throw new ASException(e);
    }
}
Also used : HostRequestType(com.intel.mountwilson.ta.host.data.HostRequestType) UnknownHostException(java.net.UnknownHostException) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) PropertyException(javax.xml.bind.PropertyException) SocketTimeoutException(java.net.SocketTimeoutException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) JAXBException(javax.xml.bind.JAXBException) UnknownHostException(java.net.UnknownHostException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NoRouteToHostException(java.net.NoRouteToHostException)

Example 2 with HostRequestType

use of com.intel.mountwilson.ta.host.data.HostRequestType 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 {
    }
}
Also used : HostRequestType(com.intel.mountwilson.ta.host.data.HostRequestType) StringReader(java.io.StringReader) JAXBContext(javax.xml.bind.JAXBContext) JAXBElement(javax.xml.bind.JAXBElement) Unmarshaller(javax.xml.bind.Unmarshaller)

Aggregations

HostRequestType (com.intel.mountwilson.ta.host.data.HostRequestType)2 ASException (com.intel.mountwilson.as.common.ASException)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 MalformedURLException (java.net.MalformedURLException)1 NoRouteToHostException (java.net.NoRouteToHostException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 UnknownHostException (java.net.UnknownHostException)1 KeyManagementException (java.security.KeyManagementException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBElement (javax.xml.bind.JAXBElement)1 JAXBException (javax.xml.bind.JAXBException)1 PropertyException (javax.xml.bind.PropertyException)1 Unmarshaller (javax.xml.bind.Unmarshaller)1