Search in sources :

Example 66 with DERIA5String

use of com.github.zhenwei.core.asn1.DERIA5String in project keystore-explorer by kaikramer.

the class DNetscapeCaRevocationUrl method okPressed.

private void okPressed() {
    String netscapeCaRevocationUrlStr = jtfNetscapeCaRevocationUrl.getText().trim();
    if (netscapeCaRevocationUrlStr.length() == 0) {
        JOptionPane.showMessageDialog(this, res.getString("DNetscapeCaRevocationUrl.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    DERIA5String netscapeCaRevocationUrl = new DERIA5String(netscapeCaRevocationUrlStr);
    try {
        value = netscapeCaRevocationUrl.getEncoded(ASN1Encoding.DER);
    } catch (IOException ex) {
        DError dError = new DError(this, ex);
        dError.setLocationRelativeTo(this);
        dError.setVisible(true);
        return;
    }
    closeDialog();
}
Also used : DERIA5String(org.bouncycastle.asn1.DERIA5String) DERIA5String(org.bouncycastle.asn1.DERIA5String) IOException(java.io.IOException) DError(org.kse.gui.error.DError)

Example 67 with DERIA5String

use of com.github.zhenwei.core.asn1.DERIA5String in project keystore-explorer by kaikramer.

the class DNetscapeCaRevocationUrl method prepopulateWithValue.

private void prepopulateWithValue(byte[] value) throws IOException {
    DERIA5String netscapeCaRevocationUrl = DERIA5String.getInstance(value);
    jtfNetscapeCaRevocationUrl.setText(netscapeCaRevocationUrl.getString());
    jtfNetscapeCaRevocationUrl.setCaretPosition(0);
}
Also used : DERIA5String(org.bouncycastle.asn1.DERIA5String)

Example 68 with DERIA5String

use of com.github.zhenwei.core.asn1.DERIA5String in project keystore-explorer by kaikramer.

the class DNetscapeCertificateRenewalUrl method prepopulateWithValue.

private void prepopulateWithValue(byte[] value) throws IOException {
    DERIA5String netscapeCertificateRenewalUrl = DERIA5String.getInstance(value);
    jtfNetscapeCertificateRenewalUrl.setText(netscapeCertificateRenewalUrl.getString());
    jtfNetscapeCertificateRenewalUrl.setCaretPosition(0);
}
Also used : DERIA5String(org.bouncycastle.asn1.DERIA5String)

Example 69 with DERIA5String

use of com.github.zhenwei.core.asn1.DERIA5String in project keystore-explorer by kaikramer.

the class Spkac method createPublicKeyAndChallenge.

private ASN1Sequence createPublicKeyAndChallenge() throws SpkacException {
    ASN1EncodableVector publicKeyAlgorithm = new ASN1EncodableVector();
    publicKeyAlgorithm.add(new ASN1ObjectIdentifier(getPublicKeyAlg().oid()));
    if (getPublicKey() instanceof RSAPublicKey) {
        publicKeyAlgorithm.add(DERNull.INSTANCE);
    } else {
        DSAParams dsaParams = ((DSAPublicKey) getPublicKey()).getParams();
        ASN1EncodableVector dssParams = new ASN1EncodableVector();
        dssParams.add(new ASN1Integer(dsaParams.getP()));
        dssParams.add(new ASN1Integer(dsaParams.getQ()));
        dssParams.add(new ASN1Integer(dsaParams.getG()));
        publicKeyAlgorithm.add(new DERSequence(dssParams));
    }
    ASN1EncodableVector spki = new ASN1EncodableVector();
    spki.add(new DERSequence(publicKeyAlgorithm));
    spki.add(encodePublicKeyAsBitString(getPublicKey()));
    ASN1EncodableVector publicKeyAndChallenge = new ASN1EncodableVector();
    publicKeyAndChallenge.add(new DERSequence(spki));
    publicKeyAndChallenge.add(new DERIA5String(getChallenge()));
    return new DERSequence(publicKeyAndChallenge);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) DERIA5String(org.bouncycastle.asn1.DERIA5String) RSAPublicKey(java.security.interfaces.RSAPublicKey) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DSAParams(java.security.interfaces.DSAParams) ASN1Integer(org.bouncycastle.asn1.ASN1Integer) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) DSAPublicKey(java.security.interfaces.DSAPublicKey)

Example 70 with DERIA5String

use of com.github.zhenwei.core.asn1.DERIA5String in project keystore-explorer by kaikramer.

the class GeneralNameUtil method safeToString.

/**
 * Get string representation for General names that cannot cause a
 * IOException to be thrown. Unsupported are ediPartyName, otherName and
 * x400Address. Returns a blank string for these.
 *
 * @param generalName   General name
 * @param addLinkForURI If true, convert URI to a clickable link
 * @return String representation of general name
 */
public static String safeToString(GeneralName generalName, boolean addLinkForURI) {
    if (generalName == null) {
        return "";
    }
    switch(generalName.getTagNo()) {
        case GeneralName.directoryName:
            X500Name directoryName = (X500Name) generalName.getName();
            return MessageFormat.format(res.getString("GeneralNameUtil.DirectoryGeneralName"), directoryName.toString());
        case GeneralName.dNSName:
            DERIA5String dnsName = (DERIA5String) generalName.getName();
            return MessageFormat.format(res.getString("GeneralNameUtil.DnsGeneralName"), dnsName.getString());
        case GeneralName.iPAddress:
            String ipAddressString = parseIpAddress(generalName);
            return MessageFormat.format(res.getString("GeneralNameUtil.IpAddressGeneralName"), ipAddressString);
        case GeneralName.registeredID:
            ASN1ObjectIdentifier registeredId = (ASN1ObjectIdentifier) generalName.getName();
            return MessageFormat.format(res.getString("GeneralNameUtil.RegisteredIdGeneralName"), ObjectIdUtil.toString(registeredId));
        case GeneralName.rfc822Name:
            DERIA5String rfc822Name = (DERIA5String) generalName.getName();
            return MessageFormat.format(res.getString("GeneralNameUtil.Rfc822GeneralName"), rfc822Name.getString());
        case GeneralName.uniformResourceIdentifier:
            DERIA5String uri = (DERIA5String) generalName.getName();
            String link = addLinkForURI ? "<a href=\"" + uri.getString() + "\">" + uri.getString() + "</a>" : uri.getString();
            return MessageFormat.format(res.getString("GeneralNameUtil.UriGeneralName"), link);
        case GeneralName.otherName:
            // we currently only support UPN in otherName
            return parseUPN(generalName);
        default:
            return "";
    }
}
Also used : DERIA5String(org.bouncycastle.asn1.DERIA5String) X500Name(org.bouncycastle.asn1.x500.X500Name) DERIA5String(org.bouncycastle.asn1.DERIA5String) ASN1UTF8String(org.bouncycastle.asn1.ASN1UTF8String) ASN1OctetString(org.bouncycastle.asn1.ASN1OctetString) DirectoryString(org.bouncycastle.asn1.x500.DirectoryString) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Aggregations

DERIA5String (org.bouncycastle.asn1.DERIA5String)80 IOException (java.io.IOException)55 GeneralName (org.bouncycastle.asn1.x509.GeneralName)29 DEROctetString (org.bouncycastle.asn1.DEROctetString)22 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)21 DERSequence (org.bouncycastle.asn1.DERSequence)17 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)16 ASN1Primitive (org.bouncycastle.asn1.ASN1Primitive)15 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)14 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)14 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)12 DERBitString (org.bouncycastle.asn1.DERBitString)12 SignatureException (java.security.SignatureException)10 ArrayList (java.util.ArrayList)10 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)10 GeneralNames (org.bouncycastle.asn1.x509.GeneralNames)10 HashSet (java.util.HashSet)9 DERPrintableString (org.bouncycastle.asn1.DERPrintableString)9 OperatorCreationException (org.bouncycastle.operator.OperatorCreationException)9 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)8