All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cybersource.flex.sdk.CaptureContext Maven / Gradle / Ivy

package com.cybersource.flex.sdk;

import java.security.PublicKey;
import java.util.Map;

/**
 * Valid capture context always contains: 1. RSA public key
 */
public interface CaptureContext extends FlexApiJwtClaims, FlexApiCorrelationInfo {

    /**
     * WARNING: This method uses public key provided as an argument. Ensure that PublicKey provided is the trusted one.
     *
     * @param publicKey public key used to verify Capture Context signature.
     * @param jwt Capture Context serialized to JWT format
     * @return Processed Capture Context object
     */
    static CaptureContext parse(final PublicKey publicKey, final String jwt) {
        return new CaptureContextImpl(publicKey, jwt, null, System.currentTimeMillis());
    }

    /**
     * Creates an encrypted JWT from provided data. Data to be encrypted should be provided as a map (key-value pars).
     * JWT content is encrypted using Capture Context public key.
     *
     * @param map data to be encrypted
     * @return String representation of JWT(e) - compact serialization
     */
    String jwe(Map map);

    String getFlexOrigin();

    String getTokensPath();

    /**
     * Retrieves a public encryption key from capture context.
     *
     * @return Flex one time use public key
     */
    PublicKey getPublicKey();

    Map getJsonWebKey();

    /**
     * Provides Capture Context Id. This is jti claim of JWT.
     *
     * @return Capture Context Id
     */
    @Override
    String getId();

    /**
     * Returns underlying Capture Context, as returned from CyberSource Flex service.
     * The returned string is in a compact serialization of signed JWT (i.e. header.payload.signature).
     *
     * @return JWT string
     */
    @Override
    String toString();

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy