コード例 #1
0
 def _parse_dn(cls, dn):
     ln = LdapName(unicode(dn))
     # FIXME given this tuple of a single element tuple structure assumed here, is it possible this is
     # not actually the case, eg because of multi value attributes?
     return tuple((((_ldap_rdn_display_names.get(rdn.type),
                     _str_or_unicode(rdn.value)), )
                   for rdn in ln.getRdns()))
コード例 #2
0
 def parse(self, raw):
     '''
     Parse DistinguishedName from string representation
     @types: str -> DistinguishedName
     '''
     ldapName = LdapName(raw)
     head = None
     for item in ldapName.getRdns():
         name = item.getType()
         value = str(item.getValue())
         head = DistinguishedName(name.strip(), value.strip(), head)
     return head
コード例 #3
0
 def parse(self, raw):
     '''
     Parse DistinguishedName from string representation
     @types: str -> DistinguishedName
     '''
     ldapName = LdapName(raw)
     head = None
     for item in ldapName.getRdns():
         name = item.getType()
         value = str(item.getValue())
         head = DistinguishedName(name.strip(), value.strip(), head)
     return head
コード例 #4
0
 def redact_ee(self, ee):
     cert_data = b64decode(ee)
     x509_cert = cert_factory.generateCertificate(
         StringBufferInputStream(cert_data))
     dn = x509_cert.getSubjectDN().getName()
     LDAP_dn = LdapName(dn)
     redacted_ee = {}
     cn = ''
     for rdn in LDAP_dn.getRdns():
         if rdn.getType() == 'CN':
             cn = rdn.getValue()
     redacted_ee['redactedCN'] = svc.get_base_domain(cn)
     return redacted_ee
コード例 #5
0
ファイル: ssl.py プロジェクト: quannguyen1604/testing
    def _parse_dn(cls, dn):
        dn_lst = []

        ln = LdapName(unicode(dn))
        ln_iter = ln.getAll()
        try:
            ln_value = ln_iter.nextElement()
            while ln_value:
                dn_lst.append(tuple(ln_value.split('=', 1)))

                ln_value = ln_iter.nextElement()
        except NoSuchElementException:
            pass

        return tuple(dn_lst)
コード例 #6
0
    def _parse_dn(cls, dn):
        dn_lst = []

        ln = LdapName(unicode(dn))
        ln_iter = ln.getAll()
        try:
            ln_value = ln_iter.nextElement()
            while ln_value:
                dn_lst.append(tuple(ln_value.split('=', 1)))

                ln_value = ln_iter.nextElement()
        except NoSuchElementException:
            pass

        return tuple(dn_lst)
コード例 #7
0
ファイル: ssl.py プロジェクト: liumenglife/neuroConstruct
 def getpeercert(self, binary_form=False):
     cert = self.engine.getSession().getPeerCertificates()[0]
     if binary_form:
         return cert.getEncoded()
     dn = cert.getSubjectX500Principal().getName()
     ldapDN = LdapName(dn)
     # FIXME given this tuple of a single element tuple structure assumed here, is it possible this is
     # not actually the case, eg because of multi value attributes?
     rdns = tuple((((_ldap_rdn_display_names.get(rdn.type), rdn.value),) for rdn in ldapDN.getRdns()))
     # FIXME is it str? or utf8? or some other encoding? maybe a bug in cpython?
     alt_names = tuple(((_cert_name_types[type], str(name)) for (type, name) in cert.getSubjectAlternativeNames()))
     pycert = {
         "notAfter": _rfc2822_date_format.format(cert.getNotAfter()),
         "subject": rdns,
         "subjectAltName": alt_names, 
     }
     return pycert
コード例 #8
0
ファイル: ssl.py プロジェクト: isaiah/jython3
 def getpeercert(self, binary_form=False):
     cert = self.engine.getSession().getPeerCertificates()[0]
     if binary_form:
         return cert.getEncoded()
     dn = cert.getSubjectX500Principal().getName()
     ldapDN = LdapName(dn)
     # FIXME given this tuple of a single element tuple structure assumed here, is it possible this is
     # not actually the case, eg because of multi value attributes?
     rdns = tuple((((_ldap_rdn_display_names.get(rdn.type), rdn.value),) for rdn in ldapDN.getRdns()))
     # FIXME is it str? or utf8? or some other encoding? maybe a bug in cpython?
     alt_names = tuple(((_cert_name_types[type], str(name)) for (type, name) in cert.getSubjectAlternativeNames()))
     pycert = {
         "notAfter": _rfc2822_date_format.format(cert.getNotAfter()),
         "subject": rdns,
         "subjectAltName": alt_names, 
     }
     return pycert
コード例 #9
0
ファイル: ssl.py プロジェクト: Stewori/jython
 def _parse_dn(cls, dn):
     ln = LdapName(unicode(dn))
     # FIXME given this tuple of a single element tuple structure assumed here, is it possible this is
     # not actually the case, eg because of multi value attributes?
     return tuple((((_ldap_rdn_display_names.get(rdn.type), _str_or_unicode(rdn.value)),) for rdn in ln.getRdns()))