Search in sources :

Example 1 with ASComponentFactory

use of com.intel.mtwilson.as.helper.ASComponentFactory 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

ASException (com.intel.mountwilson.as.common.ASException)1 ASComponentFactory (com.intel.mtwilson.as.helper.ASComponentFactory)1 Hostname (com.intel.mtwilson.util.net.Hostname)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1