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

restx.security.EmptySessionProvider Maven / Gradle / Ivy

There is a newer version: 1.2.0-rc2
Show newest version
package restx.security;

import com.google.common.base.Optional;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import org.joda.time.Duration;
import restx.factory.Component;
import restx.security.RestxSession.Definition;

/**
 * A component able to provide an empty session.
 *
 * This is useful especially for testing, allowing to create an empty RestxSession
 * and then populate it.
 */
@Component
public class EmptySessionProvider implements Supplier {
    private final Definition definition;

    public EmptySessionProvider(Definition definition) {
        this.definition = definition;
    }

    @Override
    public RestxSession get() {
        return new RestxSession(definition,
                ImmutableMap.of(),
                Optional.absent(),
                Duration.ZERO);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy