/** * Returns subject alternative names for "localhost". * @return the subject alternative names for "localhost". */ private static GeneralNames getLocalhostSubjectAltNames() throws UnknownHostException { InetAddress[] localAddresses = InetAddress.getAllByName("localhost"); GeneralName[] generalNames = new GeneralName[localAddresses.length + 1]; for (int i = 0; i < localAddresses.length; i++) { generalNames[i] = new GeneralName(GeneralName.iPAddress, new DEROctetString(localAddresses[i].getAddress())); } generalNames[generalNames.length - 1] = new GeneralName(GeneralName.dNSName, new DERIA5String("localhost")); return new GeneralNames(generalNames); }
/** * Creates a new <code>PolicyQualifierInfo</code> containing a * cPSuri qualifier. * * @param cps the CPS (certification practice statement) uri as a * <code>String</code>. */ public PolicyQualifierInfo( String cps) { policyQualifierId = PolicyQualifierId.id_qt_cps; qualifier = new DERIA5String (cps); }
/** * Creates a new <code>PolicyQualifierInfo</code> containing a * cPSuri qualifier. * * @param cps the CPS (certification practice statement) uri as a * <code>String</code>. */ public PolicyQualifierInfo( String cps) { policyQualifierId = PolicyQualifierId.id_qt_cps; qualifier = new DERIA5String (cps); }
public SpcLink(String url) { this.url = new DERIA5String(url); }
private void okPressed() { String netscapeCommentStr = jtaNetscapeComment.getText().trim(); if (netscapeCommentStr.length() == 0) { JOptionPane.showMessageDialog(this, res.getString("DNetscapeComment.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } DERIA5String netscapeComment = new DERIA5String(netscapeCommentStr); try { value = netscapeComment.getEncoded(ASN1Encoding.DER); } catch (IOException e) { DError.displayError(this, e); return; } closeDialog(); }
private void okPressed() { String netscapeBaseUrlStr = jtfNetscapeBaseUrl.getText().trim(); if (netscapeBaseUrlStr.length() == 0) { JOptionPane.showMessageDialog(this, res.getString("DNetscapeBaseUrl.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } DERIA5String netscapeBaseUrl = new DERIA5String(netscapeBaseUrlStr); try { value = netscapeBaseUrl.getEncoded(ASN1Encoding.DER); } catch (IOException e) { DError.displayError(this, e); return; } closeDialog(); }
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 e) { DError.displayError(this, e); return; } closeDialog(); }
private void okPressed() { String netscapeCertificateRenewalUrlStr = jtfNetscapeCertificateRenewalUrl.getText().trim(); if (netscapeCertificateRenewalUrlStr.length() == 0) { JOptionPane.showMessageDialog(this, res.getString("DNetscapeCertificateRenewalUrl.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } DERIA5String netscapeCertificateRenewalUrl = new DERIA5String(netscapeCertificateRenewalUrlStr); try { value = netscapeCertificateRenewalUrl.getEncoded(ASN1Encoding.DER); } catch (IOException e) { DError.displayError(this, e); return; } closeDialog(); }
private void okPressed() { String netscapeRevocationUrlStr = jtfNetscapeRevocationUrl.getText().trim(); if (netscapeRevocationUrlStr.length() == 0) { JOptionPane.showMessageDialog(this, res.getString("DNetscapeRevocationUrl.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } DERIA5String netscapeRevocationUrl = new DERIA5String(netscapeRevocationUrlStr); try { value = netscapeRevocationUrl.getEncoded(ASN1Encoding.DER); } catch (IOException e) { DError.displayError(this, e); return; } closeDialog(); }
private void okPressed() { String netscapeCaPolicyUrlStr = jtfNetscapeCaPolicyUrl.getText().trim(); if (netscapeCaPolicyUrlStr.length() == 0) { JOptionPane.showMessageDialog(this, res.getString("DNetscapeCaPolicyUrl.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } DERIA5String netscapeCaPolicyUrl = new DERIA5String(netscapeCaPolicyUrlStr); try { value = netscapeCaPolicyUrl.getEncoded(ASN1Encoding.DER); } catch (IOException e) { DError.displayError(this, e); return; } closeDialog(); }
private void okPressed() { String netscapeSslServerNameStr = jtfNetscapeSslServerName.getText().trim(); if (netscapeSslServerNameStr.length() == 0) { JOptionPane.showMessageDialog(this, res.getString("DNetscapeSslServerName.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } DERIA5String netscapeSslServerName = new DERIA5String(netscapeSslServerNameStr); try { value = netscapeSslServerName.getEncoded(ASN1Encoding.DER); } catch (IOException e) { DError.displayError(this, e); return; } closeDialog(); }
public ASN1Encodable createString(String text) { Args.notNull(text, "text"); if (teletexString == this) { return new DERT61String(text); } else if (printableString == this) { return new DERPrintableString(text); } else if (utf8String == this) { return new DERUTF8String(text); } else if (bmpString == this) { return new DERBMPString(text); } else if (ia5String == this) { return new DERIA5String(text, true); } else { throw new IllegalStateException("should not reach here, unknown StringType " + this.name()); } }
SignaturePolicyIdentifier toSignaturePolicyIdentifier() { String algId = DigestAlgorithms.getAllowedDigests(this.policyDigestAlgorithm); if (algId == null || algId.length() == 0) { throw new IllegalArgumentException("Invalid policy hash algorithm"); } SignaturePolicyIdentifier signaturePolicyIdentifier = null; SigPolicyQualifierInfo spqi = null; if (this.policyUri != null && this.policyUri.length() > 0) { spqi = new SigPolicyQualifierInfo(PKCSObjectIdentifiers.id_spq_ets_uri, new DERIA5String(this.policyUri)); } SigPolicyQualifiers qualifiers = new SigPolicyQualifiers(new SigPolicyQualifierInfo[] {spqi}); signaturePolicyIdentifier = new SignaturePolicyIdentifier(new SignaturePolicyId(DERObjectIdentifier.getInstance(new DERObjectIdentifier(this.policyIdentifier.replace("urn:oid:", ""))), new OtherHashAlgAndValue(new AlgorithmIdentifier(algId), new DEROctetString(this.policyHash)), qualifiers)); return signaturePolicyIdentifier; } }
protected ASN1Encodable encodeStringValue(ASN1ObjectIdentifier oid, String value) { if (oid.equals(dc)) { return new DERIA5String(value); } else if (oid.equals(c) || oid.equals(serialNumber) || oid.equals(dnQualifier) || oid.equals(telephoneNumber)) { return new DERPrintableString(value); } return super.encodeStringValue(oid, value); }
protected ASN1Encodable encodeStringValue(ASN1ObjectIdentifier oid, String value) { if (oid.equals(dc)) { return new DERIA5String(value); } else if (oid.equals(c) || oid.equals(serialNumber) || oid.equals(dnQualifier) || oid.equals(telephoneNumber)) { return new DERPrintableString(value); } return super.encodeStringValue(oid, value); }
SignaturePolicyIdentifier toSignaturePolicyIdentifier() { String algId = DigestAlgorithms.getAllowedDigest(this.policyDigestAlgorithm); if (algId == null || algId.length() == 0) { throw new IllegalArgumentException("Invalid policy hash algorithm"); } SignaturePolicyIdentifier signaturePolicyIdentifier = null; SigPolicyQualifierInfo spqi = null; if (this.policyUri != null && this.policyUri.length() > 0) { spqi = new SigPolicyQualifierInfo(PKCSObjectIdentifiers.id_spq_ets_uri, new DERIA5String(this.policyUri)); } signaturePolicyIdentifier = new SignaturePolicyIdentifier(new SignaturePolicyId(DERObjectIdentifier.getInstance(new DERObjectIdentifier(this.policyIdentifier.replace("urn:oid:", ""))), new OtherHashAlgAndValue(new AlgorithmIdentifier(new ASN1ObjectIdentifier(algId)), new DEROctetString(this.policyHash)), SignUtils.createSigPolicyQualifiers(spqi))); return signaturePolicyIdentifier; } }
SignaturePolicyIdentifier toSignaturePolicyIdentifier() { String algId = DigestAlgorithms.getAllowedDigest(this.policyDigestAlgorithm); if (algId == null || algId.length() == 0) { throw new IllegalArgumentException("Invalid policy hash algorithm"); } SignaturePolicyIdentifier signaturePolicyIdentifier = null; SigPolicyQualifierInfo spqi = null; if (this.policyUri != null && this.policyUri.length() > 0) { spqi = new SigPolicyQualifierInfo(PKCSObjectIdentifiers.id_spq_ets_uri, new DERIA5String(this.policyUri)); } signaturePolicyIdentifier = new SignaturePolicyIdentifier(new SignaturePolicyId(DERObjectIdentifier.getInstance(new DERObjectIdentifier(this.policyIdentifier.replace("urn:oid:", ""))), new OtherHashAlgAndValue(new AlgorithmIdentifier(new ASN1ObjectIdentifier(algId)), new DEROctetString(this.policyHash)), SignUtils.createSigPolicyQualifiers(spqi))); return signaturePolicyIdentifier; } }
@Override public Attribute getValue() { //Atributo 1 ASN1ObjectIdentifier sigPolicyId = new ASN1ObjectIdentifier(signaturePolicy.getSignPolicyInfo().getSignPolicyIdentifier().getValue()); //Atributo 2 OtherHashAlgAndValue sigPolicyHash = new OtherHashAlgAndValue(new AlgorithmIdentifier(new ASN1ObjectIdentifier(signaturePolicy.getSignPolicyHashAlg().getAlgorithm().getValue())), new DEROctetString(signaturePolicy.getSignPolicyHash().getValueUTF8().getBytes())); //Atributo 3 List<SigPolicyQualifierInfo> sigPolicyQualifierInfos = new ArrayList<SigPolicyQualifierInfo>(); ASN1ObjectIdentifier sigPolicyQualifierId = new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.5.1"); DERIA5String sigQualifier = new DERIA5String("xxx"); SigPolicyQualifierInfo bcSigPolicyQualifierInfo = new SigPolicyQualifierInfo(sigPolicyQualifierId, sigQualifier); sigPolicyQualifierInfos.add(bcSigPolicyQualifierInfo); SigPolicyQualifiers sigPolicyQualifiers = new SigPolicyQualifiers(sigPolicyQualifierInfos.toArray(new SigPolicyQualifierInfo[]{})); SignaturePolicyId signaturePolicyId = new SignaturePolicyId(sigPolicyId, sigPolicyHash, sigPolicyQualifiers); return new Attribute(new ASN1ObjectIdentifier(oid), new DERSet(signaturePolicyId)); }
protected ASN1Encodable encodeStringValue(ASN1ObjectIdentifier oid, String value) { if (oid.equals(EmailAddress) || oid.equals(DC)) { return new DERIA5String(value); } else if (oid.equals(DATE_OF_BIRTH)) // accept time string as well as # (for compatibility) { return new ASN1GeneralizedTime(value); } else if (oid.equals(C) || oid.equals(SN) || oid.equals(DN_QUALIFIER) || oid.equals(TELEPHONE_NUMBER)) { return new DERPrintableString(value); } return super.encodeStringValue(oid, value); }
protected ASN1Encodable encodeStringValue(ASN1ObjectIdentifier oid, String value) { if (oid.equals(EmailAddress) || oid.equals(DC)) { return new DERIA5String(value); } else if (oid.equals(DATE_OF_BIRTH)) // accept time string as well as # (for compatibility) { return new ASN1GeneralizedTime(value); } else if (oid.equals(C) || oid.equals(SN) || oid.equals(DN_QUALIFIER) || oid.equals(TELEPHONE_NUMBER)) { return new DERPrintableString(value); } return super.encodeStringValue(oid, value); }