use of com.intel.mtwilson.as.data.TblOs in project OpenAttestation by OpenAttestation.
the class OsBO method deleteOs.
/**
*
* @param osName
* @param osVersion
* @return
*/
public String deleteOs(String osName, String osVersion) {
try {
TblOs tblOs = tblOsJpaController.findTblOsByNameVersion(osName, osVersion);
if (tblOs == null) {
throw new ASException(ErrorCode.WS_OS_DOES_NOT_EXIST, osName, osVersion);
}
Collection<TblMle> tblMleCollection = tblOs.getTblMleCollection();
if (tblMleCollection != null) {
log.info("OS is currently associated with # MLEs: " + tblMleCollection.size());
if (!tblMleCollection.isEmpty()) {
throw new ASException(ErrorCode.WS_OS_ASSOCIATION_EXISTS, osName, osVersion, tblMleCollection.size());
}
}
tblOsJpaController.destroy(tblOs.getId());
} catch (ASException ase) {
throw ase;
} catch (Exception e) {
throw new ASException(e);
}
return "true";
}
use of com.intel.mtwilson.as.data.TblOs in project OpenAttestation by OpenAttestation.
the class MleBOTest method mockFindVmmMle.
public TblMle mockFindVmmMle() {
String vmmName = "XEN";
String vmmVersion = "4.3";
String osName = "Fedora";
String osVersion = "20";
TblMle vmmMle = new TblMle();
vmmMle.setId(MLE_ID2);
vmmMle.setName(vmmName);
vmmMle.setVersion(vmmVersion);
vmmMle.setOemId(new TblOem());
TblOs os = new TblOs();
os.setId(1);
os.setName(osName);
os.setVersion(osVersion);
vmmMle.setOsId(os);
Collection<TblPcrManifest> tblPcrManifestCollectionVMM = new ArrayList<TblPcrManifest>();
TblPcrManifest tblPcrManifestVMM = new TblPcrManifest();
tblPcrManifestVMM.setId(2);
tblPcrManifestVMM.setName("18");
tblPcrManifestVMM.setValue("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
tblPcrManifestCollectionVMM.add(tblPcrManifestVMM);
vmmMle.setTblPcrManifestCollection(tblPcrManifestCollectionVMM);
return vmmMle;
}
use of com.intel.mtwilson.as.data.TblOs in project OpenAttestation by OpenAttestation.
the class MleBOTest method mockFindBiosMle.
public TblMle mockFindBiosMle() {
String biosName = "DELL";
String biosVersion = "A08";
String oemName = "DELL";
TblMle biosMle = new TblMle();
biosMle.setId(MLE_ID1);
biosMle.setName(biosName);
biosMle.setVersion(biosVersion);
TblOem oem = new TblOem();
oem.setId(1);
oem.setName(oemName);
biosMle.setOemId(oem);
biosMle.setOsId(new TblOs());
Collection<TblPcrManifest> tblPcrManifestCollection = new ArrayList<TblPcrManifest>();
TblPcrManifest tblPcrManifest = new TblPcrManifest();
tblPcrManifest.setId(1);
tblPcrManifest.setName("0");
tblPcrManifest.setValue("31B97D97B4679917EC3C1D943635693FFBAB4143");
tblPcrManifestCollection.add(tblPcrManifest);
biosMle.setTblPcrManifestCollection(tblPcrManifestCollection);
return biosMle;
}
use of com.intel.mtwilson.as.data.TblOs in project OpenAttestation by OpenAttestation.
the class MleBOTest method testAddMLe.
@Test
public void testAddMLe() {
TblMle biosMle = null;
TblMle vmmMle = null;
TblOem tblOem = new TblOem();
tblOem.setId(OEM_ID);
tblOem.setName("DELL");
TblOs tblOs = new TblOs(OS_ID, "Fedora", "20");
doReturn(tblOem).when(tblOemJpaController).findTblOemByName(anyString());
doReturn(tblOs).when(tblOsJpaController).findTblOsByNameVersion(anyString(), anyString());
doReturn(biosMle).when(tblMleJpaController).findBiosMle(anyString(), anyString(), anyString());
doReturn(vmmMle).when(tblMleJpaController).findVmmMle(anyString(), anyString(), anyString(), anyString());
List<ManifestData> biosManifestList = new ArrayList<ManifestData>();
biosManifestList.add(new ManifestData("0", "31B97D97B4679917EC3C1D943635693FFBAB4143"));
MleData biosMleData = new MleData("DELL", "A08", MleType.BIOS, AttestationType.PCR, biosManifestList, "", "", "", "DELL");
List<ManifestData> vmmManifestList = new ArrayList<ManifestData>();
vmmManifestList.add(new ManifestData("18", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"));
MleData vmmMleData = new MleData("XEN", "4.3", MleType.VMM, AttestationType.PCR, vmmManifestList, "", "Fedora", "20", "");
String biosResult = mleBO.addMLe(biosMleData);
assertEquals("true", biosResult);
String vmmResult = mleBO.addMLe(vmmMleData);
assertEquals("true", vmmResult);
}
use of com.intel.mtwilson.as.data.TblOs in project OpenAttestation by OpenAttestation.
the class OsBOTest method testUpdateOs.
@Test
public void testUpdateOs() {
TblOs tblOs = new TblOs(OS_ID1, "Fedora", "20");
doReturn(tblOs).when(tblOsJpaController).findTblOsByNameVersion(anyString(), anyString());
OsData osData = new OsData("Fedora", "20", "");
String result = osBO.updateOs(osData);
assertEquals("true", result);
}
Aggregations