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();
}
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);
}
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);
}
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);
}
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 "";
}
}
Aggregations