Package com.intel.mountwilson.as.common

Examples of com.intel.mountwilson.as.common.ASException


                    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());       
                mleSourceJpaController.edit(mwMleSource);
               
            } catch (ASException ase) {
                    throw ase;
            } catch (Exception e) {
                throw new ASException(e);
            }                               
            return "true";
        }
View Full Code Here


                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());
               
            } catch (ASException ase) {
                    throw ase;
            } catch (Exception e) {
                throw new ASException(e);
            }                                     
            return "true";
        }
View Full Code Here

            for (Hostname host : hostNames) {
                TblHosts tblHosts = new TblHostsJpaController(getEntityManagerFactory()).findByName(host.toString()); // datatype.Hostname


                if (tblHosts == null) {
                    throw new ASException(ErrorCode.AS_HOST_NOT_FOUND, host);
                }

                List<TblTaLog> logs = new TblTaLogJpaController(getEntityManagerFactory()).findTrustStatusByHostId(tblHosts.getId(), 5);

                if (logs != null) {

                    for (TblTaLog log : logs) {
                        HostType hostType = new HostType();
                        hostType.setHostName(host.toString()); // datatype.Hostname
                        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);
        }

    }
View Full Code Here

                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";
                }
                else {
                    hostName = mwMleSource.getHostName();
                }
               
                return hostName;
               
            } catch (ASException ase) {
                    throw ase;
            } catch (Exception e) {
                throw new ASException(e);
            }                                               
        }
View Full Code Here

         */
        TblHosts tblHosts = null;
        try {
            tblHosts = new TblHostsJpaController(getEntityManagerFactory()).findByName(hostName.toString()); // datatype.Hostname
        } 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 = new TblTaLogJpaController(getEntityManagerFactory()).findLastStatusTs(tblHosts.getId());


View Full Code Here

        try {

            tblHosts = new TblHostsJpaController(getEntityManagerFactory()).findByName(hostName.toString());

            if (tblHosts == null) {
                throw new ASException(ErrorCode.AS_HOST_NOT_FOUND, hostName.toString());
            }

            // BUG #497 needs to use HostAgentFactory and HostAgent
            strategyFactory = new DefaultManifestStrategyFactory();

            manifestStrategy = strategyFactory.getManifestStategy(tblHosts, getEntityManagerFactory());
            pcrManifestMap = manifestStrategy.getManifest(tblHosts); // BUG #497  this is now obtained by IntelHostAgent using TAHelper's getQuoteInformationForHost which is what was called by TrustAgentManifestStrategy.getManifest()

        } catch (ASException aex) {

            throw aex;


        } catch (CryptographyException e) {
            throw new ASException(e, ErrorCode.AS_ENCRYPTION_ERROR, e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
        } catch (Exception ex) {

            throw new ASException(ex);
        }

        try {
            // XXX BUG #497 this entire section in try{}catch{} has  moved to TAHelper and used by IntelHostAgent
           
            // We need to check if the host supports TPM or not. Only way we can do it
            // using the host table contents is by looking at the AIK Certificate. Based
            // on this flag we generate the attestation report.
            boolean tpmSupport = true;
            String hostType = tblHosts.getVmmMleId().getName();

            if (tblHosts.getAIKCertificate() == null || tblHosts.getAIKCertificate().isEmpty()) {
                tpmSupport = false;
            }

           

            // xtw = xof.createXMLStreamWriter(new FileWriter("c:\\temp\\nb_xml.xml"));
            xtw = xof.createXMLStreamWriter(sw);
            xtw.writeStartDocument();
            xtw.writeStartElement("Host_Attestation_Report");
            xtw.writeAttribute("Host_Name", hostName.toString());
            xtw.writeAttribute("Host_VMM", hostType);
            xtw.writeAttribute("TXT_Support", String.valueOf(tpmSupport));

            if (tpmSupport == true) {
                ArrayList<IManifest> pcrMFList = new ArrayList<IManifest>();
                pcrMFList.addAll(pcrManifestMap.values());

                for (IManifest pcrInfo : pcrMFList) {
                    PcrManifest pInfo = (PcrManifest) pcrInfo;
                    xtw.writeStartElement("PCRInfo");
                    xtw.writeAttribute("ComponentName", String.valueOf(pInfo.getPcrNumber()));
                    xtw.writeAttribute("DigestValue", pInfo.getPcrValue().toUpperCase());
                    xtw.writeEndElement();
                }
            } else {
                xtw.writeStartElement("PCRInfo");
                xtw.writeAttribute("Error", "Host does not support TPM.");
                xtw.writeEndElement();
            }

            xtw.writeEndElement();
            xtw.writeEndDocument();
            xtw.flush();
            xtw.close();
            attestationReport = sw.toString();

        } catch (Exception ex) {

            throw new ASException(ex);
        }

        return attestationReport;
    }
View Full Code Here

        TblHosts tblHosts = null;
        try {
            tblHosts = new TblHostsJpaController(getEntityManagerFactory()).findByName(hostName.toString()); // datatype.Hostname
        } 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 = new TblTaLogJpaController(getEntityManagerFactory()).findLastStatusTs(tblHosts.getId());

View Full Code Here

                if (pcrManifest.getName().equals(manifestName)) {
                    return pcrManifest;
                }
            }
        }
        throw new ASException(ErrorCode.AS_PCR_MANIFEST_MISSING,manifestName,mleId,tblHosts.getName());
       
    }
View Full Code Here

        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());
        }

        return biosPcrList + "," + vmmPcrList;

    }
View Full Code Here

            int bytes_read = sockInput.read(buf);
            log.info( "Received " + bytes_read + " bytes to server and received them back again, msg = " +StringUtils.replace(new String(buf), "\n", "\n  "));
            return buf;
        }
        catch(SocketTimeoutException e){
            throw new ASException(e,ErrorCode.AS_TRUST_AGENT_CONNNECT_TIMED_OUT,serverHostname,serverPort,(TIME_OUT/1000));          
        }
        finally {
            sock.close();       
        }
    }
View Full Code Here

TOP

Related Classes of com.intel.mountwilson.as.common.ASException

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.