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

fun.fengwk.convention4j.oauth2.server.service.mode.ClientCredentialsMode Maven / Gradle / Ivy

package fun.fengwk.convention4j.oauth2.server.service.mode;

import fun.fengwk.convention4j.oauth2.server.manager.OAuth2ClientManager;
import fun.fengwk.convention4j.oauth2.server.manager.OAuth2SubjectManager;
import fun.fengwk.convention4j.oauth2.server.model.OAuth2Client;
import fun.fengwk.convention4j.oauth2.server.model.OAuth2Token;
import fun.fengwk.convention4j.oauth2.server.model.context.ClientCredentialsTokenContext;
import fun.fengwk.convention4j.oauth2.server.repo.OAuth2TokenRepository;
import fun.fengwk.convention4j.oauth2.share.constant.GrantType;
import fun.fengwk.convention4j.oauth2.share.constant.OAuth2Mode;

/**
 * @author fengwk
 */
public class ClientCredentialsMode
    extends BaseOAuth2TokenService {

    public ClientCredentialsMode(OAuth2ClientManager clientManager,
                                    OAuth2SubjectManager subjectManager,
                                    OAuth2TokenRepository oauth2TokenRepository) {
        super(clientManager, subjectManager, oauth2TokenRepository);
    }

    @Override
    protected GrantType getGrantType() {
        return OAuth2Mode.CLIENT_CREDENTIALS.getGrantType();
    }

    @Override
    protected OAuth2Token generateOAuth2Token(ClientCredentialsTokenContext context, OAuth2Client client) {
        checkScope(client, context.getScope());
        String ssoId = getSsoId(context);
        return generateToken(context.getSubjectId(), context.getScope(), client, ssoId);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy