Search in sources :

Example 56 with ASN1Exception

use of com.unboundid.asn1.ASN1Exception in project ldapsdk by pingidentity.

the class EndBatchedTransactionExtendedResult method decodeOpControls.

/**
 * Decodes the provided ASN.1 element as an update controls sequence.  Each
 * element of the sequence should itself be a sequence containing the message
 * ID associated with the operation in which the control was returned and a
 * sequence of the controls included in the response for that operation.
 *
 * @param  element     The ASN.1 element to be decoded.
 * @param  controlMap  The map into which to place the decoded controls.
 *
 * @throws  LDAPException  If a problem occurs while attempting to decode the
 *                         contents of the provided ASN.1 element.
 */
private static void decodeOpControls(@NotNull final ASN1Element element, @NotNull final Map<Integer, Control[]> controlMap) throws LDAPException {
    final ASN1Sequence ctlsSequence;
    try {
        ctlsSequence = ASN1Sequence.decodeAsSequence(element);
    } catch (final ASN1Exception ae) {
        Debug.debugException(ae);
        throw new LDAPException(ResultCode.DECODING_ERROR, ERR_END_TXN_RESPONSE_CONTROLS_NOT_SEQUENCE.get(ae), ae);
    }
    for (final ASN1Element e : ctlsSequence.elements()) {
        final ASN1Sequence ctlSequence;
        try {
            ctlSequence = ASN1Sequence.decodeAsSequence(e);
        } catch (final ASN1Exception ae) {
            Debug.debugException(ae);
            throw new LDAPException(ResultCode.DECODING_ERROR, ERR_END_TXN_RESPONSE_CONTROL_NOT_SEQUENCE.get(ae), ae);
        }
        final ASN1Element[] ctlSequenceElements = ctlSequence.elements();
        if (ctlSequenceElements.length != 2) {
            throw new LDAPException(ResultCode.DECODING_ERROR, ERR_END_TXN_RESPONSE_CONTROL_INVALID_ELEMENT_COUNT.get(ctlSequenceElements.length));
        }
        final int msgID;
        try {
            msgID = ASN1Integer.decodeAsInteger(ctlSequenceElements[0]).intValue();
        } catch (final ASN1Exception ae) {
            Debug.debugException(ae);
            throw new LDAPException(ResultCode.DECODING_ERROR, ERR_END_TXN_RESPONSE_CONTROL_MSGID_NOT_INT.get(ae), ae);
        }
        final ASN1Sequence controlsSequence;
        try {
            controlsSequence = ASN1Sequence.decodeAsSequence(ctlSequenceElements[1]);
        } catch (final ASN1Exception ae) {
            Debug.debugException(ae);
            throw new LDAPException(ResultCode.DECODING_ERROR, ERR_END_TXN_RESPONSE_CONTROLS_ELEMENT_NOT_SEQUENCE.get(ae), ae);
        }
        final Control[] controls = Control.decodeControls(controlsSequence);
        if (controls.length == 0) {
            continue;
        }
        controlMap.put(msgID, controls);
    }
}
Also used : Control(com.unboundid.ldap.sdk.Control) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) LDAPException(com.unboundid.ldap.sdk.LDAPException) ASN1Exception(com.unboundid.asn1.ASN1Exception) ASN1Element(com.unboundid.asn1.ASN1Element)

Aggregations

IOException (java.io.IOException)18 Asn1Exception (es.gob.jmulticard.asn1.Asn1Exception)16 ASN1Exception (com.unboundid.asn1.ASN1Exception)12 TlvException (es.gob.jmulticard.asn1.TlvException)12 Asn1Exception (sun.security.krb5.Asn1Exception)11 ASN1Element (com.unboundid.asn1.ASN1Element)8 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)8 NotNull (com.unboundid.util.NotNull)8 Iso7816FourCardException (es.gob.jmulticard.card.iso7816four.Iso7816FourCardException)7 CertificateException (java.security.cert.CertificateException)7 X509Certificate (java.security.cert.X509Certificate)7 Asn1Exception (org.kse.utilities.asn1.Asn1Exception)7 ASN1Exception (org.wildfly.security.asn1.ASN1Exception)6 ApduConnectionException (es.gob.jmulticard.apdu.connection.ApduConnectionException)5 Cdf (es.gob.jmulticard.asn1.der.pkcs15.Cdf)5 CryptoCardException (es.gob.jmulticard.card.CryptoCardException)5 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)4 DecoderObject (es.gob.jmulticard.asn1.DecoderObject)4 InvalidCardException (es.gob.jmulticard.card.InvalidCardException)4 ArrayList (java.util.ArrayList)4