Returns the subject DN of the given certificate in the Globus format.

@param cert the certificate to get the subject of. The certificate
must be of <code>X509CertificateObject</code> type.
@return the subject DN of the certificate in the Globus format.
964279
public static String getIdentity(X509Certificate cert) {
    	if (cert == null) {
    		return null;
    	}

    	String subjectDN = cert.getSubjectX500Principal().getName(X500Principal.RFC2253);
    	X509Name name = new X509Name(true, subjectDN);
	    return X509NameHelper.toString(name);
    }
1172201
public static synchronized X509CertificatePair generateCertificatePair
            (byte[] encoded) throws CertificateException {
        Object key = new Cache.EqualByteArray(encoded);
        X509CertificatePair pair = cache.get(key);
        if (pair != null) {
            return pair;
        }
        pair = new X509CertificatePair(encoded);
        key = new Cache.EqualByteArray(pair.encoded);
        cache.put(key, pair);
        return pair;
    }
1010192
public static X509CertificateHolder getX509CertificateHolder(CertifiedPublicKey cert)
    {
        if (cert instanceof BcX509CertifiedPublicKey) {
            return ((BcX509CertifiedPublicKey) cert).getX509CertificateHolder();
        } else {
            try {
                return new X509CertificateHolder(cert.getEncoded());
            } catch (IOException e) {
                // Very unlikely
                throw new IllegalArgumentException("Invalid certified public key, unable to encode.");
            }
        }

    }
874844
public static sslcertkey_binding get(nitro_service service, String certkey) throws Exception{
		sslcertkey_binding obj = new sslcertkey_binding();
		obj.set_certkey(certkey);
		sslcertkey_binding response = (sslcertkey_binding) obj.get_resource(service);
		return response;
	}
1009950
public static X509Name getSubjectFields(X509Certificate cert) {
        try {
            return new X509Name((ASN1Sequence)getSubject(cert.getTBSCertificate()));
        }
        catch (Exception e) {
            throw new ExceptionConverter(e);
        }
    }
849693
public CertificateBundle getCertificate(String certificateIdentifier) {
        CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier);
        return getCertificate(id.vault(), id.name(), id.version() == null ? "" : id.version());
    }
1027677
function x509CertificateChain() {
	var self = {
		__TYPE__ : CertificateType.CERT_CHAIN_VERSION_2,
		NumCertBlobs : new type.UInt32Le(),
        CertBlobArray : new type.Factory(function(s) {
        	self.CertBlobArray = new type.Component([]);
        	for(var i = 0; i < self.NumCertBlobs.value; i++) {
        		self.CertBlobArray.obj.push(certBlob().read(s));
        	}
        }),
        padding : new type.BinaryString(null, { readLength : new type.CallableValue(function() {
        	return 8 + 4 * self.NumCertBlobs.value;
        }) }),
        /**
         * @return {object} {n : modulus{bignum}, e : publicexponent{integer}
         */
        getPublicKey : function(){
        	var cert = x509.X509Certificate().decode(new type.Stream(self.CertBlobArray.obj[self.CertBlobArray.obj.length - 1].obj.abCert.value), asn1.ber);
        	var publikeyStream = new type.Stream(cert.value.tbsCertificate.value.subjectPublicKeyInfo.value.subjectPublicKey.toBuffer());
        	var asn1PublicKey = x509.RSAPublicKey().decode(publikeyStream, asn1.ber);
        	return rsa.publicKey(asn1PublicKey.value.modulus.value, asn1PublicKey.value.publicExponent.value);
        }
	};
	
	return new type.Component(self);
}
1231566
public String getUserName(Subject subject) {
		// Subject subject = null;
		try {
			// subject = WSSubject.getRunAsSubject();
			WSCredential wsCred = getWSCredential(subject);
			if (wsCred == null) {
				wsCred = getPrivateWSCredential(subject);
			}
			return wsCred != null ? wsCred.getSecurityName() : null;
		} catch (Exception e) {
			// ffdc
			return null;
		}
	}
1130914
function loadCA($cert)
    {
        $olddn = $this->dn;
        $oldcert = $this->currentCert;
        $oldsigsubj = $this->signatureSubject;

        $cert = $this->loadX509($cert);
        if (!$cert) {
            $this->dn = $olddn;
            $this->currentCert = $oldcert;
            $this->signatureSubject = $oldsigsubj;

            return false;
        }

        /* From RFC5280 "PKIX Certificate and CRL Profile":

           If the keyUsage extension is present, then the subject public key
           MUST NOT be used to verify signatures on certificates or CRLs unless
           the corresponding keyCertSign or cRLSign bit is set. */
        //$keyUsage = $this->getExtension('id-ce-keyUsage');
        //if ($keyUsage && !in_array('keyCertSign', $keyUsage)) {
        //    return false;
        //}

        /* From RFC5280 "PKIX Certificate and CRL Profile":

           The cA boolean indicates whether the certified public key may be used
           to verify certificate signatures.  If the cA boolean is not asserted,
           then the keyCertSign bit in the key usage extension MUST NOT be
           asserted.  If the basic constraints extension is not present in a
           version 3 certificate, or the extension is present but the cA boolean
           is not asserted, then the certified public key MUST NOT be used to
           verify certificate signatures. */
        //$basicConstraints = $this->getExtension('id-ce-basicConstraints');
        //if (!$basicConstraints || !$basicConstraints['cA']) {
        //    return false;
        //}

        $this->CAs[] = $cert;

        $this->dn = $olddn;
        $this->currentCert = $oldcert;
        $this->signatureSubject = $oldsigsubj;

        return true;
    }
449108
def der_cert(der_data):
    
    if isinstance(der_data, str):
        der_data = bytes(der_data, 'utf-8')
    return x509.load_der_x509_certificate(der_data, default_backend())
429054
private static function _getCertKeyId(Certificate $cert): string
    {
        $exts = $cert->tbsCertificate()->extensions();
        if ($exts->hasSubjectKeyIdentifier()) {
            return $exts->subjectKeyIdentifier()->keyIdentifier();
        }
        return $cert->tbsCertificate()
            ->subjectPublicKeyInfo()
            ->keyIdentifier();
    }
665093
public KeyStore getCaCertKeystore() {
        try {
            KeyStore returnKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
            returnKeyStore.load(null, null);
            Enumeration<String> e = CACertService.caCertKeystore.aliases();
            while(e.hasMoreElements()) {
                Certificate cert = CACertService.caCertKeystore.getCertificate(e.nextElement());
                returnKeyStore.setCertificateEntry(((X509Certificate) cert).getSubjectDN().toString(), cert);
            }
            return CACertService.caCertKeystore;
        } catch (KeyStoreException e) {
            return null;
        } catch (CertificateException e) {
            return null;
        } catch (NoSuchAlgorithmException e) {
            return null;
        } catch (IOException e) {
            return null;
        }
    }
67453
protected X509Certificate loadX509CertificateFromResource(String resource) throws CertificateException{
		InputStream derInputStream = this.getClass().getClassLoader().getResourceAsStream(resource);
		CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
		X509Certificate cert = (X509Certificate) certificateFactory.generateCertificate(derInputStream);
		try {
			derInputStream.close();
		} catch (IOException e) {
			// ignore
		}
		return cert;
	}
1322666
static X509Certificate selfSignedCertificate() throws CertificateException {
        return (X509Certificate) SslContext.X509_CERT_FACTORY.generateCertificate(
                new ByteArrayInputStream(CERT.getBytes(CharsetUtil.US_ASCII))
        );
    }
918909
protected Map<String, List<Object>> extractPersonAttributes(final X509Certificate certificate) {
        val attributes = new LinkedHashMap<String, List<Object>>();

        if (certificate != null) {
            if (StringUtils.isNotBlank(certificate.getSigAlgOID())) {
                attributes.put("sigAlgOid", CollectionUtils.wrapList(certificate.getSigAlgOID()));
            }
            val subjectDn = certificate.getSubjectDN();
            if (subjectDn != null) {
                attributes.put("subjectDn", CollectionUtils.wrapList(subjectDn.getName()));
            }
            val subjectPrincipal = certificate.getSubjectX500Principal();
            if (subjectPrincipal != null) {
                attributes.put("subjectX500Principal", CollectionUtils.wrapList(subjectPrincipal.getName()));
            }
            try {
                val rfc822Email = getRFC822EmailAddress(certificate.getSubjectAlternativeNames());
                if (rfc822Email != null) {
                    attributes.put("x509Rfc822Email", CollectionUtils.wrapList(rfc822Email));
                }
            } catch (final CertificateParsingException e) {
                LOGGER.warn("Error parsing subject alternative names to get rfc822 email [{}]", e.getMessage());
            }
        }
        return attributes;
    }
1044979
protected X509CertifiedPublicKey getPublicKey(CertifiedPublicKey publicKey)
    {
        if (publicKey instanceof X509CertifiedPublicKey) {
            return (X509CertifiedPublicKey) publicKey;
        }

        throw new IllegalArgumentException(String.format("Unsupported certificate [%s], expecting X509 certificates.",
            publicKey.getClass().getName()));
    }
1195784
static String getDNSubField(String varName, String DN) throws CertificateMapperException {
        if (varName.equals("DN")) {
            return DN; // return the whole DN
        }
        // Parse the DN looking for 'varName'
        StringTokenizer st = new StringTokenizer(DN);
        for (;;) {
            String name, value;
            try {
                name = st.nextToken(",= ");
                value = st.nextToken(",");
                if (value != null) {
                    value = value.substring(1);
                }
            } catch (NoSuchElementException e) {
                e.getMessage();
                break;
            }
            if (name.equals(varName)) {
                return value;
            }
        }

        throw new CertificateMapperException(WIMMessageKey.UNKNOWN_DN_FIELD, Tr.formatMessage(
                                                                                              tc,
                                                                                              WIMMessageKey.UNKNOWN_DN_FIELD,
                                                                                              WIMMessageHelper.generateMsgParms(varName)));
    }