List of usage examples for org.bouncycastle.asn1 DERSequence DERSequence
public DERSequence(ASN1Encodable[] elements)
From source file:net.sf.keystore_explorer.crypto.x509.PolicyConstraints.java
License:Open Source License
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vec = new ASN1EncodableVector(); if (requireExplicitPolicy != -1) { vec.add(new DERTaggedObject(0, new ASN1Integer(requireExplicitPolicy))); }/*w ww . jav a 2 s.c o m*/ if (inhibitPolicyMapping != -1) { vec.add(new DERTaggedObject(1, new ASN1Integer(inhibitPolicyMapping))); } return new DERSequence(vec); }
From source file:net.sf.keystore_explorer.crypto.x509.PolicyMapping.java
License:Open Source License
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector dv = new ASN1EncodableVector(); dv.add(issuerDomainPolicy);/*from ww w . ja va 2 s .com*/ dv.add(subjectDomainPolicy); return new DERSequence(dv); }
From source file:net.sf.keystore_explorer.crypto.x509.SubjectInfoAccess.java
License:Open Source License
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vec = new ASN1EncodableVector(); Iterator<AccessDescription> it = accessDescriptions.iterator(); while (it.hasNext()) { vec.add(it.next().toASN1Primitive()); }//w ww .j av a 2 s .co m return new DERSequence(vec); }
From source file:net.sf.keystore_explorer.gui.crypto.generalname.DGeneralNameChooser.java
License:Open Source License
private void okPressed() { try {//from w w w .j ava 2 s.c o m GeneralName newGeneralName = null; if (jrbDirectoryName.isSelected()) { X500Name directoryName = jdnDirectoryName.getDistinguishedName(); if (directoryName == null) { JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.DirectoryNameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } newGeneralName = new GeneralName(GeneralName.directoryName, directoryName); } else if (jrbDnsName.isSelected()) { String dnsName = jtfDnsName.getText().trim(); if (dnsName.length() == 0) { JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.DnsNameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } newGeneralName = new GeneralName(GeneralName.dNSName, new DERIA5String(dnsName)); } else if (jrbIpAddress.isSelected()) { String ipAddress = jtfIpAddress.getText().trim(); if (ipAddress.length() == 0) { JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.IpAddressValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } if (!IPAddress.isValid(ipAddress)) { JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.NotAValidIP.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } newGeneralName = new GeneralName(GeneralName.iPAddress, ipAddress); } else if (jrbRegisteredId.isSelected()) { ASN1ObjectIdentifier registeredId = joiRegisteredId.getObjectId(); if (registeredId == null) { JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.RegisteredIdValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } newGeneralName = new GeneralName(GeneralName.registeredID, registeredId); } else if (jrbRfc822Name.isSelected()) { String rfc822Name = jtfRfc822Name.getText().trim(); if (rfc822Name.length() == 0) { JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.Rfc822NameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } newGeneralName = new GeneralName(GeneralName.rfc822Name, new DERIA5String(rfc822Name)); } else if (jrbUniformResourceIdentifier.isSelected()) { String uniformResourceIdentifier = jtfUniformResourceIdentifier.getText().trim(); if (uniformResourceIdentifier.length() == 0) { JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.UniformResourceIdentifierValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } newGeneralName = new GeneralName(GeneralName.uniformResourceIdentifier, new DERIA5String(uniformResourceIdentifier)); } else if (jrbPrincipalName.isSelected()) { String upnString = jtfPrincipalName.getText().trim(); if (upnString.length() == 0) { JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.PrincipalNameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } ASN1EncodableVector asn1Vector = new ASN1EncodableVector(); asn1Vector.add(new ASN1ObjectIdentifier(GeneralNameUtil.UPN_OID)); asn1Vector.add(new DERTaggedObject(true, 0, new DERUTF8String(upnString))); newGeneralName = new GeneralName(GeneralName.otherName, new DERSequence(asn1Vector)); } generalName = newGeneralName; } catch (Exception ex) { DError dError = new DError(this, ex); dError.setLocationRelativeTo(this); dError.setVisible(true); return; } closeDialog(); }
From source file:net.sf.keystore_explorer.gui.crypto.policyinformation.DPolicyInformationChooser.java
License:Open Source License
private void okPressed() { ASN1ObjectIdentifier policyIdentifer = joiPolicyIdentifier.getObjectId(); if (policyIdentifer == null) { JOptionPane.showMessageDialog(this, res.getString("DPolicyInformationChooser.PolicyIdentifierValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return;/*from w ww .j ava 2 s .c om*/ } List<PolicyQualifierInfo> policyQualifierInfo = jpqPolicyQualifiers.getPolicyQualifierInfo(); if (policyQualifierInfo.size() > 0) { ASN1EncodableVector policyQualifiersVec = new ASN1EncodableVector(); for (PolicyQualifierInfo policyQualInfo : policyQualifierInfo) { try { policyQualifiersVec.add(policyQualInfo); } catch (Exception ex) { DError dError = new DError(this, ex); dError.setLocationRelativeTo(this); dError.setVisible(true); return; } } DERSequence policyQualifiersSeq = new DERSequence(policyQualifiersVec); policyInformation = new PolicyInformation(policyIdentifer, policyQualifiersSeq); } else { policyInformation = new PolicyInformation(policyIdentifer); } closeDialog(); }
From source file:net.sf.keystore_explorer.gui.dialogs.extensions.DAuthorityInformationAccess.java
License:Open Source License
private void okPressed() { List<AccessDescription> accessDescriptions = jadAccessDescriptions.getAccessDescriptions(); if (accessDescriptions.size() == 0) { JOptionPane.showMessageDialog(this, res.getString("DAuthorityInformationAccess.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return;//from ww w . jav a2s .c o m } ASN1EncodableVector vec = new ASN1EncodableVector(); for (AccessDescription accessDescription : accessDescriptions) { vec.add(accessDescription); } AuthorityInformationAccess authorityInformationAccess = AuthorityInformationAccess .getInstance(new DERSequence(vec)); try { value = authorityInformationAccess.getEncoded(ASN1Encoding.DER); } catch (IOException ex) { DError dError = new DError(this, ex); dError.setLocationRelativeTo(this); dError.setVisible(true); return; } closeDialog(); }
From source file:net.sf.keystore_explorer.gui.dialogs.extensions.DPrivateKeyUsagePeriod.java
License:Open Source License
private void okPressed() { Date notBefore = jdtNotBefore.getDateTime(); Date notAfter = jdtNotAfter.getDateTime(); if ((notBefore == null) && (notAfter == null)) { JOptionPane.showMessageDialog(this, res.getString("DPrivateKeyUsagePeriod.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return;/*from w w w.j ava2s.c o m*/ } // BC forgot the value constructor for PrivateKeyUsagePeriod... ASN1EncodableVector v = new ASN1EncodableVector(); if (notBefore != null) { DERGeneralizedTime notBeforeGenTime = new DERGeneralizedTime(notBefore); v.add(new DERTaggedObject(false, 0, notBeforeGenTime)); } if (notAfter != null) { DERGeneralizedTime notAfterGenTime = new DERGeneralizedTime(notAfter); v.add(new DERTaggedObject(false, 1, notAfterGenTime)); } PrivateKeyUsagePeriod privateKeyUsagePeriod = PrivateKeyUsagePeriod.getInstance(new DERSequence(v)); try { value = privateKeyUsagePeriod.getEncoded(ASN1Encoding.DER); } catch (IOException ex) { DError dError = new DError(this, ex); dError.setLocationRelativeTo(this); dError.setVisible(true); return; } closeDialog(); }
From source file:net.sourceforge.javacardsign.iso7816_15.AlgorithmInfo.java
License:Open Source License
public DERSequence getDERObject() { DERInteger reference = new DERInteger(this.reference); DERInteger internalIdentifier = new DERInteger(this.internalIdentifier); DERBitString operations = new DERBitString(CommonObjectAttributes.encodeBits(this.operations), CommonObjectAttributes.getPad(this.operations)); DERObjectIdentifier objectId = new DERObjectIdentifier(this.objectId); DERInteger algId = new DERInteger(this.algId); return new DERSequence( new ASN1Encodable[] { reference, internalIdentifier, new DERNull(), operations, objectId, algId }); }
From source file:net.sourceforge.javacardsign.iso7816_15.AuthenticationObjectDirectoryEntry.java
License:Open Source License
public DERObject getDERObject() { return new DERSequence(new ASN1Encodable[] { coa.getDERObject(), caoa.getDERObject(), new DERTaggedObject(1, pa.getDERObject()) }); }
From source file:net.sourceforge.javacardsign.iso7816_15.CertificateDirectoryEntry.java
License:Open Source License
public DERObject getDERObject() { return new DERSequence(new ASN1Encodable[] { coa.getDERObject(), cca.getDERObject(), new DERTaggedObject(1, xca.getDERObject()) }); }