当前位置: 首页>>代码示例>>Java>>正文


Java ASN1ObjectIdentifier类代码示例

本文整理汇总了Java中org.spongycastle.asn1.ASN1ObjectIdentifier的典型用法代码示例。如果您正苦于以下问题:Java ASN1ObjectIdentifier类的具体用法?Java ASN1ObjectIdentifier怎么用?Java ASN1ObjectIdentifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ASN1ObjectIdentifier类属于org.spongycastle.asn1包,在下文中一共展示了ASN1ObjectIdentifier类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValueByObjectIdentifier

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
public String getValueByObjectIdentifier(ASN1ObjectIdentifier identifier) {
    X500Name x500name = null;
    try {
        x500name = new JcaX509CertificateHolder(certificate).getSubject();
    } catch (CertificateEncodingException e) {
        Timber.e(e, "Error getting value by ASN1 Object identifier");
    }
    if (x500name == null) {
        return null;
    }
    RDN[] rdNs = x500name.getRDNs(identifier);
    if (rdNs.length == 0) {
        return null;
    }
    RDN c = rdNs[0];
    return IETFUtils.valueToString(c.getFirst().getValue());
}
 
开发者ID:open-eid,项目名称:MOPP-Android,代码行数:18,代码来源:X509Cert.java

示例2: put

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
public String put(ASN1ObjectIdentifier oid, String value) {
        if (value != null && value.equals("")) value = null;
        if (containsKey(oid)) super.put(oid,value); // preserve original ordering
        else {
            super.put(oid,value);
//            String cn = remove(BCStyle.CN); // CN will always be last.
//            put(BCStyle.CN,cn);
        }
        return value;
    }
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:11,代码来源:DistinguishedNameValues.java

示例3: getPrincipal

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
public X509Principal getPrincipal() {
    Vector<ASN1ObjectIdentifier> oids = new Vector<ASN1ObjectIdentifier>();
    Vector<String> values = new Vector<String>();

    for (Map.Entry<ASN1ObjectIdentifier,String> entry : entrySet()) {
        if (entry.getValue() != null && !entry.getValue().equals("")) {
            oids.add( entry.getKey());
            values.add( entry.getValue());
        }
    }

    return new X509Principal(oids,values);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:14,代码来源:DistinguishedNameValues.java

示例4: getDisplayNameFromCertificate

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
/**
 * Returns either a string that "sums up" the certificate for humans, in a similar manner to what you might see
 * in a web browser, or null if one cannot be extracted. This will typically be the common name (CN) field, but
 * can also be the org (O) field, org+location+country if withLocation is set, or the email
 * address for S/MIME certificates.
 */
@Nullable
public static String getDisplayNameFromCertificate(@Nonnull X509Certificate certificate, boolean withLocation) throws CertificateParsingException {
    X500Name name = new X500Name(certificate.getSubjectX500Principal().getName());
    String commonName = null, org = null, location = null, country = null;
    for (RDN rdn : name.getRDNs()) {
        AttributeTypeAndValue pair = rdn.getFirst();
        String val = ((ASN1String) pair.getValue()).getString();
        ASN1ObjectIdentifier type = pair.getType();
        if (type.equals(RFC4519Style.cn))
            commonName = val;
        else if (type.equals(RFC4519Style.o))
            org = val;
        else if (type.equals(RFC4519Style.l))
            location = val;
        else if (type.equals(RFC4519Style.c))
            country = val;
    }
    final Collection<List<?>> subjectAlternativeNames = certificate.getSubjectAlternativeNames();
    String altName = null;
    if (subjectAlternativeNames != null)
        for (final List<?> subjectAlternativeName : subjectAlternativeNames)
            if ((Integer) subjectAlternativeName.get(0) == 1) // rfc822name
                altName = (String) subjectAlternativeName.get(1);

    if (org != null) {
        return withLocation ? Joiner.on(", ").skipNulls().join(org, location, country) : org;
    } else if (commonName != null) {
        return commonName;
    } else {
        return altName;
    }
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:39,代码来源:X509Utils.java

示例5: getPrincipal

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
public X509Principal getPrincipal() {
    Vector<ASN1ObjectIdentifier> oids = new Vector<ASN1ObjectIdentifier>();
    Vector<String> values = new Vector<String>();

    for (Entry<ASN1ObjectIdentifier,String> entry : entrySet()) {
        if (entry.getValue() != null && !entry.getValue().equals("")) {
            oids.add( entry.getKey());
            values.add( entry.getValue());
        }
    }

    return new X509Principal(oids,values);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:14,代码来源:DistinguishedNameValues.java

示例6: isSignedBy

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
public boolean isSignedBy(String personalCode) {
    for (SignatureFacade signatureFacade : getSignatures()) {
        String serialNumber = signatureFacade.getSigningCertificate()
                .getValueByObjectIdentifier(ASN1ObjectIdentifier.getInstance(BCStyle.SERIALNUMBER));
        if (personalCode != null && serialNumber != null && personalCode.equals(serialNumber)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:open-eid,项目名称:MOPP-Android,代码行数:11,代码来源:ContainerFacade.java

示例7: generateSignedCertificate

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
public static X509Certificate generateSignedCertificate(X509Certificate caCertificate, PrivateKey caPrivateKey, PublicKey publicKey, String CN) 
		throws NoSuchAlgorithmException, OperatorCreationException, CertificateException, 
		KeyStoreException, UnrecoverableKeyException, IOException, 
		InvalidKeyException, NoSuchPaddingException, InvalidParameterSpecException, 
		InvalidKeySpecException, InvalidAlgorithmParameterException, IllegalBlockSizeException, 
		BadPaddingException {

	X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);

	builder.addRDN(BCStyle.CN, CN);

	// We want this root certificate to be valid for one year
	Calendar calendar = Calendar.getInstance();
	calendar.add(Calendar.YEAR, 1);

	ContentSigner sigGen = new JcaContentSignerBuilder("SHA1WithRSAEncryption").setProvider(BC).build(caPrivateKey);
	X509v3CertificateBuilder certGen = new JcaX509v3CertificateBuilder(
			caCertificate, 
			new BigInteger(80, new Random()), 
			new Date(System.currentTimeMillis() - 50000),
			calendar.getTime(),
			new X500Principal(builder.build().getEncoded()),
			publicKey);

	// Those are the extensions needed for the certificate to be a leaf certificate that authenticates a SSL server
	certGen.addExtension(new ASN1ObjectIdentifier("2.5.29.15"), true, new X509KeyUsage(X509KeyUsage.keyEncipherment));
	certGen.addExtension(new ASN1ObjectIdentifier("2.5.29.37"), true, new DERSequence(KeyPurposeId.id_kp_serverAuth));

	X509CertificateHolder certificateHolder = certGen.build(sigGen);
	X509Certificate certificate = new JcaX509CertificateConverter().setProvider(BC).getCertificate(certificateHolder);

	return certificate;

}
 
开发者ID:ghazi94,项目名称:Android_CCTV,代码行数:35,代码来源:ModSSL.java

示例8: generateRootCertificate

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
public static X509Certificate generateRootCertificate(KeyPair keys, String CN) 
		throws NoSuchAlgorithmException, OperatorCreationException, CertificateException, 
		KeyStoreException, UnrecoverableKeyException, IOException, 
		InvalidKeyException, NoSuchPaddingException, InvalidParameterSpecException, 
		InvalidKeySpecException, InvalidAlgorithmParameterException, IllegalBlockSizeException, 
		BadPaddingException {

	X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);

	builder.addRDN(BCStyle.CN, CN);

	// We want this root certificate to be valid for one year 
	Calendar calendar = Calendar.getInstance();
	calendar.add( Calendar.YEAR, 1 );

	ContentSigner sigGen = new JcaContentSignerBuilder("SHA1WithRSAEncryption").setProvider(BC).build(keys.getPrivate());
	X509v3CertificateBuilder certGen = new JcaX509v3CertificateBuilder(
			builder.build(), 
			new BigInteger(80, new Random()), 
			new Date(System.currentTimeMillis() - 50000),
			calendar.getTime(),
			builder.build(),
			keys.getPublic());

	// Those are the extensions needed for a CA certificate
	certGen.addExtension(new ASN1ObjectIdentifier("2.5.29.19"), true, new BasicConstraints(true));
	certGen.addExtension(new ASN1ObjectIdentifier("2.5.29.15"), true, new X509KeyUsage(X509KeyUsage.digitalSignature));
	certGen.addExtension(new ASN1ObjectIdentifier("2.5.29.37"), true, new ExtendedKeyUsage(KeyPurposeId.id_kp_serverAuth));

	X509CertificateHolder certificateHolder = certGen.build(sigGen);

	X509Certificate certificate = new JcaX509CertificateConverter().setProvider(BC).getCertificate(certificateHolder);

	return certificate;

}
 
开发者ID:ghazi94,项目名称:Android_CCTV,代码行数:37,代码来源:ModSSL.java

示例9: getDisplayNameFromCertificate

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
/**
 * Returns either a string that "sums up" the certificate for humans, in a similar manner to what you might see
 * in a web browser, or null if one cannot be extracted. This will typically be the common name (CN) field, but
 * can also be the org (O) field, org+location+country if withLocation is set, or the email
 * address for S/MIME certificates.
 */
public static @Nullable String getDisplayNameFromCertificate(@Nonnull X509Certificate certificate, boolean withLocation) throws CertificateParsingException {
    X500Name name = new X500Name(certificate.getSubjectX500Principal().getName());
    String commonName = null, org = null, location = null, country = null;
    for (RDN rdn : name.getRDNs()) {
        AttributeTypeAndValue pair = rdn.getFirst();
        String val = ((ASN1String) pair.getValue()).getString();
        ASN1ObjectIdentifier type = pair.getType();
        if (type.equals(RFC4519Style.cn))
            commonName = val;
        else if (type.equals(RFC4519Style.o))
            org = val;
        else if (type.equals(RFC4519Style.l))
            location = val;
        else if (type.equals(RFC4519Style.c))
            country = val;
    }
    final Collection<List<?>> subjectAlternativeNames = certificate.getSubjectAlternativeNames();
    String altName = null;
    if (subjectAlternativeNames != null)
        for (final List<?> subjectAlternativeName : subjectAlternativeNames)
            if ((Integer) subjectAlternativeName.get(0) == 1) // rfc822name
                altName = (String) subjectAlternativeName.get(1);

    if (org != null) {
        return withLocation ? Joiner.on(", ").skipNulls().join(org, location, country) : org;
    } else if (commonName != null) {
        return commonName;
    } else {
        return altName;
    }
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:38,代码来源:X509Utils.java

示例10: setBagAttribute

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
public void setBagAttribute(
    ASN1ObjectIdentifier oid,
    ASN1Encodable        attribute)
{
    attrCarrier.setBagAttribute(oid, attribute);
}
 
开发者ID:B4dT0bi,项目名称:silvertunnel-ng,代码行数:7,代码来源:TempJCERSAPrivateKey.java

示例11: getBagAttribute

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
public ASN1Encodable getBagAttribute(
    ASN1ObjectIdentifier oid)
{
    return attrCarrier.getBagAttribute(oid);
}
 
开发者ID:B4dT0bi,项目名称:silvertunnel-ng,代码行数:6,代码来源:TempJCERSAPrivateKey.java

示例12: getView

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
@NonNull
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
    notificationUtil = new NotificationUtil(activity);
    ViewHolder viewHolder;
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.fragment_container_signatures, parent, false);
        viewHolder = new ViewHolder(convertView);
        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }

    SignatureFacade signatureFacade = getItem(position);

    if (signatureFacade != null) {
        String personInfo;
        X509Cert x509Cert = signatureFacade.getSigningCertificate();
        if (x509Cert != null) {
            String surname = x509Cert.getValueByObjectIdentifier(ASN1ObjectIdentifier.getInstance(BCStyle.SURNAME));
            String name = x509Cert.getValueByObjectIdentifier(ASN1ObjectIdentifier.getInstance(BCStyle.GIVENNAME));
            String serialNumber = x509Cert.getValueByObjectIdentifier(ASN1ObjectIdentifier.getInstance(BCStyle.SERIALNUMBER));

            if ((surname != null && !surname.isEmpty()) && (name != null && !name.isEmpty())) {
                if (serialNumber != null) {
                    personInfo = String.format("%s %s (%s)", name, surname, serialNumber);
                } else {
                    personInfo = String.format("%s %s", name, surname);
                }
            } else {
                String commonName = x509Cert.getValueByObjectIdentifier(ASN1ObjectIdentifier.getInstance(BCStyle.CN));

                if (serialNumber != null) {
                    personInfo = String.format("%s (%s)", commonName, serialNumber);
                } else {
                    personInfo = String.format("%s", commonName);
                }
            }
        } else {
            personInfo = signatureFacade.getSignedBy();
        }

        viewHolder.name.setText(personInfo);
        viewHolder.signed.setText(DateUtils.formatSignedDate(signatureFacade.getTrustedSigningTime()));

        if (signatureFacade.isSignatureValid()) {
            viewHolder.isSigned.setText(getContext().getText(R.string.signature_valid));
            viewHolder.isSigned.setTextColor(Color.rgb(80, 155, 0));
        } else {
            viewHolder.isSigned.setText(getContext().getText(R.string.signature_invalid));
            viewHolder.isSigned.setTextColor(Color.RED);
        }
        viewHolder.removeSignature.setOnClickListener(new RemoveSignatureListener(position, personInfo));
        viewHolder.removeSignature.setVisibility(containerFacade.isRWContainer() ? View.VISIBLE : View.INVISIBLE);
    }
    return convertView;
}
 
开发者ID:open-eid,项目名称:MOPP-Android,代码行数:58,代码来源:SignatureAdapter.java

示例13: SignatureData

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
public SignatureData(ASN1ObjectIdentifier type, 
        InputStream is)
{
  this.type = type;
  in = is;
}
 
开发者ID:KodeKreatif,项目名称:pdfdigisign,代码行数:7,代码来源:SignatureData.java

示例14: getContentType

import org.spongycastle.asn1.ASN1ObjectIdentifier; //导入依赖的package包/类
@Override
public ASN1ObjectIdentifier getContentType() {
  return type;
}
 
开发者ID:KodeKreatif,项目名称:pdfdigisign,代码行数:5,代码来源:SignatureData.java


注:本文中的org.spongycastle.asn1.ASN1ObjectIdentifier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。