use of com.unboundid.util.OID in project ldapsdk by pingidentity.
the class X509CertificateExtensionTestCase method testNonCriticalWithNonPrintableValue.
/**
* Tests the behavior with a non-critical extension and a non-printable value.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testNonCriticalWithNonPrintableValue() throws Exception {
X509CertificateExtension extension = new X509CertificateExtension(new OID("1.2.3.5"), false, new byte[100]);
extension = new X509CertificateExtension(extension);
assertNotNull(extension.getOID());
assertEquals(extension.getOID().toString(), "1.2.3.5");
assertFalse(extension.isCritical());
assertNotNull(extension.getValue());
assertEquals(extension.getValue(), new byte[100]);
assertNotNull(extension.encode());
assertNotNull(extension.getExtensionName());
assertEquals(extension.getExtensionName(), "1.2.3.5");
assertNotNull(extension.toString());
}
use of com.unboundid.util.OID in project ldapsdk by pingidentity.
the class X509CertificateExtensionTestCase method testEncodeWithMalformedOID.
/**
* Tests the behavior when trying to encode an extension with a malformed OID.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { CertException.class })
public void testEncodeWithMalformedOID() throws Exception {
final X509CertificateExtension extension = new X509CertificateExtension(new OID("1234.56789"), false, new byte[100]);
extension.encode();
}
use of com.unboundid.util.OID in project ldapsdk by pingidentity.
the class X509CertificateTestCase method testDecodeMalformedIssuerUniqueID.
/**
* Tests the behavior when trying to decode a certificate with a malformed
* issuer unique ID.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { CertException.class })
public void testDecodeMalformedIssuerUniqueID() throws Exception {
final long notBefore = System.currentTimeMillis();
final long notAfter = notBefore + (365L * 24L * 60L * 60L * 1000L);
final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Sequence(new ASN1Element((byte) 0xA0, new ASN1Integer(2).encode()), new ASN1BigInteger(12435L), new ASN1Sequence(new ASN1ObjectIdentifier(new OID("1.2.3.4")), new ASN1Null()), X509Certificate.encodeName(new DN("CN=issuer")), new ASN1Sequence(new ASN1GeneralizedTime(notBefore), new ASN1GeneralizedTime(notAfter)), X509Certificate.encodeName(new DN("CN=ldap.example.com")), new ASN1Sequence(new ASN1Sequence(new ASN1ObjectIdentifier(new OID("1.2.3.5")), new ASN1Null()), new ASN1BitString(new boolean[1024])), new ASN1Element((byte) 0x81)), new ASN1Sequence(new ASN1ObjectIdentifier(new OID("1.2.3.4")), new ASN1Null()), new ASN1BitString(new boolean[1024]));
new X509Certificate(valueSequence.encode());
}
use of com.unboundid.util.OID in project ldapsdk by pingidentity.
the class X509CertificateTestCase method testDecodeMalformedExtension.
/**
* Tests the behavior when trying to decode a certificate with a malformed
* subject unique ID.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { CertException.class })
public void testDecodeMalformedExtension() throws Exception {
final long notBefore = System.currentTimeMillis();
final long notAfter = notBefore + (365L * 24L * 60L * 60L * 1000L);
final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Sequence(new ASN1Element((byte) 0xA0, new ASN1Integer(2).encode()), new ASN1BigInteger(12435L), new ASN1Sequence(new ASN1ObjectIdentifier(new OID("1.2.3.4")), new ASN1Null()), X509Certificate.encodeName(new DN("CN=issuer")), new ASN1Sequence(new ASN1GeneralizedTime(notBefore), new ASN1GeneralizedTime(notAfter)), X509Certificate.encodeName(new DN("CN=ldap.example.com")), new ASN1Sequence(new ASN1Sequence(new ASN1ObjectIdentifier(new OID("1.2.3.5")), new ASN1Null()), new ASN1BitString(new boolean[1024])), new ASN1Element((byte) 0xA3)), new ASN1Sequence(new ASN1ObjectIdentifier(new OID("1.2.3.4")), new ASN1Null()), new ASN1BitString(new boolean[1024]));
new X509Certificate(valueSequence.encode());
}
use of com.unboundid.util.OID in project ldapsdk by pingidentity.
the class X509CertificateTestCase method testDecodeMalformedSignatureBitString.
/**
* Tests the behavior when trying to decode a certificate with a malformed
* signature bit string.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { CertException.class })
public void testDecodeMalformedSignatureBitString() throws Exception {
final long notBefore = System.currentTimeMillis();
final long notAfter = notBefore + (365L * 24L * 60L * 60L * 1000L);
final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Sequence(new ASN1Element((byte) 0xA0, new ASN1Integer(2).encode()), new ASN1BigInteger(12435L), new ASN1Sequence(new ASN1ObjectIdentifier(new OID("1.2.3.4")), new ASN1Null()), X509Certificate.encodeName(new DN("CN=issuer")), new ASN1Sequence(new ASN1GeneralizedTime(notBefore), new ASN1GeneralizedTime(notAfter)), X509Certificate.encodeName(new DN("CN=ldap.example.com")), new ASN1Sequence(new ASN1Sequence(new ASN1ObjectIdentifier(new OID("1.2.3.5")), new ASN1Null()), new ASN1BitString(new boolean[1024]))), new ASN1Sequence(new ASN1ObjectIdentifier(new OID("1.2.3.5")), new ASN1Null()), new ASN1BitString(new boolean[1024]));
new X509Certificate(valueSequence.encode());
}
Aggregations