Search in sources :

Example 6 with Hostname

use of com.intel.mtwilson.util.net.Hostname in project OpenAttestation by OpenAttestation.

the class HostTrustBO method getTrustWithSamlForHostnames.

public String getTrustWithSamlForHostnames(Collection<String> hosts) throws IOException {
    //My.initDataEncryptionKey();
    ArrayList<TblHosts> tblHostsList = new ArrayList<TblHosts>();
    for (String host : hosts) {
        TblHosts tblHosts = getHostByName(new Hostname((host)));
        tblHostsList.add(tblHosts);
    }
    return getTrustWithSaml(tblHostsList);
}
Also used : TblHosts(com.intel.mtwilson.as.data.TblHosts) ArrayList(java.util.ArrayList) Hostname(com.intel.mtwilson.util.net.Hostname)

Example 7 with Hostname

use of com.intel.mtwilson.util.net.Hostname in project OpenAttestation by OpenAttestation.

the class HostBOTest method testDeleteHost.

@Test
public void testDeleteHost() throws CryptographyException {
    List<TblTaLog> taLogs = new ArrayList<TblTaLog>();
    taLogs.add(new TblTaLog(1));
    taLogs.add(new TblTaLog(2));
    when(taLogJpaController.findLogsByHostId(anyInt(), any(Date.class))).thenReturn(taLogs);
    doReturn(new TblHosts(1)).when(hostBO).getHostByName(new Hostname(SERVER_NAME));
    String response = hostBO.deleteHost(new Hostname(SERVER_NAME));
    assertTrue(response.equalsIgnoreCase("true"));
}
Also used : TblTaLog(com.intel.mtwilson.as.data.TblTaLog) TblHosts(com.intel.mtwilson.as.data.TblHosts) ArrayList(java.util.ArrayList) Hostname(com.intel.mtwilson.util.net.Hostname) Matchers.anyString(org.mockito.Matchers.anyString) Date(java.util.Date) Test(org.junit.Test)

Example 8 with Hostname

use of com.intel.mtwilson.util.net.Hostname in project OpenAttestation by OpenAttestation.

the class HostBOTest method testUpdateHost.

@Test
public void testUpdateHost() throws CryptographyException {
    doReturn(mockGetHost()).when(hostBO).getHostByName(new Hostname(SERVER_NAME));
    when(mleJpaController.findBiosMle(anyString(), anyString(), anyString())).thenReturn(mockGetHost().getBiosMleId());
    when(mleJpaController.findVmmMle(anyString(), anyString(), anyString(), anyString())).thenReturn(mockGetHost().getBiosMleId());
    String response = hostBO.updateHost(mockHost());
    assertTrue(response.equalsIgnoreCase("true"));
}
Also used : Hostname(com.intel.mtwilson.util.net.Hostname) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 9 with Hostname

use of com.intel.mtwilson.util.net.Hostname in project OpenAttestation by OpenAttestation.

the class HostTrustBO method getHostWithTrust.

public TxtHost getHostWithTrust(TblHosts tblHosts, String hostId, TblSamlAssertion tblSamlAssertion) throws IOException {
    //HostTrustStatus trust = getTrustStatus(tblHosts, hostId);
    HostTrustStatus trust = getTrustStatus(new Hostname(tblHosts.getName()));
    TxtHostRecord data = createTxtHostRecord(tblHosts);
    TxtHost host = new TxtHost(data, trust);
    tblSamlAssertion.setHostId(tblHosts);
    tblSamlAssertion.setBiosTrust(trust.bios);
    tblSamlAssertion.setVmmTrust(trust.vmm);
    return host;
}
Also used : Hostname(com.intel.mtwilson.util.net.Hostname)

Example 10 with Hostname

use of com.intel.mtwilson.util.net.Hostname in project OpenAttestation by OpenAttestation.

the class Host method get.

/**
     * Returns the trust status of a host.
     * 
     * Sample request:
     * GET http://localhost:8080/AttestationService/resources/hosts/trust?hostName=Some+TXT+Host
     * 
     * Sample output for untrusted host:
     * BIOS:0,VMM:0
     * 
     * Sample output for trusted host:
     * BIOS:1,VMM:1
     * 
     * @param hostName unique name of the host to query
     * @return a string like BIOS:0,VMM:0 representing the trust status
     */
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Path("/trust")
public HostTrustResponse get(@QueryParam("hostName") String hostName) {
    try {
        // 0.5.1 returned MediaType.TEXT_PLAIN string like "BIOS:0,VMM:0" :  return new HostTrustBO().getTrustStatusString(new Hostname(hostName)); // datatype.Hostname            
        Hostname hostname = new Hostname(hostName);
        HostTrustStatus trust = new ASComponentFactory().getHostTrustBO().getTrustStatus(hostname);
        return new HostTrustResponse(hostname, trust);
    } catch (ASException e) {
        throw e;
    } catch (Exception e) {
        throw new ASException(e);
    }
}
Also used : ASComponentFactory(com.intel.mtwilson.as.helper.ASComponentFactory) Hostname(com.intel.mtwilson.util.net.Hostname) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

Hostname (com.intel.mtwilson.util.net.Hostname)30 Test (org.junit.Test)15 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)8 TblTaLog (com.intel.mtwilson.as.data.TblTaLog)7 ApiException (com.intel.mtwilson.ApiException)6 SignatureException (java.security.SignatureException)6 DemoPortalException (com.intel.mountwilson.common.DemoPortalException)5 TblHosts (com.intel.mtwilson.as.data.TblHosts)5 Date (java.util.Date)5 ASException (com.intel.mountwilson.as.common.ASException)4 HostsTrustReportType (com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType)4 Matchers.anyString (org.mockito.Matchers.anyString)4 CryptographyException (com.intel.mtwilson.crypto.CryptographyException)3 UnknownHostException (java.net.UnknownHostException)3 HostType (com.intel.mountwilson.as.hosttrustreport.data.HostType)2 AttestationReport (com.intel.mtwilson.datatypes.AttestationReport)2 HostTrustResponse (com.intel.mtwilson.datatypes.HostTrustResponse)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 ConfigurationException (org.apache.commons.configuration.ConfigurationException)2