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

com.identityblitz.scs.service.ServiceProvider Maven / Gradle / Ivy

Go to download

The Java implementation of Secure Cookie Session (SCS). The implementation conforms RFC 6896 (https://tools.ietf.org/html/rfc6896).

The newest version!
package com.identityblitz.scs.service;

import com.identityblitz.scs.service.spi.ConfigurationService;
import com.identityblitz.scs.service.spi.CryptoTransformationService;
import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * The service provider allows to obtain the following services:
 *  - cryptographic transformation service;
 *  - configuration service.
 */
public enum ServiceProvider {
    INSTANCE;

    private static final CryptoTransformationService cryptoService;
    private static final ConfigurationService configService;

    static {
        final Iterator cItr =
                ServiceLoader.load(ConfigurationService.class).iterator();
        if(!cItr.hasNext())
            throw new RuntimeException("configuration service is undefined.");
        configService = cItr.next();

        final Iterator ctsItr =
                ServiceLoader.load(CryptoTransformationService.class).iterator();
        if(!ctsItr.hasNext())
            throw new RuntimeException("cryptographic transformation service is undefined.");
        cryptoService = ctsItr.next();
    }

    public static ServiceProvider service() {
        return INSTANCE;
    }

    public CryptoTransformationService getCryptoService() {
        return cryptoService;
    }

    public ConfigurationService getConfiguration() {
        return configService;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy