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);
}
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"));
}
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"));
}
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;
}
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);
}
}
Aggregations