use of com.intel.mountwilson.ta.data.ClientRequestType in project OpenAttestation by OpenAttestation.
the class TrustAgentSecureClient method getAIKCertificate.
// XXX TODO we need to return an X509Certificate here; if the caller wants it in PEM format they can encode it. returning a String is ambiguous and leaves open possibiility of parsing errors later. we should catch them here.
public String getAIKCertificate() {
try {
log.info("Sending Generate Identity");
byte[] identityInput = "<identity_request></identity_request>".getBytes();
this.data = identityInput;
ClientRequestType response = sendQuoteRequest();
String certificate = response.getAikcert();
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);
}
}
use of com.intel.mountwilson.ta.data.ClientRequestType in project OpenAttestation by OpenAttestation.
the class TrustAgentSecureClient method getQuote.
public ClientRequestType getQuote(String nonce, String pcrList) throws PropertyException, JAXBException, UnknownHostException, IOException, KeyManagementException, NoSuchAlgorithmException {
QuoteRequest quoteRequest = new QuoteRequest();
quoteRequest.setPcrList(pcrList + ",22,22");
quoteRequest.setNonce(nonce);
this.data = getXml(quoteRequest).getBytes();
ClientRequestType clientRequestType = sendQuoteRequest();
log.info("Got quote from server");
log.info("+++++++++++++++++++++++++++clientRequestType.getQuote(): " + clientRequestType.getQuote());
log.info("+++++++++++++++++++++++++++clientRequestType.getEventLog(): " + new String(Base64.decodeBase64(clientRequestType.getEventLog())));
return clientRequestType;
}
use of com.intel.mountwilson.ta.data.ClientRequestType 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 com.intel.mountwilson.ta.data.ClientRequestType in project OpenAttestation by OpenAttestation.
the class TAHelper method getQuoteInformationForHost.
public HashMap<String, PcrManifest> getQuoteInformationForHost(String hostname, TrustAgentSecureClient client, String pcrList) throws Exception {
// XXX BUG #497 START CODE SNIPPET MOVED TO INTEL HOST AGENT
String nonce = generateNonce();
String sessionId = generateSessionId();
ClientRequestType clientRequestType = client.getQuote(nonce, pcrList);
log.info("got response from server [" + hostname + "] " + clientRequestType);
String quote = clientRequestType.getQuote();
log.info("extracted quote from response: " + quote);
saveQuote(quote, sessionId);
log.info("saved quote with session id: " + sessionId);
// we only need to save the certificate when registring the host ... when we are just getting a quote we need to verify it using the previously saved AIK.
if (trustedAik == null) {
String aikCertificate = clientRequestType.getAikcert();
log.info("extracted aik cert from response: " + aikCertificate);
saveCertificate(aikCertificate, sessionId);
log.info("saved host-provided AIK certificate with session id: " + sessionId);
} else {
// XXX we only need to save the certificate when registring the host ... when we are just getting a quote we don't need it
saveCertificate(trustedAik, sessionId);
log.info("extracted aik cert from database: " + trustedAik);
log.info("saved database-provided trusted AIK certificate with session id: " + sessionId);
}
saveNonce(nonce, sessionId);
log.info("TAHelper - src: saved nonce with session id: " + sessionId);
createRSAKeyFile(sessionId);
log.info("created RSA key file for session id: " + sessionId);
// issue #879
byte[] eventLogBytes = Base64.decodeBase64(clientRequestType.getEventLog());
HashMap<String, PcrManifest> pcrMap;
if (eventLogBytes != null) {
String decodedEventLog = new String(eventLogBytes);
pcrMap = verifyQuoteAndGetPcr(sessionId, decodedEventLog);
log.info("Got PCR map");
} else {
pcrMap = verifyQuoteAndGetPcr(sessionId, null);
log.info("Got PCR map");
}
return pcrMap;
//log.log(Level.INFO, "PCR map = "+pcrMap); // need to untaint this first
}
Aggregations