Search in sources :

Example 1 with TrustAgentSecureClient

use of com.intel.mountwilson.as.helper.TrustAgentSecureClient in project OpenAttestation by OpenAttestation.

the class TAHelper method getQuoteInformationForHost.

// BUG #497 see  the other getQuoteInformationForHost which is called from IntelHostAgent
//    public HashMap<String, PcrManifest> getQuoteInformationForHost(String hostIpAddress, String pcrList, String name, int port) {
public HashMap<String, PcrManifest> getQuoteInformationForHost(TblHosts tblHosts, String pcrList) {
    try {
        // going to IntelHostAgent directly because 1) we are TAHelper so we know we need intel trust agents,  2) the HostAgent interface isn't ready yet for full generic usage,  3) one day this entire function will be in the IntelHostAgent or that agent will call THIS function instaed of the othe way around
        HostAgentFactory factory = new HostAgentFactory();
        TlsPolicy tlsPolicy = factory.getTlsPolicy(tblHosts.getTlsPolicyName(), tblHosts.getTlsKeystoreResource());
        String connectionString = tblHosts.getAddOnConnectionInfo();
        if (connectionString == null || connectionString.isEmpty()) {
            if (tblHosts.getIPAddress() != null) {
                // without vendor scheme because we are passing directly to TrustAgentSEcureClient  (instead of to HOstAgentFactory)
                connectionString = String.format("https://%s:%d", tblHosts.getIPAddress(), tblHosts.getPort());
            }
        } else if (connectionString.startsWith("intel:")) {
            connectionString = connectionString.substring(6);
        }
        TrustAgentSecureClient client = new TrustAgentSecureClient(new TlsConnection(connectionString, tlsPolicy));
        //                IntelHostAgent agent = new IntelHostAgent(client, new InternetAddress(tblHosts.getIPAddress().toString()));
        HashMap<String, PcrManifest> pcrMap = getQuoteInformationForHost(tblHosts.getIPAddress(), client, pcrList);
        return pcrMap;
    } catch (ASException e) {
        throw e;
    } catch (UnknownHostException e) {
        throw new ASException(e, ErrorCode.AS_HOST_COMMUNICATION_ERROR, "Unknown host: " + (tblHosts.getIPAddress() == null ? "missing IP Address" : tblHosts.getIPAddress().toString()));
    } catch (Exception e) {
        throw new ASException(e);
    }
}
Also used : TrustAgentSecureClient(com.intel.mountwilson.as.helper.TrustAgentSecureClient) UnknownHostException(java.net.UnknownHostException) PcrManifest(com.intel.mountwilson.manifest.data.PcrManifest) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) KeyStoreException(java.security.KeyStoreException) XMLStreamException(javax.xml.stream.XMLStreamException) SignatureException(java.security.SignatureException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) InvalidKeySpecException(java.security.spec.InvalidKeySpecException) CertificateException(java.security.cert.CertificateException) UnknownHostException(java.net.UnknownHostException)

Aggregations

ASException (com.intel.mountwilson.as.common.ASException)1 TrustAgentSecureClient (com.intel.mountwilson.as.helper.TrustAgentSecureClient)1 PcrManifest (com.intel.mountwilson.manifest.data.PcrManifest)1 UnknownHostException (java.net.UnknownHostException)1 InvalidKeyException (java.security.InvalidKeyException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 SignatureException (java.security.SignatureException)1 CertificateException (java.security.cert.CertificateException)1 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1