use of com.intel.mountwilson.as.hosttrustreport.data.HostType in project OpenAttestation by OpenAttestation.
the class DemoPortalServicesImpl method getHostTrustReport.
@Override
public List<HostReportTypeVO> getHostTrustReport(List<String> hostNames, ApiClient client) throws DemoPortalException {
AttestationService service = (AttestationService) client;
HostsTrustReportType report = null;
List<HostReportTypeVO> hostReportTypeVO = new ArrayList<HostReportTypeVO>();
try {
List<Hostname> hostList = new ArrayList<Hostname>();
for (String host : hostNames) {
hostList.add(new Hostname(host));
}
report = service.getHostTrustReport(hostList);
} catch (Exception e) {
log.error(e.getMessage());
throw ConnectionUtil.handleException(e);
}
List<HostType> list = report.getHost();
for (HostType hostType : list) {
HostReportTypeVO vo = new HostReportTypeVO();
vo.setHostName(hostType.getHostName());
vo.setMleInfo(hostType.getMLEInfo());
vo.setCreatedOn("");
vo.setTrustStatus(hostType.getTrustStatus());
vo.setVerifiedOn(formatter.format(hostType.getVerifiedOn().toGregorianCalendar().getTime()));
hostReportTypeVO.add(vo);
}
return hostReportTypeVO;
}
use of com.intel.mountwilson.as.hosttrustreport.data.HostType in project OpenAttestation by OpenAttestation.
the class ReportsBO method getReportManifest.
public HostManifestReportType getReportManifest(Hostname hostName) {
// datatype.Hostname
HostManifestReportType hostManifestReportType = new HostManifestReportType();
/*
* if (hostName == null || hostName.isEmpty()) { throw new
* ASException(ErrorCode.VALIDATION_ERROR, "Input Hostname " + hostName
* + " is empty."); }
*
*/
TblHosts tblHosts = null;
try {
// datatype.Hostname
tblHosts = getTblHostsJpaController().findByName(hostName.toString());
} catch (CryptographyException e) {
throw new ASException(e, ErrorCode.AS_ENCRYPTION_ERROR, e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
}
if (tblHosts == null) {
throw new ASException(ErrorCode.AS_HOST_NOT_FOUND, hostName.toString());
}
Date lastStatusTs = getTblTaLogJpaController().findLastStatusTs(tblHosts.getId());
if (lastStatusTs != null) {
List<TblTaLog> logs = getTblTaLogJpaController().findLogsByHostId(tblHosts.getId(), lastStatusTs);
com.intel.mountwilson.as.hostmanifestreport.data.HostType hostType = new com.intel.mountwilson.as.hostmanifestreport.data.HostType();
// datatype.Hostname
hostType.setName(hostName.toString());
if (logs != null) {
for (TblTaLog log : logs) {
ManifestType manifest = new ManifestType();
manifest.setName(Integer.parseInt(log.getManifestName()));
manifest.setValue(log.getManifestValue());
manifest.setVerifiedOn(Util.getCalendar(log.getUpdatedOn()));
manifest.setTrustStatus(getTrustStatus(log.getTrustStatus()));
hostType.getManifest().add(manifest);
}
}
hostManifestReportType.setHost(hostType);
}
return hostManifestReportType;
}
use of com.intel.mountwilson.as.hosttrustreport.data.HostType in project OpenAttestation by OpenAttestation.
the class ReportsBO method getTrustReport.
public HostsTrustReportType getTrustReport(Collection<Hostname> hostNames) {
// datatype.Hostname
try {
HostsTrustReportType hostsTrustReportType = new HostsTrustReportType();
for (Hostname host : hostNames) {
// datatype.Hostname
TblHosts tblHosts = getTblHostsJpaController().findByName(host.toString());
if (tblHosts == null) {
throw new ASException(ErrorCode.AS_HOST_NOT_FOUND, host);
}
List<TblTaLog> logs = getTblTaLogJpaController().findTrustStatusByHostId(tblHosts.getId(), 5);
if (logs != null) {
for (TblTaLog log : logs) {
HostType hostType = new HostType();
// datatype.Hostname
hostType.setHostName(host.toString());
hostType.setMLEInfo(getMleInfo(tblHosts));
hostType.setTrustStatus(getTrustStatus(log.getError()));
hostType.setVerifiedOn(Util.getCalendar(log.getUpdatedOn()));
hostsTrustReportType.getHost().add(hostType);
}
}
}
return hostsTrustReportType;
} catch (CryptographyException e) {
throw new ASException(e, ErrorCode.AS_ENCRYPTION_ERROR, e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
} catch (Exception e) {
throw new ASException(e);
}
}
use of com.intel.mountwilson.as.hosttrustreport.data.HostType in project OpenAttestation by OpenAttestation.
the class ReportsBO method getAttestationReport.
public AttestationReport getAttestationReport(Hostname hostName, Boolean failureOnly) throws NumberFormatException, IOException {
AttestationReport attestationReport = new AttestationReport();
TblHosts tblHosts = null;
try {
// datatype.Hostname
tblHosts = getTblHostsJpaController().findByName(hostName.toString());
} catch (CryptographyException e) {
throw new ASException(e, ErrorCode.AS_ENCRYPTION_ERROR, e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
}
if (tblHosts == null) {
throw new ASException(ErrorCode.AS_HOST_NOT_FOUND, hostName.toString());
}
Date lastStatusTs = getTblTaLogJpaController().findLastStatusTs(tblHosts.getId());
if (lastStatusTs != null) {
List<TblTaLog> logs = getTblTaLogJpaController().findLogsByHostId(tblHosts.getId(), lastStatusTs);
com.intel.mountwilson.as.hostmanifestreport.data.HostType hostType = new com.intel.mountwilson.as.hostmanifestreport.data.HostType();
// datatype.Hostname
hostType.setName(hostName.toString());
if (logs != null) {
for (TblTaLog log : logs) {
boolean value = (failureOnly && log.getTrustStatus() == false);
if (!failureOnly || value) {
if (log.getManifestName().equalsIgnoreCase(ASSET_TAG_PCR)) {
attestationReport.getPcrLogs().add(getPcrLogReportForAssetTag(log, tblHosts.getId()));
} else {
attestationReport.getPcrLogs().add(getPcrManifestLog(tblHosts, log, failureOnly));
}
}
}
}
}
return attestationReport;
}
Aggregations