io.phasetwo.keycloak.themes.resource.BaseRealmResourceProvider Maven / Gradle / Ivy
The newest version!
package io.phasetwo.keycloak.themes.resource;
import lombok.extern.jbosslog.JBossLog;
import org.keycloak.http.HttpRequest;
import org.keycloak.models.KeycloakSession;
import org.keycloak.services.resource.RealmResourceProvider;
/** */
@JBossLog
public abstract class BaseRealmResourceProvider implements RealmResourceProvider {
protected final KeycloakSession session;
public BaseRealmResourceProvider(KeycloakSession session) {
this.session = session;
}
@Override
public void close() {}
protected abstract Object getRealmResource();
@Override
public Object getResource() {
HttpRequest request = session.getContext().getHttpRequest();
log.debugf("request method %s", request.getHttpMethod());
if (request != null && "OPTIONS".equals(request.getHttpMethod())) {
return new CorsResource(session, request);
} else {
return getRealmResource();
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy