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

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

package com.cybersource.flex.sdk;

public interface Credentials {

    enum Environment {
        /**
         * Denotes production environment.
         */
        PRODUCTION("flex.cybersource.com", "/flex/v1/keys?format=JWT"),
        /**
         * Denotes merchant facing test environment. Test environment is called
         * "sandbox" for Visa Developer Center and "CAS" for CyberSource Developer
         * Platform.
         * CAS stands for Customer Acceptance Simulation
         */
        SANDBOX("testflex.cybersource.com", "/flex/v1/keys?format=JWT");

        private final String host;
        private final String path;
        private final String url;

        private Environment(String host, String path) {
            this.host = host;
            this.path = path;
            this.url = "https://" + host + path;
        }

        public String getHost() {
            return host;
        }

        public String getPath() {
            return path;
        }

        public String getUrl() {
            return url;
        }
    }

    /**
     * for client (i.e. Android) use-cases
     *
     * @param environment
     * @return no-auth credentials
     */
    static Credentials noAuthentication(final Environment environment) {
        return new NoAuthentication(environment);
    }

    static Credentials httpSignature(Environment environment, String mid, String keyId, char[] sharedSecret) {
        return new CredentialsImpl(environment, mid, keyId, sharedSecret);
    }

    /**
     * Retrieves environment
     *
     * @return environment referenced by this credentials instance
     */
    Environment getEnvironment();

    final class NoAuthentication implements Credentials {

        private final Environment environment;

        private NoAuthentication(Environment environment) {
            this.environment = environment;
        }

        @Override
        public Environment getEnvironment() {
            return environment;
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy