Search in sources :

Example 1 with BulkHostTrustBO

use of com.intel.mtwilson.as.business.trust.BulkHostTrustBO in project OpenAttestation by OpenAttestation.

the class BulkHostTrust method getTrustSaml.

/**
         * REST Web Service Example: GET /hosts/trust?hosts=host_name_1
         * ,host_name_2,host_name_3&force_verify=true
         *
         * @param hosts
         * @param forceVerify
     * @param timeout
         * @return
         */
@GET
@Produces({ MediaType.APPLICATION_XML })
@Path("/trust/saml")
//@RolesAllowed({"Attestation", "Report"})
@RequiresPermissions("host_attestations:create,retrieve")
public String getTrustSaml(@QueryParam("hosts") String hosts, @QueryParam("force_verify") @DefaultValue("false") Boolean forceVerify, //                        @QueryParam("threads") @DefaultValue("5") Integer threads, // bug #503 max threads now global and configured in properties file
@QueryParam("timeout") @DefaultValue("600") Integer timeout) {
    ValidationUtil.validate(hosts);
    Integer myTimeOut = timeout;
    // Modified the default time out back to 600 seconds as we are seeing time out issues. 30 seconds short for VMware hosts.
    if (timeout == 600) {
        log.info("getTrustSaml called with default timeout, checking config");
        myTimeOut = ASConfig.getConfiguration().getInt("com.intel.mountwilson.as.attestation.hostTimeout", 600);
        log.debug("getTrustSaml config returned back" + myTimeOut);
    }
    if (hosts == null || hosts.length() == 0) {
        throw new ASException(com.intel.mtwilson.datatypes.ErrorCode.AS_MISSING_INPUT, "hosts");
    }
    Set<String> hostSet = new HashSet<String>();
    // bug #783  make sure that we only pass to the next layer hostnames that are likely to be valid 
    for (String host : Arrays.asList(hosts.split(","))) {
        log.debug("Host: '{}'", host);
        if (!(host.trim().isEmpty() || host.trim() == null)) {
            hostSet.add(host.trim());
        }
    }
    BulkHostTrustBO bulkHostTrustBO = new BulkHostTrustBO(/*threads, */
    myTimeOut);
    String result = bulkHostTrustBO.getBulkTrustSaml(hostSet, forceVerify);
    return result;
}
Also used : BulkHostTrustBO(com.intel.mtwilson.as.business.trust.BulkHostTrustBO) ASException(com.intel.mountwilson.as.common.ASException) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ASException (com.intel.mountwilson.as.common.ASException)1 BulkHostTrustBO (com.intel.mtwilson.as.business.trust.BulkHostTrustBO)1 HashSet (java.util.HashSet)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)1