Examples of TblHosts


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

        XMLStreamWriter xtw;
        StringWriter sw = new StringWriter();
        IManifestStrategy manifestStrategy;
        IManifestStrategyFactory strategyFactory;
        HashMap<String, ? extends IManifest> pcrManifestMap = null;
        TblHosts tblHosts = null;
        String attestationReport = "";

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

           
View Full Code Here

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

    public AttestationReport getAttestationReport(Hostname hostName, Boolean failureOnly) {

        AttestationReport attestationReport = new AttestationReport();

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


        if (lastStatusTs != null) {
            List<TblTaLog> logs = new TblTaLogJpaController(getEntityManagerFactory()).findLogsByHostId(tblHosts.getId(), lastStatusTs);
            com.intel.mountwilson.as.hostmanifestreport.data.HostType hostType = new com.intel.mountwilson.as.hostmanifestreport.data.HostType();
            hostType.setName(hostName.toString()); // datatype.Hostname
            if (logs != null) {
                for (TblTaLog log : logs) {
                    boolean value = (failureOnly && log.getTrustStatus() == false);
View Full Code Here

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

    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);
            }
View Full Code Here

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

    public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
        EntityManager em = getEntityManager();
        try {
            em.getTransaction().begin();
            TblHosts tblHosts;
            try {
                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);
View Full Code Here

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

    }

    public TblHosts findTblHosts(Integer id) {
        EntityManager em = getEntityManager();
        try {
            TblHosts result = em.find(TblHosts.class, id);
            return result;
        } finally {
            em.close();
        }
    }
View Full Code Here

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

        }
    }

    public TblHosts findByName(String name) {

        TblHosts host = null;
        EntityManager em = getEntityManager();
        try {

            Query query = em.createNamedQuery("TblHosts.findByName");
View Full Code Here

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

    }

      public TblHosts findByIPAddress(String ipAddress) {

        TblHosts host = null;
        EntityManager em = getEntityManager();
        try {
            Query query = em.createNamedQuery("TblHosts.findByIPAddress");

            query.setParameter("iPAddress", ipAddress);
View Full Code Here

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

                                            throw new ASException(ErrorCode.AS_HOST_IPADDRESS_NOT_MATCHED, host.getHostName().toString(),host.getIPAddress().toString());
                                        }
                                        checkForDuplicate(host);
                                        getBiosAndVMM(host);
                                        log.info("Getting Server Identity.");
                                                    TblHosts tblHosts = new TblHosts();
                                                    tblHosts.setTlsPolicyName("TRUST_FIRST_CERTIFICATE");
                                                    tblHosts.setTlsKeystore(null);
                                                    log.debug("stdalex addHost cs == " + host.getAddOn_Connection_String());
                                                    tblHosts.setAddOnConnectionInfo(host.getAddOn_Connection_String());
                                                    if( host.getHostName() != null ) { tblHosts.setName(host.getHostName().toString()); }
                                                    if( host.getIPAddress() != null ) { tblHosts.setIPAddress(host.getIPAddress().toString()); }
                                                    if( host.getPort() != null ) { tblHosts.setPort(host.getPort()); }

                                                    if (canFetchAIKCertificateForHost(host.getVmm().getName())) { // datatype.Vmm
                                                        if(!host.getAddOn_Connection_String().toLowerCase().contains("citrix")){
                                                            certificate = getAIKCertificateForHost(tblHosts, host);
                               // we have to check that the aik certificate was signed by a trusted privacy ca
                              X509Certificate hostAikCert = X509Util.decodePemCertificate(certificate);
                              hostAikCert.checkValidity();
                              // read privacy ca certificate
                              InputStream privacyCaIn = new FileInputStream(ResourceFinder.getFile("PrivacyCA.cer")); // XXX TODO currently we only support one privacy CA cert... in the future we should read a PEM format file with possibly multiple trusted privacy ca certs
                              X509Certificate privacyCaCert = X509Util.decodeDerCertificate(IOUtils.toByteArray(privacyCaIn));
                              IOUtils.closeQuietly(privacyCaIn);
                              privacyCaCert.checkValidity();
                              // verify the trusted privacy ca signed this aik cert
                              hostAikCert.verify(privacyCaCert.getPublicKey()); // NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
                                                        }
                                                   }
                                                    else { // ESX host so get the location for the host and store in the
                                                                    // table
                                                        pcrMap = getHostPcrManifest(tblHosts, host); // BUG #497 sending both the new TblHosts record and the TxtHost object just to get the TlsPolicy into the initial call so that with the trust_first_certificate policy we will obtain the host certificate now while adding it
                                                        log.info("Getting location for host from VCenter");
                                                        location = getLocation(pcrMap);
                                                    }
                                                    log.info("Saving Host in database with TlsPolicyName {} and TlsKeystoreLength {}", tblHosts.getTlsPolicyName(), tblHosts.getTlsKeystore() == null ? "null" : tblHosts.getTlsKeystore().length);
                                                    log.debug("Saving the host details in the DB");
                                                    saveHostInDatabase(tblHosts, host, certificate, location, pcrMap);

                                            } catch (ASException ase) {
                                                    throw ase;
View Full Code Here

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

  public String updateHost(TxtHost host) {
               
                                try {

                                        TblHosts tblHosts = getHostByName(host.getHostName()); // datatype.Hostname
                                        if (tblHosts == null) {
                                                throw new ASException(ErrorCode.AS_HOST_NOT_FOUND,host.getHostName().toString());
                                        }

                                        getBiosAndVMM(host);

                                        // need to update with the new connection string before we attempt to connect to get any updated info from host (aik cert, manifest, etc)
                                        if( tblHosts.getTlsPolicyName() == null && tblHosts.getTlsPolicyName().isEmpty() ) { // XXX new code to test
                                            tblHosts.setTlsPolicyName("TRUST_FIRST_CERTIFICATE"); // XXX  bug #497  the TxtHost object doesn't have the ssl certificate and policy
                                        }
                                        tblHosts.setAddOnConnectionInfo(host.getAddOn_Connection_String());
                                        if( host.getHostName() != null ) { tblHosts.setName(host.getHostName().toString()); }
                                        if( host.getIPAddress() != null ) { tblHosts.setIPAddress(host.getIPAddress().toString()); }
                                        if( host.getPort() != null ) { tblHosts.setPort(host.getPort()); }

                                        log.info("Getting identity.");
                                        if (canFetchAIKCertificateForHost(host.getVmm().getName())) { // datatype.Vmm
                                                String certificate = getAIKCertificateForHost(tblHosts, host);
                                                tblHosts.setAIKCertificate(certificate);
                                        }else { // ESX host so get the location for the host and store in the
                                            if(vmmMleId.getId().intValue() != tblHosts.getVmmMleId().getId().intValue() ){
                                                log.info("VMM is updated. Update the host specific manifest");

                                                HashMap<String, ? extends IManifest> pcrMap = getHostPcrManifest(tblHosts,host); // BUG #497 added tblHosts parameter
                                                //Building objects and validating that manifests are created ahead of create of host

                                            }
                                        }

                                        log.info("Saving Host in database");
                                        tblHosts.setBiosMleId(biosMleId);
                                        tblHosts.setDescription(host.getDescription());
                                        tblHosts.setEmail(host.getEmail());
                                        if (host.getIPAddress() != null)
                                                tblHosts.setIPAddress(host.getIPAddress().toString()); // datatype.IPAddress
                                        tblHosts.setPort(host.getPort());
                                        tblHosts.setVmmMleId(vmmMleId);

                                        log.info("Updating Host in database");
                                        new TblHostsJpaController(getEntityManagerFactory()).edit(tblHosts);

View Full Code Here

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

  }

  public String deleteHost(Hostname hostName) { // datatype.Hostname
       
                                try {
                                        TblHosts tblHosts = getHostByName(hostName);
                                        if (tblHosts == null) {
                                                throw new ASException(ErrorCode.AS_HOST_NOT_FOUND, hostName);
                                        }
                                        log.info("Deleting Host from database");



                                        deleteTALogs(tblHosts.getId());


                                        new TblHostsJpaController(getEntityManagerFactory())
                                                        .destroy(tblHosts.getId());
                                } catch (ASException ase) {
                                        throw ase;
                                }
                                catch(CryptographyException e) {
                                    throw new ASException(ErrorCode.SYSTEM_ERROR, e.getCause() == null ? e.getMessage() : e.getCause().getMessage(), e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.