Handle null in HttpRequestImpl

This commit is contained in:
Václav Muzikář 2022-12-02 10:46:36 +01:00 committed by Václav Muzikář
parent 3a9e051301
commit 7a0ad6ff21

View file

@ -17,42 +17,58 @@
package org.keycloak.services; package org.keycloak.services;
import java.security.cert.X509Certificate; import org.keycloak.http.HttpRequest;
import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo; import javax.ws.rs.core.UriInfo;
import org.keycloak.http.HttpRequest; import java.security.cert.X509Certificate;
public class HttpRequestImpl implements HttpRequest { public class HttpRequestImpl implements HttpRequest {
private org.jboss.resteasy.spi.HttpRequest delegate; private org.jboss.resteasy.spi.HttpRequest delegate;
public <R> HttpRequestImpl(org.jboss.resteasy.spi.HttpRequest delegate) { public HttpRequestImpl(org.jboss.resteasy.spi.HttpRequest delegate) {
this.delegate = delegate; this.delegate = delegate;
} }
@Override @Override
public String getHttpMethod() { public String getHttpMethod() {
if (delegate == null) {
return null;
}
return delegate.getHttpMethod(); return delegate.getHttpMethod();
} }
@Override @Override
public MultivaluedMap<String, String> getDecodedFormParameters() { public MultivaluedMap<String, String> getDecodedFormParameters() {
if (delegate == null) {
return null;
}
return delegate.getDecodedFormParameters(); return delegate.getDecodedFormParameters();
} }
@Override @Override
public HttpHeaders getHttpHeaders() { public HttpHeaders getHttpHeaders() {
if (delegate == null) {
return null;
}
return delegate.getHttpHeaders(); return delegate.getHttpHeaders();
} }
@Override @Override
public X509Certificate[] getClientCertificateChain() { public X509Certificate[] getClientCertificateChain() {
if (delegate == null) {
return null;
}
return (X509Certificate[]) delegate.getAttribute("javax.servlet.request.X509Certificate"); return (X509Certificate[]) delegate.getAttribute("javax.servlet.request.X509Certificate");
} }
@Override @Override
public UriInfo getUri() { public UriInfo getUri() {
if (delegate == null) {
return null;
}
return delegate.getUri(); return delegate.getUri();
} }
} }