Search in sources :

Example 31 with ASException

use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.

the class MleBO method findMle.

/**
    * 
    * @param mleName
    * @param mleVersion
    * @param osName
    * @param osVersion
    * @param oemName
    * @return 
    */
public MleData findMle(String mleName, String mleVersion, String osName, String osVersion, String oemName) {
    try {
        TblMle tblMle = getMleDetails(mleName, mleVersion, osName, osVersion, oemName);
        if (tblMle == null) {
            throw new ASException(ErrorCode.WS_MLE_DOES_NOT_EXIST, mleName, mleVersion);
        }
        MleData mleData = createMleDataFromDatabaseRecord(tblMle, true);
        return mleData;
    } catch (ASException ase) {
        throw ase;
    } catch (Exception e) {
        throw new ASException(e);
    }
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) MleData(com.intel.mtwilson.datatypes.MleData) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) NoResultException(javax.persistence.NoResultException) ASDataException(com.intel.mtwilson.as.controller.exceptions.ASDataException) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) IllegalOrphanException(com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)

Example 32 with ASException

use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.

the class MleBO method updatePCRWhiteList.

/**
         * Added By: Sudhir on June 20, 2012
         * 
         * Processes the update request for an existing PCR white list for the specified MLE.
         * 
         * @param pcrData: White list data sent by the user
         * @return : true if the call is successful or else exception.
         */
public String updatePCRWhiteList(PCRWhiteList pcrData) {
    TblMle tblMle;
    TblPcrManifest tblPcr;
    try {
        tblMle = getMleDetails(pcrData.getMleName(), pcrData.getMleVersion(), pcrData.getOsName(), pcrData.getOsVersion(), pcrData.getOemName());
        if (tblMle == null && pcrData.getOemName() != null) {
            throw new ASException(ErrorCode.WS_MLE_OEM_DOES_NOT_EXIST, pcrData.getMleName(), pcrData.getMleVersion(), pcrData.getOemName());
        }
        if (tblMle == null && pcrData.getOsName() != null) {
            throw new ASException(ErrorCode.WS_MLE_OS_DOES_NOT_EXIST, pcrData.getMleName(), pcrData.getMleVersion(), pcrData.getOsName(), pcrData.getOsVersion());
        }
        // Now we need to check if PCR is already configured. If yes, then
        // we ned to ask the user to use the Update option instead of create
        tblPcr = getPCRWhiteListDetails(tblMle.getId(), pcrData.getPcrName());
        if (tblPcr == null) {
            throw new ASException(ErrorCode.WS_PCR_WHITELIST_DOES_NOT_EXIST, pcrData.getPcrName());
        }
        // Now update the pcr in the database.
        tblPcr.setValue(pcrData.getPcrDigest());
        pcrManifestJpaController.edit(tblPcr);
    } catch (ASException ase) {
        throw ase;
    } catch (Exception e) {
        throw new ASException(e);
    }
    return "true";
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) NoResultException(javax.persistence.NoResultException) ASDataException(com.intel.mtwilson.as.controller.exceptions.ASDataException) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) IllegalOrphanException(com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)

Example 33 with ASException

use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.

the class OemBO method updateOem.

/**
     * 
     * @param oemData
     * @return 
     */
public String updateOem(OemData oemData) {
    try {
        TblOem tblOem = tblOemJpaController.findTblOemByName(oemData.getName());
        if (tblOem == null)
            throw new ASException(ErrorCode.WS_OEM_DOES_NOT_EXIST, oemData.getName());
        tblOem.setDescription(oemData.getDescription());
        tblOemJpaController.edit(tblOem);
    } catch (ASException ase) {
        throw ase;
    } catch (Exception e) {
        throw new ASException(e);
    }
    return "true";
}
Also used : TblOem(com.intel.mtwilson.as.data.TblOem) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException)

Example 34 with ASException

use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.

the class OsBO method createOs.

/**
     * 
     * @param osData
     * @return 
     */
public String createOs(OsData osData, String uuid) {
    try {
        TblOs tblOs = tblOsJpaController.findTblOsByNameVersion(osData.getName(), osData.getVersion());
        if (tblOs != null) {
            throw new ASException(ErrorCode.WS_OS_ALREADY_EXISTS, osData.getName(), osData.getVersion());
        }
        tblOs = new TblOs();
        tblOs.setName(osData.getName());
        tblOs.setVersion(osData.getVersion());
        tblOs.setDescription(osData.getDescription());
        if (uuid != null && !uuid.isEmpty()) {
            tblOs.setUuid_hex(uuid);
        } else {
            tblOs.setUuid_hex(new UUID().toString());
        }
        tblOsJpaController.create(tblOs);
    } catch (ASException ase) {
        throw ase;
    } catch (Exception e) {
        throw new ASException(e);
    }
    return "true";
}
Also used : UUID(com.intel.mtwilson.util.io.UUID) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) TblOs(com.intel.mtwilson.as.data.TblOs)

Example 35 with ASException

use of com.intel.mountwilson.as.common.ASException 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";
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) TblOs(com.intel.mtwilson.as.data.TblOs)

Aggregations

ASException (com.intel.mountwilson.as.common.ASException)69 IOException (java.io.IOException)28 CryptographyException (com.intel.mtwilson.crypto.CryptographyException)26 IllegalOrphanException (com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)20 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)20 TblMle (com.intel.mtwilson.as.data.TblMle)20 NoResultException (javax.persistence.NoResultException)19 UnknownHostException (java.net.UnknownHostException)18 TblHosts (com.intel.mtwilson.as.data.TblHosts)17 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)14 ASDataException (com.intel.mtwilson.as.controller.exceptions.ASDataException)12 KeyManagementException (java.security.KeyManagementException)10 MwAssetTagCertificate (com.intel.mtwilson.as.data.MwAssetTagCertificate)9 SignatureException (java.security.SignatureException)8 CertificateException (java.security.cert.CertificateException)8 WebApplicationException (javax.ws.rs.WebApplicationException)8 ConfigurationException (org.apache.commons.configuration.ConfigurationException)8 ApiException (com.intel.mtwilson.ApiException)7 MwAssetTagCertificateJpaController (com.intel.mtwilson.as.controller.MwAssetTagCertificateJpaController)7 TblMleJpaController (com.intel.mtwilson.as.controller.TblMleJpaController)7