Моя фабрика: < /p>
Код: Выделить всё
public class MyTokenExchangeProviderFactory implements TokenExchangeProviderFactory, EnvironmentDependentProviderFactory {
private static final String PROVIDER_ID = "standard" (or "default");
@Override
public TokenExchangeProvider create(KeycloakSession keycloakSession) {
return new MyTokenExchangeProvider();
}
@Override
public void init(Config.Scope scope) {}
@Override
public void postInit(KeycloakSessionFactory keycloakSessionFactory) {}
@Override
public void close() {}
@Override
public String getId() {
return PROVIDER_ID;
}
@Override
public int order() {
return 20; // 10 - for Standard and specifying more than 10 should have set priority to my provider but it seems not work
}
@Override
public boolean isSupported(Config.Scope scope) {
return Profile.isFeatureEnabled(Profile.Feature.TOKEN_EXCHANGE_STANDARD_V2);
}
< /code>
или < /p>
@Override
public boolean isSupported(Config.Scope scope) {
return Profile.isFeatureEnabled(Profile.Feature.TOKEN_EXCHANGE);
}
< /code>
mytokenexchangeprovider class: < /p>
public class MyTokenExchangeProvider extends StandardTokenExchangeProvider (or V1TokenExchangeProvider) {
@Override
public boolean supports(TokenExchangeContext tokenExchangeContext) {
return false;
}
@Override
public Response exchange(TokenExchangeContext context) {
this.params = context.getParams();
this.formParams = context.getFormParams();
this.session = context.getSession();
this.cors = context.getCors();
this.realm = context.getRealm();
this.client = context.getClient();
this.event = context.getEvent();
this.clientConnection = context.getClientConnection();
this.headers = context.getHeaders();
this.tokenManager = (TokenManager) context.getTokenManager();
this.clientAuthAttributes = context.getClientAuthAttributes();
this.context = context;
this.audience = context.getFormParams().getFirst("audience");
if (client.getClientId().equals(KEYCLOAK_EXCHANGE_CLIENT_ID)) {
return tokenExchange(); // Class for custom logic I'd like to implement
}
return super.exchange(context);
}
@Override
public Response tokenExchange() {
//My custom logic here }
< /code>
i enable-features = token-exchange при запуске KeyCloak, если режим V1 требуется в ACC. С помощью руководства по keycloak.
Мои вопросы: почему я не могу включить свой пользовательский поставщик и как отключить стандарт или v1?
Заранее за любую помощь.
Подробнее здесь: https://stackoverflow.com/questions/796 ... oak-26-2-x