use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X509CertSelector method setIssuer.
/**
* <b>Do not use</b>, use {@link #getIssuer()} or
* {@link #getIssuerAsBytes()} instead. Sets the issuer that a certificate
* must match.
*
* @param issuerName
* the issuer in a RFC 2253 format string, or {@code null} to not
* check the issuer.
* @throws IOException
* if parsing the issuer fails.
*/
public void setIssuer(String issuerName) throws IOException {
if (issuerName == null) {
this.issuer = null;
this.issuerName = null;
this.issuerBytes = null;
return;
}
try {
this.issuer = new X500Principal(issuerName);
this.issuerName = issuerName;
this.issuerBytes = null;
} catch (IllegalArgumentException e) {
throw new IOException(e.getMessage());
}
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X509CertificateTest method getSubjectX500Principal.
private void getSubjectX500Principal(CertificateFactory f) throws Exception {
X509Certificate c = getCertificate(f, CERT_RSA);
final byte[] expected = new byte[] { 0x30, 0x60, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x43, 0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x09, 0x53, 0x61, 0x6e, 0x20, 0x4d, 0x61, 0x74, 0x65, 0x6f, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0e, 0x47, 0x65, 0x6e, 0x69, 0x75, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x06, 0x4e, 0x65, 0x74, 0x4f, 0x70, 0x73 };
X500Principal princ = c.getSubjectX500Principal();
assertEquals(Arrays.toString(expected), Arrays.toString(princ.getEncoded()));
assertEquals("OU=NetOps,O=Genius.com Inc,L=San Mateo,ST=California,C=US", princ.getName());
assertEquals("ou=netops,o=genius.com inc,l=san mateo,st=california,c=us", princ.getName(X500Principal.CANONICAL));
assertEquals("OU=NetOps, O=Genius.com Inc, L=San Mateo, ST=California, C=US", princ.getName(X500Principal.RFC1779));
assertEquals("OU=NetOps,O=Genius.com Inc,L=San Mateo,ST=California,C=US", princ.getName(X500Principal.RFC2253));
X509Certificate c2 = getCertificate(f, CERT_RSA);
assertEquals(princ, c2.getSubjectX500Principal());
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class X509CRLSelectorTest method testGetIssuersImmutable.
public void testGetIssuersImmutable() {
X509CRLSelector crlSelector = new X509CRLSelector();
crlSelector.addIssuer(PRINCIPAL);
Collection<X500Principal> issuers = crlSelector.getIssuers();
try {
issuers.clear();
fail();
} catch (UnsupportedOperationException expected) {
}
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class DistinguishedNameParserTest method assertFirstCn.
private void assertFirstCn(String dn, String expected) {
X500Principal principal = new X500Principal(dn);
assertEquals(dn, expected, new DistinguishedNameParser(principal).findMostSpecific("cn"));
}
use of javax.security.auth.x500.X500Principal in project robovm by robovm.
the class OpenSSLSocketImpl method clientCertificateRequested.
// used by NativeCrypto.SSLHandshakeCallbacks / client_cert_cb
@SuppressWarnings("unused")
public void clientCertificateRequested(byte[] keyTypeBytes, byte[][] asn1DerEncodedPrincipals) throws CertificateEncodingException, SSLException {
String[] keyTypes = new String[keyTypeBytes.length];
for (int i = 0; i < keyTypeBytes.length; i++) {
keyTypes[i] = CipherSuite.getClientKeyType(keyTypeBytes[i]);
}
X500Principal[] issuers;
if (asn1DerEncodedPrincipals == null) {
issuers = null;
} else {
issuers = new X500Principal[asn1DerEncodedPrincipals.length];
for (int i = 0; i < asn1DerEncodedPrincipals.length; i++) {
issuers[i] = new X500Principal(asn1DerEncodedPrincipals[i]);
}
}
setCertificate(sslParameters.getKeyManager().chooseClientAlias(keyTypes, issuers, this));
}
Aggregations