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

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

package com.cybersource.flex.sdk;

import com.cybersource.flex.sdk.impl.HttpResponse;
import com.cybersource.flex.sdk.repackaged.JSONObject;
import com.cybersource.flex.sdk.repackaged.JSONTokener;

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

public final class TransientTokenImpl extends JwtJwtClaimsImpl implements TransientToken {

    TransientTokenImpl(final PublicKey publicKey, final String jwt, final String correlationId, long startTime) {
        super(publicKey, jwt, correlationId, startTime);
    }

    static TransientToken fromHttpResponse(PublicKey publicKey, HttpResponse response, long startTime) {
        String resBody = response.getBody();
        JSONObject tokenResponse = new JSONObject(new JSONTokener(resBody));
        String token = tokenResponse.getString("token");

        return new TransientTokenImpl(publicKey, token, response.getHeaderFirstValue("v-c-correlation-id"), startTime);
    }

    @Override
    public Map getData() {
        return jwt.payload("data");
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy