Package com.intel.mtwilson.as.data

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


  private void saveHostInDatabase(TblHosts newRecordWithTlsPolicyAndKeystore, TxtHost host, String certificate,
                                String location, HashMap<String, ? extends IManifest> pcrMap) throws CryptographyException {

                                //Building objects and validating that manifests are created ahead of create of host
                                TblHosts tblHosts = newRecordWithTlsPolicyAndKeystore; // new TblHosts();
                                log.info("saveHostInDatabase with tls policy {} and keystore size {}", tblHosts.getTlsPolicyName(), tblHosts.getTlsKeystore() == null ? "null" : tblHosts.getTlsKeystore().length);
                                log.error("saveHostInDatabase with tls policy {} and keystore size {}", tblHosts.getTlsPolicyName(), tblHosts.getTlsKeystore() == null ? "null" : tblHosts.getTlsKeystore().length);

                                TblHostsJpaController hostController = new TblHostsJpaController(
                                                getEntityManagerFactory());
                                tblHosts.setAddOnConnectionInfo(host.getAddOn_Connection_String());
                                tblHosts.setBiosMleId(biosMleId);
                                tblHosts.setDescription(host.getDescription());
                                tblHosts.setEmail(host.getEmail());
                                if (host.getIPAddress() != null) {
                                        tblHosts.setIPAddress(host.getIPAddress().toString()); // datatype.IPAddress
                                }
                                tblHosts.setName(host.getHostName().toString()); // datatype.Hostname

                                if (host.getPort() != null) {
                                        tblHosts.setPort(host.getPort());
                                }
                                tblHosts.setVmmMleId(vmmMleId);
                                tblHosts.setAIKCertificate(certificate); // null is ok

                                if (location != null) {
                                    tblHosts.setLocation(location);
                                }

                                // create the host
                                log.debug("COMMITING NEW HOST DO DATABASE");
                                hostController.create(tblHosts);
View Full Code Here


  public HostResponse isHostRegistered(String hostnameOrAddress) {
                                try {
                                    TblHostsJpaController tblHostsJpaController = new TblHostsJpaController(
                                                    getEntityManagerFactory());
                                    TblHosts tblHosts = tblHostsJpaController.findByName(hostnameOrAddress);
                                    if (tblHosts != null) {
                                            return new HostResponse(ErrorCode.OK); // host name exists in
                                                                                                                            // database
                                    }
                                    tblHosts = tblHostsJpaController.findByIPAddress(hostnameOrAddress);
View Full Code Here

  }

  private void checkForDuplicate(TxtHost host) throws CryptographyException {
    TblHostsJpaController tblHostsJpaController = new TblHostsJpaController(
        getEntityManagerFactory());
    TblHosts tblHosts1 = tblHostsJpaController.findByName(host.getHostName()
        .toString()); // datatype.Hostname
    TblHosts tblHosts2 = tblHostsJpaController.findByIPAddress(host.getIPAddress()
        .toString());
    if (tblHosts1 != null) {
      throw new ASException(
          ErrorCode.AS_HOST_EXISTS,
          host.getHostName());
View Full Code Here

         * @param hostName
         * @return
         * @throws CryptographyException
         */
  public TblHosts getHostByName(Hostname hostName) throws CryptographyException { // datatype.Hostname
    TblHosts tblHosts = new TblHostsJpaController(getEntityManagerFactory())
        .findByName(hostName.toString());
    return tblHosts;
  }
View Full Code Here

        .findByName(hostName.toString());
    return tblHosts;
  }

   public TblHosts getHostByIpAddress(String ipAddress) throws CryptographyException {
    TblHosts tblHosts = new TblHostsJpaController(getEntityManagerFactory())
        .findByIPAddress(ipAddress);
    return tblHosts;
  }
View Full Code Here

     */
    public HostTrustStatus getTrustStatus(Hostname hostName) {
        HashMap<String, ? extends IManifest> pcrManifestMap;
        HashMap<String, ? extends IManifest> gkvBiosPcrManifestMap, gkvVmmPcrManifestMap;
        if( hostName == null ) { throw new IllegalArgumentException("missing hostname"); }
        TblHosts tblHosts = null;
        try {
            tblHosts = getHostByIpAddress(InetAddress.getByName(hostName.toString()).getHostAddress());
        } catch (UnknownHostException e) {
            throw new ASException(e);
        }
        if (tblHosts == null) {
            throw new ASException(
                    ErrorCode.AS_HOST_NOT_FOUND,
                    hostName.toString());
        }
        log.info( "VMM name for host is {}", tblHosts.getVmmMleId().getName());
        log.info( "OS name for host is {}", tblHosts.getVmmMleId().getOsId().getName());

        // bug #538 first check if the host supports tpm
        HostAgentFactory factory = new HostAgentFactory();
        HostAgent agent = factory.getHostAgent(tblHosts);
        if( !agent.isTpmAvailable() ) {
            //Bug 510 add a blank row in the ta log for this host. this is so the host does not report mle's incorrectly. 
            logBlankTrustStatus(tblHosts);
            throw new ASException(ErrorCode.AS_INTEL_TXT_NOT_ENABLED, hostName.toString());
        }
       
        IManifestStrategy manifestStrategy;
        IManifestStrategyFactory strategyFactory;

        strategyFactory = new DefaultManifestStrategyFactory();

        manifestStrategy = strategyFactory.getManifestStategy(tblHosts, getEntityManagerFactory());

        try {
            long start = System.currentTimeMillis();
           
            pcrManifestMap = manifestStrategy.getManifest(tblHosts);
           
            log.info("Manifest Time {}", (System.currentTimeMillis() - start));
           
        } catch (ASException e) {
            throw e;
        } catch (Exception e) {
            throw new ASException(e);
        }
        long start = System.currentTimeMillis();
        log.info("PCRS from the VMM host {}", pcrManifestMap);

        /**
         * Get GKV for the given host
     *
         */
        IGKVStrategy gkvStrategy = new DefaultGKVStrategyFactory().getGkStrategy(tblHosts);

        gkvBiosPcrManifestMap = gkvStrategy.getBiosGoodKnownManifest(tblHosts.getBiosMleId().getName(),
                tblHosts.getBiosMleId().getVersion(), tblHosts.getBiosMleId().getOemId().getName());

        gkvVmmPcrManifestMap = gkvStrategy.getVmmGoodKnownManifest(tblHosts.getVmmMleId().getName(),
                tblHosts.getVmmMleId().getVersion(), tblHosts.getVmmMleId().getOsId().getName(), tblHosts.getVmmMleId().getOsId().getVersion(),
                tblHosts.getId());

        /**
         * Verify trust
     *
         */
 
View Full Code Here

     * @param hostName
     * @return {@link HostLocation}
     */
    public HostLocation getHostLocation(Hostname hostName) {
        try {
            TblHosts tblHosts = getHostByName(hostName);

            if (tblHosts == null) {
                throw new ASException(
                        ErrorCode.AS_HOST_NOT_FOUND,
                        String.format(
                        "%s",
                        hostName));
            }

            HostLocation location = new HostLocation(tblHosts.getLocation());
            return location;
        } catch (ASException e) {
            throw e;
        } catch (Exception e) {
            throw new ASException(e);
View Full Code Here

    public HostTrust getTrustWithCache(String host, Boolean forceVerify) {
        log.info("Getting trust for host: " + host + " Force verify flag: " + forceVerify);
        try {
           
            if(forceVerify != true){
                TblHosts tblHosts = getHostByName(new Hostname(host));
                if(tblHosts != null){
                    TblTaLog tblTaLog = new TblTaLogJpaController(getEntityManagerFactory()).getHostTALogEntryBefore(
                            tblHosts.getId() , getCacheStaleAfter() );
                   
                    if(tblTaLog != null)
                        return getHostTrustObj(tblTaLog);
                }else{
                    throw new ASException(
View Full Code Here


        try {
            HostsTrustReportType hostsTrustReportType = new HostsTrustReportType();
            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();
View Full Code Here

         * if (hostName == null || hostName.isEmpty()) { throw new
         * ASException(ErrorCode.VALIDATION_ERROR, "Input Hostname " + hostName
         * + " is empty."); }
         *
         */
        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) {
                    ManifestType manifest = new ManifestType();
View Full Code Here

TOP

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

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.