Package com.intel.mtwilson.as.data

Examples of com.intel.mtwilson.as.data.TblMle


         * @return
         */
  public String deletePCRWhiteList(String pcrName, String mleName, String mleVersion, String osName,
      String osVersion, String oemName) {
                                TblPcrManifest tblPcr;
                                TblMle tblMle;
                                try {
                                  tblMle = getMleDetails(mleName, mleVersion, osName, osVersion,oemName);
                                  if (tblMle == null && oemName != null) {
                                        throw new ASException(ErrorCode.WS_MLE_OEM_DOES_NOT_EXIST, mleName, mleVersion, oemName);
                                    }
                                    if (tblMle == null && osName != null) {
                                        throw new ASException(ErrorCode.WS_MLE_OS_DOES_NOT_EXIST, mleName, mleVersion, osName, osVersion);
                                    }
                                   
                                    // Now we need to check if PCR value exists. If it does, then we do delete or else
                                    // we still return true since the data does not exist.
                                    tblPcr = getPCRWhiteListDetails(tblMle.getId(), pcrName);
                                    if (tblPcr == null) {
                                      return "true";
                                    }

                                    // Delete the PCR white list entry.
View Full Code Here


         *
         * @param mleSourceObj : Object containing the details of the host and the MLE.
         * @return True or False
         */
        public String addMleSource(MleSource mleSourceObj) {
                                TblMle tblMle;
                                MleData mleData = null;
                                try {

                                    try {
                                        mleData = mleSourceObj.getMleData();
                                        // Verify if the MLE exists in the system.
                                        tblMle = getMleDetails(mleData.getName(), mleData.getVersion(), mleData.getOsName(),
                                                        mleData.getOsVersion(), mleData.getOemName());
                                    } catch (NoResultException nre){
                                        throw new ASException(nre,ErrorCode.WS_MLE_DOES_NOT_EXIST, mleData.getName(), mleData.getVersion());
                                    }

                                    MwMleSourceJpaController mleSourceJpaController = new MwMleSourceJpaController(getEntityManagerFactory());

                                    // Let us check if there is a mapping entry already for this MLE. If it does, then we need to return
                                    // back appropriate error.
                                    MwMleSource mleSourceCurrentObj = mleSourceJpaController.findByMleId(tblMle.getId());

                                    if (mleSourceCurrentObj != null) {
                                        log.error("White List host is already mapped to the MLE - " + tblMle.getName());
                                        throw new ASException(ErrorCode.WS_MLE_SOURCE_MAPPING_ALREADY_EXISTS, mleData.getName());
                                    }

                                    // Else create a new entry in the DB.
                                    MwMleSource mleSourceData = new MwMleSource();
View Full Code Here

         * Updates an existing MLE with the name of the white list host that was used to modify the white list values.
         * @param mleSourceObj
         * @return
         */
        public String updateMleSource(MleSource mleSourceObj) {
            TblMle tblMle;
            MleData mleData = null;
            try {

                try {
                    mleData = mleSourceObj.getMleData();
                    // Verify if the MLE exists in the system.
                    tblMle = getMleDetails(mleData.getName(), mleData.getVersion(), mleData.getOsName(),
                                    mleData.getOsVersion(), mleData.getOemName());
                } catch (NoResultException nre){
                    throw new ASException(nre,ErrorCode.WS_MLE_DOES_NOT_EXIST, mleData.getName(), mleData.getVersion());
                }
                               
                MwMleSourceJpaController mleSourceJpaController = new MwMleSourceJpaController(getEntityManagerFactory());
                // If the mapping does not exist already in the db, then we need to return back error.
                MwMleSource mwMleSource = mleSourceJpaController.findByMleId(tblMle.getId());
                if (mwMleSource == null) {
                    throw new ASException(ErrorCode.WS_MLE_SOURCE_MAPPING_DOES_NOT_EXIST, mleData.getName());
                }
               
                mwMleSource.setHostName(mleSourceObj.getHostName());       
View Full Code Here

         * @param osVersion
         * @param oemName
         * @return
         */
        public String deleteMleSource(String mleName, String mleVersion, String osName, String osVersion, String oemName) {
            TblMle tblMle;
            try {
               
                try {
                    // First check if the entry exists in the MLE table.
                    tblMle = getMleDetails(mleName, mleVersion, osName, osVersion, oemName);

                } catch (NoResultException nre){
                    throw new ASException(nre,ErrorCode.WS_MLE_DOES_NOT_EXIST, mleName, mleVersion);
                }
                               
                MwMleSourceJpaController mleSourceJpaController = new MwMleSourceJpaController(getEntityManagerFactory());
                MwMleSource mwMleSource = mleSourceJpaController.findByMleId(tblMle.getId());
                // If the mapping does not exist, it is ok. We don't need to worry. Actually for MLES
                // configured manully, this entry does not exist.
                if  (mwMleSource != null)                               
                    mleSourceJpaController.destroy(mwMleSource.getId());
               
View Full Code Here

         * @param osVersion
         * @param oemName
         * @return
         */
        public String getMleSource(String mleName, String mleVersion, String osName, String osVersion, String oemName) {
            TblMle tblMle;
            String hostName = null;
            try {
               
                try {
                    // First check if the entry exists in the MLE table.
                    tblMle = getMleDetails(mleName, mleVersion, osName, osVersion, oemName);

                } catch (NoResultException nre){
                    throw new ASException(nre,ErrorCode.WS_MLE_DOES_NOT_EXIST, mleName, mleVersion);
                }
                               
                MwMleSourceJpaController mleSourceJpaController = new MwMleSourceJpaController(getEntityManagerFactory());
                MwMleSource mwMleSource = mleSourceJpaController.findByMleId(tblMle.getId());
               
                // Now check if the data exists in the MLE Source table. If there is no corresponding entry, then we know that
                // the MLE was configured manually.
                if (mwMleSource == null) {
                    hostName = "Manually configured white list";
View Full Code Here

 
    private String getPcrList(TblHosts tblHosts) {
       
        // Get the Bios MLE without accessing cache
       
        TblMle biosMle = new TblMleJpaController(getEntityManagerFactory()).findMleById(tblHosts.getBiosMleId().getId());
       
        String biosPcrList = biosMle.getRequiredManifestList();

        if (biosPcrList.isEmpty()) {
            throw new ASException(ErrorCode.AS_MISSING_MLE_REQD_MANIFEST_LIST, tblHosts.getBiosMleId().getName(), tblHosts.getBiosMleId().getVersion());
        }

        // Get the Vmm MLE without accessing cache
        TblMle vmmMle = new TblMleJpaController(getEntityManagerFactory()).findMleById(tblHosts.getVmmMleId().getId());

        String vmmPcrList = vmmMle.getRequiredManifestList();

        if (vmmPcrList == null || vmmPcrList.isEmpty()) {
            throw new ASException(ErrorCode.AS_MISSING_MLE_REQD_MANIFEST_LIST, tblHosts.getVmmMleId().getName(), tblHosts.getVmmMleId().getVersion());
        }
View Full Code Here

    public void create(TblHosts tblHosts) throws CryptographyException {
        log.debug("create tblHosts with policy {} and keystore length {}", tblHosts.getTlsPolicyName(), tblHosts.getTlsKeystore() == null ? "null" : tblHosts.getTlsKeystore().length);
        EntityManager em = getEntityManager();
        try {
            em.getTransaction().begin();
            TblMle vmmMleId = tblHosts.getVmmMleId();
            if (vmmMleId != null) {
                vmmMleId = em.getReference(vmmMleId.getClass(), vmmMleId.getId());
                tblHosts.setVmmMleId(vmmMleId);
            }
            TblMle biosMleId = tblHosts.getBiosMleId();
            if (biosMleId != null) {
                biosMleId = em.getReference(biosMleId.getClass(), biosMleId.getId());
                tblHosts.setBiosMleId(biosMleId);
            }
           
            // encrypt addon connection string, persist, then restore the plaintext
            String addOnConnectionString = tblHosts.getAddOnConnectionInfo();
            if( addOnConnectionString != null ) {
                em.persist(tblHosts);
            }
            else {
                log.debug("saving without encrypting connection string");
                em.persist(tblHosts);
            }
           
            if (vmmMleId != null) {
                vmmMleId.getTblHostsCollection().add(tblHosts);
                em.merge(vmmMleId);
            }
            if (biosMleId != null) {
                biosMleId.getTblHostsCollection().add(tblHosts);
                em.merge(biosMleId);
            }
            em.getTransaction().commit();
        } finally {
            em.close();
View Full Code Here

    public void edit(TblHosts tblHosts) throws IllegalOrphanException, NonexistentEntityException, ASDataException {
        EntityManager em = getEntityManager();
        try {
            em.getTransaction().begin();
            TblHosts persistentTblHosts = em.find(TblHosts.class, tblHosts.getId());
            TblMle vmmMleIdOld = persistentTblHosts.getVmmMleId();
            TblMle vmmMleIdNew = tblHosts.getVmmMleId();
            TblMle biosMleIdOld = persistentTblHosts.getBiosMleId();
            TblMle biosMleIdNew = tblHosts.getBiosMleId();
            if (vmmMleIdNew != null) {
                vmmMleIdNew = em.getReference(vmmMleIdNew.getClass(), vmmMleIdNew.getId());
                tblHosts.setVmmMleId(vmmMleIdNew);
            }
            if (biosMleIdNew != null) {
                biosMleIdNew = em.getReference(biosMleIdNew.getClass(), biosMleIdNew.getId());
                tblHosts.setBiosMleId(biosMleIdNew);
            }

            // encrypt addon connection string, persist, then restore the plaintext
            String addOnConnectionString = tblHosts.getAddOnConnectionInfo();
            if( addOnConnectionString != null ) {
                tblHosts = em.merge(tblHosts);
            }
            else {
                tblHosts = em.merge(tblHosts);
            }
           
            if (vmmMleIdOld != null && !vmmMleIdOld.equals(vmmMleIdNew)) {
                vmmMleIdOld.getTblHostsCollection().remove(tblHosts);
                vmmMleIdOld = em.merge(vmmMleIdOld);
            }
            if (vmmMleIdNew != null && !vmmMleIdNew.equals(vmmMleIdOld)) {
                vmmMleIdNew.getTblHostsCollection().add(tblHosts);
                em.merge(vmmMleIdNew);
            }
            if (biosMleIdOld != null && !biosMleIdOld.equals(biosMleIdNew)) {
                biosMleIdOld.getTblHostsCollection().remove(tblHosts);
                biosMleIdOld = em.merge(biosMleIdOld);
            }
            if (biosMleIdNew != null && !biosMleIdNew.equals(biosMleIdOld)) {
                biosMleIdNew.getTblHostsCollection().add(tblHosts);
                em.merge(biosMleIdNew);
            }
            em.getTransaction().commit();
        } catch (Exception ex) {
            String msg = ex.getLocalizedMessage();
View Full Code Here

                tblHosts = em.getReference(TblHosts.class, id);
                tblHosts.getId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The tblHosts with id " + id + " no longer exists.", enfe);
            }
            TblMle vmmMleId = tblHosts.getVmmMleId();
            if (vmmMleId != null) {
                vmmMleId.getTblHostsCollection().remove(tblHosts);
                em.merge(vmmMleId);
            }
            TblMle biosMleId = tblHosts.getBiosMleId();
            if (biosMleId != null) {
                biosMleId.getTblHostsCollection().remove(tblHosts);
                em.merge(biosMleId);
            }
            em.remove(tblHosts);
            em.getTransaction().commit();
        } finally {
View Full Code Here

                attachedTblPcrManifestCollection.add(tblPcrManifestCollectionTblPcrManifestToAttach);
            }
            tblMle.setTblPcrManifestCollection(attachedTblPcrManifestCollection);
            em.persist(tblMle);
            for (TblHosts tblHostsCollectionTblHosts : tblMle.getTblHostsCollection()) {
                TblMle oldVmmMleIdOfTblHostsCollectionTblHosts = tblHostsCollectionTblHosts.getVmmMleId();
                tblHostsCollectionTblHosts.setVmmMleId(tblMle);
                tblHostsCollectionTblHosts = em.merge(tblHostsCollectionTblHosts);
                if (oldVmmMleIdOfTblHostsCollectionTblHosts != null) {
                    oldVmmMleIdOfTblHostsCollectionTblHosts.getTblHostsCollection().remove(tblHostsCollectionTblHosts);
                    em.merge(oldVmmMleIdOfTblHostsCollectionTblHosts);
                }
            }
            for (TblHosts tblHostsCollection1TblHosts : tblMle.getTblHostsCollection1()) {
                TblMle oldBiosMleIdOfTblHostsCollection1TblHosts = tblHostsCollection1TblHosts.getBiosMleId();
                tblHostsCollection1TblHosts.setBiosMleId(tblMle);
                tblHostsCollection1TblHosts = em.merge(tblHostsCollection1TblHosts);
                if (oldBiosMleIdOfTblHostsCollection1TblHosts != null) {
                    oldBiosMleIdOfTblHostsCollection1TblHosts.getTblHostsCollection1().remove(tblHostsCollection1TblHosts);
                    em.merge(oldBiosMleIdOfTblHostsCollection1TblHosts);
                }
            }
            for (TblPcrManifest tblPcrManifestCollectionTblPcrManifest : tblMle.getTblPcrManifestCollection()) {
                TblMle oldMleIdOfTblPcrManifestCollectionTblPcrManifest = tblPcrManifestCollectionTblPcrManifest.getMleId();
                tblPcrManifestCollectionTblPcrManifest.setMleId(tblMle);
                tblPcrManifestCollectionTblPcrManifest = em.merge(tblPcrManifestCollectionTblPcrManifest);
                if (oldMleIdOfTblPcrManifestCollectionTblPcrManifest != null) {
                    oldMleIdOfTblPcrManifestCollectionTblPcrManifest.getTblPcrManifestCollection().remove(tblPcrManifestCollectionTblPcrManifest);
                    em.merge(oldMleIdOfTblPcrManifestCollectionTblPcrManifest);
                }
            }
            em.getTransaction().commit();
        } finally {
View Full Code Here

TOP

Related Classes of com.intel.mtwilson.as.data.TblMle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.