Changeset 452

Show
Ignore:
Timestamp:
02/16/07 16:35:20 (2 years ago)
Author:
sacha
Message:

cpa reading certificates and trust anchors
providing a runtime location for certificates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/branch-https-dev/bin/debian-base-hefeweizen-installation.sh

    r450 r452  
    44 
    55echo "some handy tools" 
    6 apt-get install -y ssh screen less openssl 
     6apt-get install -y ssh screen less emacs21 
    77 
    88echo "install HefeWeizen debian package dependencies" 
    9 apt-get install -y uuid wget bzip2 xmlstarlet ruby libopenssl-ruby gcc make perl-modules libgmime-2.0-2 libgmime-2.0-2-dev libxml2 libxml2-dev libxmlsec1 libxmlsec1-dev libxmlsec1-openssl subversion hwinfo rubygems  
     9apt-get install -y uuid wget openssl bzip2 xmlstarlet ruby libopenssl-ruby gcc make perl-modules libgmime-2.0-2 libgmime-2.0-2-dev libxml2 libxml2-dev libxmlsec1 libxmlsec1-dev libxmlsec1-openssl subversion hwinfo rubygems  
    1010 
    1111echo "install HefeWeizen ruby gems dependencies" 
  • branches/branch-https-dev/bin/run-check-dependencies.sh

    r356 r452  
    4343else 
    4444    echo "The http client wget is not available. Please install that package first." 
     45    exit -1 
     46fi 
     47 
     48which openssl 1>/dev/null 
     49if [ $? -eq 0 ]; then 
     50    echo "openssl binary is available. good." 
     51else 
     52    echo "The openssl tool is not available. Please install that package first." 
    4553    exit -1 
    4654fi 
  • branches/branch-https-dev/defaults/hefeweizen-defaults

    r297 r452  
    2323CONVERSATION_DIR=/var/run/hefeweizen/conversations 
    2424DIRECTIVE_DIR=/var/run/hefeweizen/directives 
     25CPA_DIR=/var/run/hefeweizen/cpas 
    2526SPOOL_DIR=/var/spool/hefeweizen 
    2627TRANSACTION_DIR=/var/run/hefeweizen/transactions 
  • branches/branch-https-dev/src/hefeweizen_library_cpa.rb

    r451 r452  
    5454          return nil 
    5555        end 
     56      end 
     57 
     58      # Setting up the certificate locations for this CPA. 
     59      # These locations will be used at run time. 
     60      # First usecase is SSL trust anchors. 
     61      def create_certificate_locations party_name, cpa_runtime_dir 
     62        # this party 
     63        # get trust anchors -> will be needed for SSL client to validate 
     64        #                      server SSL certificate against 
     65        this_party_info = nil 
     66        if party_name == @xml_cpa.partyInfo.first.xmlattr_partyName then 
     67          this_party_info = @xml_cpa.partyInfo[0] 
     68          other_party_info = @xml_cpa.partyInfo[1] 
     69        else 
     70          this_party_info = @xml_cpa.partyInfo[1] 
     71          other_party_info = @xml_cpa.partyInfo[0] 
     72        end 
     73         
     74        if this_party_info.respond_to? "securityDetails" then 
     75          sec_details = this_party_info.securityDetails.class == Array ? this_party_info.securityDetails : [this_party_info.securityDetails] 
     76          sec_details.each{ | sec_detail | 
     77            security_id = sec_detail.xmlattr_securityId 
     78            new_dir = "#{cpa_runtime_dir}/#{security_id}" 
     79            FileUtils.mkdir new_dir 
     80            # adding individual certificates 
     81            if sec_detail.trustAnchors.respond_to? "anchorCertificateRef" then 
     82              anchors = sec_detail.trustAnchors.anchorCertificateRef.class == Array ? sec_detail.trustAnchors.anchorCertificateRef : [sec_detail.trustAnchors.anchorCertificateRef] 
     83              anchors.each{ | anchor | 
     84                cert_id = anchor.xmlattr_certId 
     85                add_pem_cert_to_dir new_dir, cert_id 
     86              } 
     87              # TODO a system command 
     88              # Not criticial right here. 
     89              command = "c_rehash #{cpa_runtime_dir}/#{security_id}" 
     90              system command 
     91            end 
     92          } 
     93 
     94        end 
     95 
     96        # other party 
     97        if other_party_info.respond_to? "certificate" then 
     98          certs = other_party_info.certificate.class == Array ? other_party_info.certificate : [other_party_info.certificate] 
     99          certs.each{ | cert | 
     100            cert_id = cert.xmlattr_certId 
     101#            new_dir = "#{cpa_runtime_dir}" 
     102#            FileUtils.mkdir new_dir 
     103            add_pem_cert_to_dir cpa_runtime_dir, cert_id 
     104          } 
     105        end 
     106         
     107        # get each XML certificate and create .pem file 
     108         
     109      end 
     110       
     111      def add_pem_cert_to_dir new_dir, cert_id 
     112        @xml_cpa.partyInfo.each{ | party_info | 
     113          if party_info.respond_to? "certificate" then 
     114            certs = party_info.certificate.class == Array ? party_info.certificate : [party_info.certificate] 
     115            certs.each{ | cert |  
     116              if cert.xmlattr_certId.strip == cert_id then 
     117                text = cert.keyInfo.x509Data.x509Certificate.strip 
     118                output_file = File.new "#{new_dir}/#{cert.xmlattr_certId}.pem", "w" 
     119                output_file << "-----BEGIN CERTIFICATE-----\n" 
     120                text.each_line{ | line | 
     121                  output_file << line.strip << "\n" 
     122                } 
     123                output_file << "-----END CERTIFICATE-----\n" 
     124                output_file.close 
     125              end 
     126            } 
     127          end 
     128        } 
    56129      end 
    57130 
  • branches/branch-https-dev/src/hefeweizen_library_cpa_manager.rb

    r451 r452  
    2929# 
    3030############################################################################## 
     31 
     32require 'digest/md5' 
    3133 
    3234module HefeWeizen 
     
    4749 
    4850        require @config['LIB_DIR'].strip + "/hefeweizen_library_cpa" 
     51 
     52        @cpas_runtime_dir = "#{@config['CPA_DIR']}/#{party_name}" 
     53        FileUtils.mkdir_p @cpas_runtime_dir 
    4954         
     55        # Lookup table for CPA id to md5sum 
     56        @cpa_id_md5sum = Hash.new 
    5057      end 
    5158 
     
    100107                  @cpas[cpa.id] = Hash.new 
    101108                  @cpas[cpa.id]['cpa'] = cpa 
     109                  result = nil 
    102110                  begin 
    103111                    result = cpa.setup_all_ebMS_header_infos cpa.id, @party_name, @party_identities 
     
    107115                    @logger.error "#{me}: CPA with id '#{cpa.id}' is not installed into the system." 
    108116                  end 
     117                   
    109118                  if result.nil? then 
     119                    @cpas.delete[cpa.id] 
    110120                    @logger.error "#{me}: Unable to successfully read ebXML CPA." 
    111121                  else 
     122                    md5sum = Digest::MD5.hexdigest cpa.id 
     123                    @cpa_id_md5sum[cpa.id] = md5sum 
     124                    cpa_runtime_dir = "#{@cpas_runtime_dir}/#{md5sum}" 
     125                    FileUtils.mkdir_p cpa_runtime_dir 
     126                    mapping_file = "#{@cpas_runtime_dir}/mapping_file" 
     127                    file = File.open mapping_file, "a" 
     128                    file << "#{md5sum} - #{cpa.id}\n" 
     129                    file.close  
     130                    cpa.create_certificate_locations @party_name, cpa_runtime_dir 
    112131                    @logger.info "#{me}: Loaded CPA '#{cpa_filename}' with id: '#{cpa.id}'" 
    113132                  end 
     
    121140        end 
    122141        return @cpas 
     142      end 
     143 
     144      def get_cpa_runtime_dir cpa_id 
     145        if @cpa_id_md5sum.has_key? cpa_id then 
     146          return "#{@cpas_runtime_dir}/#{@cpa_id_md5sum[cpa_id]}" 
     147        else 
     148          return nil 
     149        end 
    123150      end 
    124151