use of com.github.zhenwei.core.asn1.ASN1Integer in project ldapsdk by pingidentity.
the class RSAPrivateKeyTestCase method testDecodeKeyInvalidVersion.
/**
* Tests the behavior when trying to decode a private key with an invalid
* version.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { CertException.class })
public void testDecodeKeyInvalidVersion() throws Exception {
final ASN1Sequence pkSequence = new ASN1Sequence(new ASN1Integer(123), new ASN1BigInteger(BigInteger.ONE), new ASN1BigInteger(BigInteger.ONE), new ASN1BigInteger(BigInteger.ONE), new ASN1BigInteger(BigInteger.ONE), new ASN1BigInteger(BigInteger.ONE), new ASN1BigInteger(BigInteger.ONE), new ASN1BigInteger(BigInteger.ONE), new ASN1BigInteger(BigInteger.ONE));
new RSAPrivateKey(new ASN1OctetString(pkSequence.encode()));
}
use of com.github.zhenwei.core.asn1.ASN1Integer in project ldapsdk by pingidentity.
the class PersistentSearchRequestControl method encodeValue.
/**
* Encodes the provided information into an octet string that can be used as
* the value for this control.
*
* @param changeTypes The set of change types for which to register. It
* must not be {@code null} or empty.
* @param changesOnly Indicates whether the search should only return search
* result entries for changes made to entries matching
* the search criteria, or if existing matching entries
* in the server should be returned as well.
* @param returnECs Indicates whether the search result entries returned
* as part of this persistent search should include the
* entry change notification control.
*
* @return An ASN.1 octet string that can be used as the value for this
* control.
*/
@NotNull()
private static ASN1OctetString encodeValue(@NotNull final Set<PersistentSearchChangeType> changeTypes, final boolean changesOnly, final boolean returnECs) {
Validator.ensureNotNull(changeTypes);
Validator.ensureFalse(changeTypes.isEmpty(), "PersistentSearchRequestControl.changeTypes must not be empty.");
final ASN1Element[] elements = { new ASN1Integer(PersistentSearchChangeType.encodeChangeTypes(changeTypes)), new ASN1Boolean(changesOnly), new ASN1Boolean(returnECs) };
return new ASN1OctetString(new ASN1Sequence(elements).encode());
}
use of com.github.zhenwei.core.asn1.ASN1Integer in project ldapsdk by pingidentity.
the class ActiveDirectoryDirSyncControl method encodeValue.
/**
* Encodes the provided information into a format appropriate for use as the
* value of a DirSync control.
*
* @param flags The value of the flags that should be used for
* DirSync operation. This should be zero if no
* special flags or needed, or a bitwise OR of the
* values of the individual flags that are desired.
* @param maxAttributeCount The maximum number of attributes to return.
* @param cookie A cookie that may be used to resume a previous
* DirSync search. This may be {@code null} if
* no previous cookie is available.
*
* @return An ASN.1 octet string containing the encoded control value.
*/
@NotNull()
private static ASN1OctetString encodeValue(final int flags, final int maxAttributeCount, @Nullable final ASN1OctetString cookie) {
final ASN1Element[] valueElements = new ASN1Element[3];
valueElements[0] = new ASN1Integer(flags);
valueElements[1] = new ASN1Integer(maxAttributeCount);
if (cookie == null) {
valueElements[2] = new ASN1OctetString();
} else {
valueElements[2] = cookie;
}
return new ASN1OctetString(new ASN1Sequence(valueElements).encode());
}
use of com.github.zhenwei.core.asn1.ASN1Integer in project ldapsdk by pingidentity.
the class MatchingEntryCountRequestControlTestCase method testDecodeValueSequenceNegativeMaxCandidatesToExamine.
/**
* Tests the behavior when trying to decode a control whose value sequence
* includes a max candidates to examine element with a negative value.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceNegativeMaxCandidatesToExamine() throws Exception {
final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Integer((byte) 0x80, -1));
new MatchingEntryCountRequestControl(new Control("1.3.6.1.4.1.30221.2.5.36", true, new ASN1OctetString(valueSequence.encode())));
}
use of com.github.zhenwei.core.asn1.ASN1Integer in project ldapsdk by pingidentity.
the class MatchingEntryCountResponseControlTestCase method testDecodeNegativeZeroUpperBound.
/**
* Tests the behavior when trying to decode a control whose value sequence
* contains an upper bound value of zero.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeNegativeZeroUpperBound() throws Exception {
final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Integer((byte) 0x82, -1));
new MatchingEntryCountResponseControl("1.3.6.1.4.1.30221.2.5.37", false, new ASN1OctetString(valueSequence.encode()));
}
Aggregations