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

ru.foodtechlab.lib.auth.service.domain.token.config.TokenConfig Maven / Gradle / Ivy

There is a newer version: 4.1.0
Show newest version
package ru.foodtechlab.lib.auth.service.domain.token.config;

import com.rcore.domain.security.model.AccessTokenData;
import com.rcore.domain.security.model.RefreshTokenData;
import com.rcore.domain.security.port.TokenGenerator;
import com.rcore.domain.security.port.TokenParser;
import lombok.Getter;
import lombok.experimental.Accessors;
import ru.foodtechlab.lib.auth.service.domain.auth.port.AuthorizationSessionRepository;
import ru.foodtechlab.lib.auth.service.domain.credential.port.CredentialRepository;
import ru.foodtechlab.lib.auth.service.domain.token.port.*;
import ru.foodtechlab.lib.auth.service.domain.token.usecases.*;

@Accessors(fluent = true)
@Getter
public class TokenConfig {

    private final CreateAccessTokenUseCase createAccessToken;
    private final CreateRefreshTokenUseCase createRefreshToken;
    private final DeactivateAccessTokensByRefreshToken deactivateAccessTokensByRefreshToken;
    private final DeactivateTokensByCredentialUseCase deactivateTokensByCredentialUseCase;
    private final DecodeAccessTokenUseCase decodeAccessToken;
    private final DecodeRefreshTokenUseCase decodeRefreshToken;
    private final EncodeAccessTokenUseCase encodeAccessToken;
    private final EncodeRefreshTokenUseCase encodeRefreshToken;
    private final ExpireAccessTokensByRefreshTokenUseCase expireAccessTokensByRefreshToken;
    private final ExpireAccessTokenByStatusUseCase expireAccessToken;
    private final ExpireRefreshTokenByStatusUseCase expireRefreshToken;
    private final FindAccessTokensUseCase findAccessTokens;
    private final FindRefreshTokensUseCase findRefreshTokens;
    private final FindRefreshTokenByIdUseCase findRefreshTokenById;
    private final ForceFindRefreshTokenByIdUseCase forceFindRefreshTokenById;
    private final FindAccessTokenByIdUseCase findAccessTokenById;
    private final FindAccessTokensByRefreshTokenUseCase findAccessTokensByRefreshToken;
    private final CreateTokenPairUseCase createTokenPairUseCase;
    private final ForceFindAccessTokenByIdUseCase forceFindAccessTokenByIdUseCase;

    public TokenConfig(
            AccessTokenRepository accessTokenRepository,
            AccessTokenIdGenerator accessTokenIdGenerator,
            RefreshTokenRepository refreshTokenRepository,
            RefreshTokenIdGenerator refreshTokenIdGenerator,
            TokenSaltGenerator tokenSaltGenerator,
            TokenGenerator accessTokenDataTokenGenerator,
            TokenParser accessTokenDataTokenParser,
            TokenGenerator refreshTokenDataTokenGenerator,
            TokenParser refreshTokenDataTokenParser,
            CredentialRepository credentialRepository,
            TokenLifeCycleConfig tokenLifeCycleConfig,
            AuthorizationSessionRepository authorizationSessionRepository
    ) {
        this.findAccessTokenById = new FindAccessTokenByIdUseCase(accessTokenRepository);
        this.findRefreshTokenById = new FindRefreshTokenByIdUseCase(refreshTokenRepository);
        this.findRefreshTokens = new FindRefreshTokensUseCase(refreshTokenRepository);
        this.findAccessTokens = new FindAccessTokensUseCase(accessTokenRepository);
        this.expireAccessToken = new ExpireAccessTokenByStatusUseCase(accessTokenRepository);
        this.encodeRefreshToken = new EncodeRefreshTokenUseCase(findRefreshTokenById, refreshTokenDataTokenGenerator);
        this.encodeAccessToken = new EncodeAccessTokenUseCase(findAccessTokenById, accessTokenDataTokenGenerator);
        this.decodeRefreshToken = new DecodeRefreshTokenUseCase(findRefreshTokenById, refreshTokenDataTokenParser);
        this.decodeAccessToken = new DecodeAccessTokenUseCase(findAccessTokenById, accessTokenDataTokenParser);
        this.createAccessToken = new CreateAccessTokenUseCase(accessTokenRepository, accessTokenIdGenerator, tokenLifeCycleConfig);
        this.createRefreshToken = new CreateRefreshTokenUseCase(refreshTokenRepository, refreshTokenIdGenerator, tokenSaltGenerator, tokenLifeCycleConfig);
        this.deactivateAccessTokensByRefreshToken = new DeactivateAccessTokensByRefreshToken(accessTokenRepository);
        this.deactivateTokensByCredentialUseCase = new DeactivateTokensByCredentialUseCase(accessTokenRepository, refreshTokenRepository);
        this.expireAccessTokensByRefreshToken = new ExpireAccessTokensByRefreshTokenUseCase(accessTokenRepository);
        this.expireRefreshToken = new ExpireRefreshTokenByStatusUseCase(refreshTokenRepository, deactivateAccessTokensByRefreshToken);
        this.findAccessTokensByRefreshToken = new FindAccessTokensByRefreshTokenUseCase(accessTokenRepository);
        this.createTokenPairUseCase = new CreateTokenPairUseCase(createRefreshToken, createAccessToken, accessTokenDataTokenGenerator, refreshTokenDataTokenGenerator, authorizationSessionRepository);
        this.forceFindAccessTokenByIdUseCase = new ForceFindAccessTokenByIdUseCase(accessTokenRepository);
        this.forceFindRefreshTokenById = new ForceFindRefreshTokenByIdUseCase(refreshTokenRepository);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy