use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project keystore-explorer by kaikramer.
the class DGeneralNameChooser method okPressed.
private void okPressed() {
try {
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();
}
use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project keystore-explorer by kaikramer.
the class DPolicyMappingChooser method populate.
private void populate(PolicyMapping policyMapping) {
if (policyMapping != null) {
ASN1ObjectIdentifier issuerDomainPolicy = policyMapping.getIssuerDomainPolicy();
ASN1ObjectIdentifier subjectDomainPolicy = policyMapping.getSubjectDomainPolicy();
joiIssuerDomainPolicy.setObjectId(issuerDomainPolicy);
joiSubjectDomainPolicy.setObjectId(subjectDomainPolicy);
}
}
use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project keystore-explorer by kaikramer.
the class DPolicyMappingChooser method okPressed.
private void okPressed() {
ASN1ObjectIdentifier issuerDomainPolicy = joiIssuerDomainPolicy.getObjectId();
if (issuerDomainPolicy == null) {
JOptionPane.showMessageDialog(this, res.getString("DPolicyMappingChooser.IssuerDomainPolicyValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
ASN1ObjectIdentifier subjectDomainPolicy = joiSubjectDomainPolicy.getObjectId();
if (subjectDomainPolicy == null) {
JOptionPane.showMessageDialog(this, res.getString("DPolicyMappingChooser.SubjectDomainPolicyValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
policyMapping = new PolicyMapping(issuerDomainPolicy, subjectDomainPolicy);
closeDialog();
}
use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project keystore-explorer by kaikramer.
the class Spkac method decodeSpkac.
private void decodeSpkac(byte[] der) throws SpkacException {
try {
ASN1Sequence signedPublicKeyAndChallenge = ASN1Sequence.getInstance(der);
ASN1Sequence publicKeyAndChallenge = (ASN1Sequence) signedPublicKeyAndChallenge.getObjectAt(0);
ASN1Sequence signatureAlgorithm = (ASN1Sequence) signedPublicKeyAndChallenge.getObjectAt(1);
DERBitString signature = (DERBitString) signedPublicKeyAndChallenge.getObjectAt(2);
ASN1ObjectIdentifier signatureAlgorithmOid = (ASN1ObjectIdentifier) signatureAlgorithm.getObjectAt(0);
ASN1Sequence spki = (ASN1Sequence) publicKeyAndChallenge.getObjectAt(0);
DERIA5String challenge = (DERIA5String) publicKeyAndChallenge.getObjectAt(1);
ASN1Sequence publicKeyAlgorithm = (ASN1Sequence) spki.getObjectAt(0);
DERBitString publicKey = (DERBitString) spki.getObjectAt(1);
ASN1ObjectIdentifier publicKeyAlgorithmOid = (ASN1ObjectIdentifier) publicKeyAlgorithm.getObjectAt(0);
ASN1Primitive algorithmParameters = publicKeyAlgorithm.getObjectAt(1).toASN1Primitive();
this.challenge = challenge.getString();
this.publicKey = decodePublicKeyFromBitString(publicKeyAlgorithmOid, algorithmParameters, publicKey);
this.signatureAlgorithm = getSignatureAlgorithm(signatureAlgorithmOid);
this.signature = signature.getBytes();
} catch (Exception ex) {
throw new SpkacException(res.getString("NoDecodeSpkac.exception.message"), ex);
}
}
use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project keystore-explorer by kaikramer.
the class SpkacSubject method getRdn.
private String getRdn(X500Name name, ASN1ObjectIdentifier rdnOid) {
RDN[] rdns = name.getRDNs(rdnOid);
if (rdns.length > 0) {
RDN rdn = rdns[0];
String value = rdn.getFirst().getValue().toString();
return value;
}
return null;
}
Aggregations