com.ibm.security.access.mobile.authentication

Class ChallengeContext

  • java.lang.Object
    • com.ibm.security.access.mobile.authentication.ChallengeContext


  • public final class ChallengeContext
    extends java.lang.Object
    Implementation of a container of challenge mechanisms that get invoked when an authorization challenge is returned from a request to a protected resource.
    Since:
    1.2.0
    Version:
    1.2.8
    • Method Detail

      • mechanismIdentifiers

        public java.lang.String[] mechanismIdentifiers()
        Returns an array of registered mechanism identifiers.
        Returns:
        an array of registered mechanism identifiers
      • register

        public void register(IChallenge[] mechanisms)
        Registers an array of IChallenge instances.
        Parameters:
        mechanisms - an array of mechanisms to register
      • unregister

        public void unregister(IChallenge mechanism)
        Unregister an IChallenge instances.
        Parameters:
        mechanism - mechanisms to deregister
      • invoke

        public void invoke(java.lang.String endpointUrl,
                           OAuthToken token,
                           IChallengeCallbackHandleResult callback)
                    throws java.lang.IllegalArgumentException
        Invokes a known policy enforcement point.

        Redirects to the same protocol (HTTPS to HTTPS) will be followed automatically. Redirects where the protocol changes (HTTP to HTTPS or vice versa) are not followed automatically. Instead the callback receives a MobileKitException, most likely with a JSON parsing error.

        Parameters:
        endpointUrl - the location of the policy endpoint
        token - the OAuthToken to consume with the request
        callback - the function delegate that is invoked with the ChallengeResult
        Throws:
        java.lang.IllegalArgumentException - if callback is null
      • verify

        public void verify(java.lang.String endpointUrl,
                           OAuthToken token,
                           java.util.Map<java.lang.String,java.lang.String> map,
                           IChallengeCallbackHandleVerify callback)
                    throws java.lang.IllegalArgumentException
        Submits the mechanism for verification.
        Parameters:
        endpointUrl - the location of the policy endpoint
        token - the OAuthToken to consume with the request
        map - a Map representing the postback challenge data
        callback - the function delegate that is invoked with the ChallengeResult
        Throws:
        java.lang.IllegalArgumentException - if callback is null
      • setReadTimeOut

        public void setReadTimeOut(int readTimeOut)
                            throws java.lang.IllegalArgumentException
        Sets the read timeout to a specified timeout, in milliseconds. Default is 30000.
        Parameters:
        readTimeOut - time out in milliseconds
        Throws:
        java.lang.IllegalArgumentException - if parameter is <= 0
      • setConnectionTimeOut

        public void setConnectionTimeOut(int connectionTimeOut)
                                  throws java.lang.IllegalArgumentException
        Sets the connection timeout to a specified timeout, in milliseconds. Default is 30000.
        Parameters:
        connectionTimeOut - time out in milliseconds
        Throws:
        java.lang.IllegalArgumentException - if parameter is <= 0
      • setSslContext

        public void setSslContext(javax.net.ssl.SSLContext sslContext)
        Sets the SSLContext to use self-signed or unknown certificates for HttpsURLConnection. If sslContext is not null, it will be used to validate the HttpsURLConnection, otherwise it won't be set.

        One way to provide a sslContext is described here

        Parameters:
        sslContext - a SSLContext instance that contains the list of certificates
        Since:
        1.2.0
      • setHostnameVerifier

        public void setHostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
        Sets the HostnameVerifier to use self-signed or unknown certificates for HttpsURLConnection, so that the host name is an acceptable match with the server's authentication scheme.

        hostnameVerifier will only be set if sslContext is set as well (not null).

        If hostnameVerifier is not null, the overwritten HostnameVerifier.verify(String, SSLSession) method will be invoked to verify the host name. Otherwise the inherited HostnameVerifier instance is used.

        Parameters:
        hostnameVerifier - a HostnameVerifier instance that contains an overwritten HostnameVerifier.verify(String, SSLSession) method
        Since:
        1.2.0
      • unenroll

        public void unenroll(java.lang.String endpointUrl,
                             OAuthToken token,
                             java.lang.String authenticatorId,
                             java.lang.String enrollmentType,
                             IUnenrollHandleResult callback)
                      throws java.lang.IllegalArgumentException
        Unenroll a challenge mechanism for a device.

        Redirects to the same protocol (HTTPS to HTTPS) will be followed automatically. Redirects where the protocol changes (HTTP to HTTPS or vice versa) are not followed automatically. Instead the callback receives a MobileKitException, most likely with a JSON parsing error.

        Parameters:
        endpointUrl - the location of the endpoint to unenroll a challenge
        token - the OAuthToken to consume with the request
        authenticatorId - the identifier of the device
        enrollmentType - the type of enrollment
        callback - the function delegate that is invoked with the UnenrollResult
        Throws:
        java.lang.IllegalArgumentException - if callback is null
      • enroll

        public void enroll(java.lang.String endpointUrl,
                           OAuthToken token,
                           IEnrollment enrollment,
                           IEnrollmentHandleResult callback)
                    throws java.lang.IllegalArgumentException
        Enroll a challenge mechanism for a device.
        Parameters:
        endpointUrl - the location of the endpoint to enroll a challenge
        token - the OAuthToken to consume with the request
        enrollment - the IEnrollment interface, representing the enrollment object
        callback - the function delegate that is invoked with the EnrollmentResult
        Throws:
        java.lang.IllegalArgumentException - if callback is null
      • pendingTransactions

        public void pendingTransactions(java.lang.String endpointUrl,
                                        OAuthToken token,
                                        boolean nextTransaction,
                                        java.util.Comparator<PendingTransaction> orderBy,
                                        IPendingTransactionCallback callback)
                                 throws java.lang.IllegalArgumentException
        Executes a query for pending transactions requiring a challenge.
        Parameters:
        endpointUrl - the location of the policy endpoint
        token - the OAuthToken to consume with the request
        nextTransaction - filters the transactions only to return the next pending.
        orderBy - a Comparator<PendingTransaction> that orders the list of transactions. If the parameter is null, the transactions get ordered descending by their PendingTransaction.createdDate (newest first).
        callback - the function delegate that is invoked with PendingTransactionsResult
        Throws:
        java.lang.IllegalArgumentException - if callback is null
      • pendingTransactions

        public void pendingTransactions(java.lang.String endpointUrl,
                                        OAuthToken token,
                                        java.util.Comparator<PendingTransaction> orderBy,
                                        IPendingTransactionCallback callback)
                                 throws java.lang.IllegalArgumentException
        Executes a query for pending transactions requiring a challenge.
        Parameters:
        endpointUrl - the location of the policy endpoint
        token - the OAuthToken to consume with the request
        orderBy - a Comparator<PendingTransaction> that orders the list of transactions. If the parameter is null, the transactions get ordered descending by their PendingTransaction.createdDate (newest first).
        callback - the function delegate that is invoked with PendingTransactionsResult
        Throws:
        java.lang.IllegalArgumentException - if callback is null
      • pendingTransactions

        public void pendingTransactions(java.lang.String endpointUrl,
                                        OAuthToken token,
                                        IPendingTransactionCallback callback)
                                 throws java.lang.IllegalArgumentException
        Executes a query for pending transactions requiring a challenge.
        Parameters:
        endpointUrl - the location of the policy endpoint
        token - the OAuthToken to consume with the request
        callback - the function delegate that is invoked with PendingTransactionsResult
        Throws:
        java.lang.IllegalArgumentException - if callback is null
      • pendingTransactions

        public void pendingTransactions(java.lang.String endpointUrl,
                                        OAuthToken token,
                                        boolean nextTransaction,
                                        IPendingTransactionCallback callback)
                                 throws java.lang.IllegalArgumentException
        Executes a query for pending transactions requiring a challenge.
        Parameters:
        endpointUrl - the location of the policy endpoint
        token - the OAuthToken to consume with the request
        nextTransaction - filters the transactions only to return the next pending.
        callback - the function delegate that is invoked with PendingTransactionsResult
        Throws:
        java.lang.IllegalArgumentException - if callback is null
      • pendingTransactions

        public void pendingTransactions(java.lang.String endpointUrl,
                                        OAuthToken token,
                                        java.lang.String transactionId,
                                        IPendingTransactionCallback callback)
                                 throws java.lang.IllegalArgumentException
        Executes a query for pending transactions requiring a challenge.
        Parameters:
        endpointUrl - the location of the policy endpoint
        token - the OAuthToken to consume with the request
        transactionId - the unique identifier of the transaction
        callback - the function delegate that is invoked with PendingTransactionsResult
        Throws:
        java.lang.IllegalArgumentException - if callback is null
      • toString

        public java.lang.String toString()
        Returns a textually representation of the instance with attribute names and values.
        Overrides:
        toString in class java.lang.Object
        Returns:
        textually representation of the instance