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

ru.foodtechlab.lib.auth.service.domain.token.usecases.EncodeAccessTokenUseCase Maven / Gradle / Ivy

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

import com.rcore.domain.commons.usecase.UseCase;
import com.rcore.domain.commons.usecase.model.IdInputValues;
import com.rcore.domain.commons.usecase.model.SingleInput;
import com.rcore.domain.commons.usecase.model.SingleOutput;
import com.rcore.domain.security.model.AccessTokenData;
import com.rcore.domain.security.port.TokenGenerator;
import lombok.RequiredArgsConstructor;
import ru.foodtechlab.lib.auth.service.domain.token.exception.AccessTokenNotFoundException;

@RequiredArgsConstructor
public class EncodeAccessTokenUseCase extends UseCase, SingleOutput> {

    private final FindAccessTokenByIdUseCase findAccessTokenById;
    private final TokenGenerator accessTokenDataTokenGenerator;

    @Override
    public SingleOutput execute(SingleInput input) {
        return SingleOutput.of(findAccessTokenById.execute(IdInputValues.of(input.getValue()))
                .getEntity()
                .map(a -> accessTokenDataTokenGenerator.generate(a.toAccessTokenData()))
                .orElseThrow(AccessTokenNotFoundException::new));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy