You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2022/11/18 17:43:24 UTC
[tomee] branch main updated: Cleanup CXF files to simplify further upgrade
This is an automated email from the ASF dual-hosted git repository.
jlmonteiro pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/main by this push:
new 03579e8706 Cleanup CXF files to simplify further upgrade
03579e8706 is described below
commit 03579e87060b94624e2945cf5aa12984336d27a8
Author: Jean-Louis Monteiro <jl...@tomitribe.com>
AuthorDate: Fri Nov 18 18:43:14 2022 +0100
Cleanup CXF files to simplify further upgrade
---
.../apache/cxf/jaxb/JAXBContextInitializer.java | 10 +-
.../java/org/apache/cxf/jaxrs/JAXRSInvoker.java | 460 --------------------
.../apache/cxf/jaxrs/JAXRSServerFactoryBean.java | 467 ---------------------
.../cxf/jaxrs/provider/AbstractJAXBProvider.java | 11 +-
.../apache/cxf/jaxrs/provider/ProviderFactory.java | 2 +-
.../org/apache/cxf/jaxrs/utils/InjectionUtils.java | 6 +-
.../cxf/transport/http/auth/HttpAuthHeader.java | 154 -------
.../transport/https/HttpsURLConnectionInfo.java | 168 --------
.../AbstractBeanValidationInterceptor.java | 65 ---
.../apache/cxf/ws/addressing/MAPAggregator.java | 224 ----------
10 files changed, 11 insertions(+), 1556 deletions(-)
diff --git a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxb/JAXBContextInitializer.java b/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
index 1a04e67dc3..0c8a161f14 100644
--- a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
+++ b/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
@@ -316,8 +316,7 @@ class JAXBContextInitializer extends ServiceModelVisitor {
}
addClass(String.class);
} else if (claz.getName().startsWith("java.")
- || claz.getName().startsWith("javax.")
- || claz.getName().startsWith("jakarta.")) {
+ || claz.getName().startsWith("jakarta.") || claz.getName().startsWith("javax.")) {
return;
} else {
Class<?> cls = JAXBUtils.getValidClass(claz);
@@ -376,8 +375,7 @@ class JAXBContextInitializer extends ServiceModelVisitor {
return;
}
if (cls.getName().startsWith("java.")
- || cls.getName().startsWith("javax.")
- || cls.getName().startsWith("jakarta.")) {
+ || cls.getName().startsWith("jakarta.") || cls.getName().startsWith("javax.")) {
return;
}
//walk the public fields/methods to try and find all the classes. JAXB will only load the
@@ -560,7 +558,7 @@ class JAXBContextInitializer extends ServiceModelVisitor {
Class<?> factoryClass = creator.createFactory(cls);
try {
- return factoryClass.newInstance();
+ return factoryClass.getDeclaredConstructor().newInstance();
} catch (Exception e) {
//ignore
}
@@ -568,4 +566,4 @@ class JAXBContextInitializer extends ServiceModelVisitor {
}
-}
\ No newline at end of file
+}
diff --git a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/JAXRSInvoker.java b/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
deleted file mode 100644
index b4946e343b..0000000000
--- a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
+++ /dev/null
@@ -1,460 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.jaxrs;
-
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Collections;
-import java.util.List;
-import java.util.ResourceBundle;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.CompletionException;
-import java.util.concurrent.CompletionStage;
-import java.util.logging.Logger;
-
-import jakarta.ws.rs.WebApplicationException;
-import jakarta.ws.rs.container.AsyncResponse;
-import jakarta.ws.rs.container.ResourceContext;
-import jakarta.ws.rs.core.Application;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.MultivaluedMap;
-import jakarta.ws.rs.core.Response;
-
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
-import org.apache.cxf.common.i18n.BundleUtils;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.ClassHelper;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.interceptor.InterceptorChain.State;
-import org.apache.cxf.jaxrs.impl.AsyncResponseImpl;
-import org.apache.cxf.jaxrs.impl.MetadataMap;
-import org.apache.cxf.jaxrs.impl.ResourceContextImpl;
-import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.model.ProviderInfo;
-import org.apache.cxf.jaxrs.model.URITemplate;
-import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
-import org.apache.cxf.jaxrs.utils.ExceptionUtils;
-import org.apache.cxf.jaxrs.utils.InjectionUtils;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
-import org.apache.cxf.message.Exchange;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageContentsList;
-import org.apache.cxf.service.invoker.AbstractInvoker;
-
-public class JAXRSInvoker extends AbstractInvoker {
- private static final Logger LOG = LogUtils.getL7dLogger(JAXRSInvoker.class);
- private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JAXRSInvoker.class);
- private static final String SERVICE_LOADER_AS_CONTEXT = "org.apache.cxf.serviceloader-context";
- private static final String SERVICE_OBJECT_SCOPE = "org.apache.cxf.service.scope";
- private static final String REQUEST_SCOPE = "request";
- private static final String LAST_SERVICE_OBJECT = "org.apache.cxf.service.object.last";
- private static final String PROXY_INVOCATION_ERROR_FRAGMENT
- = "object is not an instance of declaring class";
-
- public JAXRSInvoker() {
- }
-
- public Object invoke(Exchange exchange, Object request) {
- MessageContentsList responseList = checkExchangeForResponse(exchange);
- if (responseList != null) {
- return responseList;
- }
- AsyncResponse asyncResp = exchange.get(AsyncResponse.class);
- if (asyncResp != null) {
- AsyncResponseImpl asyncImpl = (AsyncResponseImpl)asyncResp;
- asyncImpl.prepareContinuation();
- try {
- asyncImpl.handleTimeout();
- return handleAsyncResponse(exchange, asyncImpl);
- } catch (Throwable t) {
- return handleAsyncFault(exchange, asyncImpl, t);
- }
- }
-
- ResourceProvider provider = getResourceProvider(exchange);
- Object rootInstance = null;
- Message inMessage = exchange.getInMessage();
- try {
- rootInstance = getServiceObject(exchange);
- Object serviceObject = getActualServiceObject(exchange, rootInstance);
-
- return invoke(exchange, request, serviceObject);
- } catch (WebApplicationException ex) {
- responseList = checkExchangeForResponse(exchange);
- if (responseList != null) {
- return responseList;
- }
- return handleFault(ex, inMessage);
- } finally {
- boolean suspended = isSuspended(exchange);
- if (suspended || exchange.isOneWay() || inMessage.get(Message.THREAD_CONTEXT_SWITCHED) != null) {
- ServerProviderFactory.clearThreadLocalProxies(inMessage);
- }
- if (suspended || isServiceObjectRequestScope(inMessage)) {
- persistRoots(exchange, rootInstance, provider);
- } else {
- provider.releaseInstance(inMessage, rootInstance);
- }
- }
- }
-
- private boolean isSuspended(Exchange exchange) {
- return exchange.getInMessage().getInterceptorChain().getState() == State.SUSPENDED;
- }
-
- private Object handleAsyncResponse(Exchange exchange, AsyncResponseImpl ar) {
- Object asyncObj = ar.getResponseObject();
- if (asyncObj instanceof Throwable) {
- final Throwable throwable = (Throwable)asyncObj;
- Throwable cause = throwable;
-
- if (throwable instanceof CompletionException) {
- cause = throwable.getCause();
- }
-
- return handleAsyncFault(exchange, ar, (cause != null) ? cause : throwable);
- }
- setResponseContentTypeIfNeeded(exchange.getInMessage(), asyncObj);
- return new MessageContentsList(asyncObj);
- }
-
- private Object handleAsyncFault(Exchange exchange, AsyncResponseImpl ar, Throwable t) {
- try {
- return handleFault(new Fault(t), exchange.getInMessage(), null, null);
- } catch (Fault ex) {
- ar.setUnmappedThrowable(ex.getCause() == null ? ex : ex.getCause());
- if (isSuspended(exchange)) {
- ar.reset();
- exchange.getInMessage().getInterceptorChain().unpause();
- }
- return new MessageContentsList(Response.serverError().build());
- }
- }
-
- private void persistRoots(Exchange exchange, Object rootInstance, Object provider) {
- exchange.put(JAXRSUtils.ROOT_INSTANCE, rootInstance);
- exchange.put(JAXRSUtils.ROOT_PROVIDER, provider);
- }
-
- @SuppressWarnings("unchecked")
- public Object invoke(Exchange exchange, Object request, Object resourceObject) {
-
- final OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
- final ClassResourceInfo cri = ori.getClassResourceInfo();
- final Message inMessage = exchange.getInMessage();
- final ServerProviderFactory providerFactory = ServerProviderFactory.getInstance(inMessage);
- cri.injectContexts(resourceObject, ori, inMessage);
-
- if (cri.isRoot()) {
- ProviderInfo<Application> appProvider = providerFactory.getApplicationProvider();
- if (appProvider != null) {
- InjectionUtils.injectContexts(appProvider.getProvider(),
- appProvider,
- inMessage);
- }
- }
-
-
- Method methodToInvoke = getMethodToInvoke(cri, ori, resourceObject);
-
- List<Object> params = null;
- if (request instanceof List) {
- params = CastUtils.cast((List<?>)request);
- } else if (request != null) {
- params = new MessageContentsList(request);
- }
-
- Object result = null;
- ClassLoaderHolder contextLoader = null;
- AsyncResponseImpl asyncResponse = null;
- try {
- if (setServiceLoaderAsContextLoader(inMessage)) {
- contextLoader = ClassLoaderUtils
- .setThreadContextClassloader(resourceObject.getClass().getClassLoader());
- }
- if (!ori.isSubResourceLocator()) {
- asyncResponse = (AsyncResponseImpl)inMessage.get(AsyncResponse.class);
- }
- result = invoke(exchange, resourceObject, methodToInvoke, params);
- if (asyncResponse == null && !ori.isSubResourceLocator()) {
- asyncResponse = checkFutureResponse(inMessage, checkResultObject(result));
- }
- if (asyncResponse != null) {
- if (!asyncResponse.suspendContinuationIfNeeded()) {
- result = handleAsyncResponse(exchange, asyncResponse);
- } else {
- providerFactory.clearThreadLocalProxies();
- }
- }
- } catch (Fault ex) {
- Object faultResponse;
- if (asyncResponse != null) {
- faultResponse = handleAsyncFault(exchange, asyncResponse,
- ex.getCause() == null ? ex : ex.getCause());
- } else {
- faultResponse = handleFault(ex, inMessage, cri, methodToInvoke);
- }
- return faultResponse;
- } finally {
- exchange.put(LAST_SERVICE_OBJECT, resourceObject);
- if (contextLoader != null) {
- contextLoader.reset();
- }
- }
- ClassResourceInfo subCri = null;
- if (ori.isSubResourceLocator()) {
- try {
- MultivaluedMap<String, String> values = getTemplateValues(inMessage);
- String subResourcePath = values.getFirst(URITemplate.FINAL_MATCH_GROUP);
- String httpMethod = (String)inMessage.get(Message.HTTP_REQUEST_METHOD);
- String contentType = (String)inMessage.get(Message.CONTENT_TYPE);
- if (contentType == null) {
- contentType = "*/*";
- }
- List<MediaType> acceptContentType =
- (List<MediaType>)exchange.get(Message.ACCEPT_CONTENT_TYPE);
-
- result = checkSubResultObject(result, subResourcePath);
-
- final Class<?> subResponseType;
- if (result.getClass() == Class.class) {
- ResourceContext rc = new ResourceContextImpl(inMessage, ori);
- result = rc.getResource((Class<?>)result);
- subResponseType = InjectionUtils.getActualType(methodToInvoke.getGenericReturnType());
- } else {
- subResponseType = methodToInvoke.getReturnType();
- }
-
- subCri = cri.getSubResource(subResponseType,
- ClassHelper.getRealClass(exchange.getBus(), result), result);
- if (subCri == null) {
- org.apache.cxf.common.i18n.Message errorM =
- new org.apache.cxf.common.i18n.Message("NO_SUBRESOURCE_FOUND",
- BUNDLE,
- subResourcePath);
- LOG.severe(errorM.toString());
- throw ExceptionUtils.toNotFoundException(null, null);
- }
-
- OperationResourceInfo subOri = JAXRSUtils.findTargetMethod(
- Collections.singletonMap(subCri, values),
- inMessage,
- httpMethod,
- values,
- contentType,
- acceptContentType);
- exchange.put(OperationResourceInfo.class, subOri);
- inMessage.put(URITemplate.TEMPLATE_PARAMETERS, values);
- inMessage.put(URITemplate.URI_TEMPLATE, JAXRSUtils.getUriTemplate(inMessage, subCri, ori, subOri));
-
- if (!subOri.isSubResourceLocator()
- && JAXRSUtils.runContainerRequestFilters(providerFactory,
- inMessage,
- false,
- subOri.getNameBindings())) {
- return new MessageContentsList(exchange.get(Response.class));
- }
-
- // work out request parameters for the sub-resource class. Here we
- // presume InputStream has not been consumed yet by the root resource class.
- List<Object> newParams = JAXRSUtils.processParameters(subOri, values, inMessage);
- inMessage.setContent(List.class, newParams);
-
- return this.invoke(exchange, newParams, result);
- } catch (IOException ex) {
- Response resp = JAXRSUtils.convertFaultToResponse(ex, inMessage);
- if (resp == null) {
- resp = JAXRSUtils.convertFaultToResponse(ex, inMessage);
- }
- return new MessageContentsList(resp);
- } catch (WebApplicationException ex) {
- Response excResponse;
- if (JAXRSUtils.noResourceMethodForOptions(ex.getResponse(),
- (String)inMessage.get(Message.HTTP_REQUEST_METHOD))) {
- excResponse = JAXRSUtils.createResponse(Collections.singletonList(subCri),
- null, null, 200, true);
- } else {
- excResponse = JAXRSUtils.convertFaultToResponse(ex, inMessage);
- }
- return new MessageContentsList(excResponse);
- }
- }
- setResponseContentTypeIfNeeded(inMessage, result);
- return result;
- }
-
- protected AsyncResponseImpl checkFutureResponse(Message inMessage, Object result) {
- if (result instanceof CompletionStage) {
- final CompletionStage<?> stage = (CompletionStage<?>)result;
- final AsyncResponseImpl asyncResponse = new AsyncResponseImpl(inMessage);
- stage.whenComplete((v, t) -> {
- if (t instanceof CancellationException) {
- asyncResponse.cancel();
- } else {
- asyncResponse.resume(v != null ? v : t);
- }
- });
- return asyncResponse;
- }
- return null;
- }
-
- protected Method getMethodToInvoke(ClassResourceInfo cri, OperationResourceInfo ori, Object resourceObject) {
- Method resourceMethod = cri.getMethodDispatcher().getMethod(ori);
-
- Method methodToInvoke;
- if (Proxy.class.isInstance(resourceObject)) {
- methodToInvoke = cri.getMethodDispatcher().getProxyMethod(resourceMethod);
- if (methodToInvoke == null) {
- methodToInvoke = InjectionUtils.checkProxy(resourceMethod, resourceObject);
- cri.getMethodDispatcher().addProxyMethod(resourceMethod, methodToInvoke);
- }
- } else {
- methodToInvoke = resourceMethod;
- }
- return methodToInvoke;
- }
-
- private MessageContentsList checkExchangeForResponse(Exchange exchange) {
- Response r = exchange.get(Response.class);
- if (r != null) {
- JAXRSUtils.setMessageContentType(exchange.getInMessage(), r);
- return new MessageContentsList(r);
- }
- return null;
- }
-
- private void setResponseContentTypeIfNeeded(Message inMessage, Object response) {
- if (response instanceof Response) {
- JAXRSUtils.setMessageContentType(inMessage, (Response)response);
- }
- }
- private Object handleFault(Throwable ex, Message inMessage) {
- return handleFault(new Fault(ex), inMessage, null, null);
- }
- private Object handleFault(Fault ex, Message inMessage,
- ClassResourceInfo cri, Method methodToInvoke) {
- String errorMessage = ex.getMessage();
- if (errorMessage != null && cri != null
- && errorMessage.contains(PROXY_INVOCATION_ERROR_FRAGMENT)) {
- org.apache.cxf.common.i18n.Message errorM =
- new org.apache.cxf.common.i18n.Message("PROXY_INVOCATION_FAILURE",
- BUNDLE,
- methodToInvoke,
- cri.getServiceClass().getName());
- LOG.severe(errorM.toString());
- }
- Response excResponse =
- JAXRSUtils.convertFaultToResponse(ex.getCause() == null ? ex : ex.getCause(), inMessage);
- if (excResponse == null) {
- inMessage.getExchange().put(Message.PROPOGATE_EXCEPTION,
- ExceptionUtils.propogateException(inMessage));
- throw ex;
- }
- return new MessageContentsList(excResponse);
- }
-
- @SuppressWarnings("unchecked")
- protected MultivaluedMap<String, String> getTemplateValues(Message msg) {
- MultivaluedMap<String, String> values = new MetadataMap<>();
- MultivaluedMap<String, String> oldValues =
- (MultivaluedMap<String, String>)msg.get(URITemplate.TEMPLATE_PARAMETERS);
- if (oldValues != null) {
- values.putAll(oldValues);
- }
- return values;
- }
-
- private boolean setServiceLoaderAsContextLoader(Message inMessage) {
- Object en = inMessage.getContextualProperty(SERVICE_LOADER_AS_CONTEXT);
- return Boolean.TRUE.equals(en) || "true".equals(en);
- }
-
- private boolean isServiceObjectRequestScope(Message inMessage) {
- Object scope = inMessage.getContextualProperty(SERVICE_OBJECT_SCOPE);
- return REQUEST_SCOPE.equals(scope);
- }
-
- private ResourceProvider getResourceProvider(Exchange exchange) {
- Object provider = exchange.remove(JAXRSUtils.ROOT_PROVIDER);
- if (provider == null) {
- OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
- ClassResourceInfo cri = ori.getClassResourceInfo();
- return cri.getResourceProvider();
- }
- return (ResourceProvider)provider;
- }
-
- public Object getServiceObject(Exchange exchange) {
-
- Object root = exchange.remove(JAXRSUtils.ROOT_INSTANCE);
- if (root != null) {
- return root;
- }
-
- OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
- ClassResourceInfo cri = ori.getClassResourceInfo();
-
- return cri.getResourceProvider().getInstance(exchange.getInMessage());
- }
-
- protected Object getActualServiceObject(Exchange exchange, Object rootInstance) {
-
- Object last = exchange.get(LAST_SERVICE_OBJECT);
- return last != null ? last : rootInstance;
- }
-
-
-
- private static Object checkResultObject(Object result) {
-
- if (result != null) {
- if (result instanceof MessageContentsList) {
- result = ((MessageContentsList)result).get(0);
- } else if (result instanceof List) {
- result = ((List<?>)result).get(0);
- } else if (result.getClass().isArray()) {
- result = ((Object[])result)[0];
- }
- }
- return result;
- }
- private static Object checkSubResultObject(Object result, String subResourcePath) {
- result = checkResultObject(result);
- if (result == null) {
- org.apache.cxf.common.i18n.Message errorM =
- new org.apache.cxf.common.i18n.Message("NULL_SUBRESOURCE",
- BUNDLE,
- subResourcePath);
- LOG.info(errorM.toString());
- throw ExceptionUtils.toNotFoundException(null, null);
- }
-
- return result;
- }
-
-
-}
diff --git a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java b/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
deleted file mode 100644
index 6ea2ea1c60..0000000000
--- a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
+++ /dev/null
@@ -1,467 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.jaxrs;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import jakarta.ws.rs.core.Application;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
-import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.endpoint.ServerImpl;
-import org.apache.cxf.feature.Feature;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.jaxrs.ext.ResourceComparator;
-import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
-import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
-import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
-import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
-import org.apache.cxf.jaxrs.model.ApplicationInfo;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
-import org.apache.cxf.jaxrs.utils.AnnotationUtils;
-import org.apache.cxf.jaxrs.utils.InjectionUtils;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
-import org.apache.cxf.service.factory.FactoryBeanListener;
-import org.apache.cxf.service.factory.ServiceConstructionException;
-import org.apache.cxf.service.invoker.Invoker;
-
-
-/**
- * Bean to help easily create Server endpoints for JAX-RS. Example:
- * <pre>
- * JAXRSServerFactoryBean sf = JAXRSServerFactoryBean();
- * sf.setResourceClasses(Book.class);
- * sf.setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID);
- * sf.setAddress("http://localhost:9080/");
- * Server myServer = sf.create();
- * </pre>
- * This will start a server for you and register it with the ServerManager. Note
- * you should explicitly close the {@link org.apache.cxf.endpoint.Server} created
- * when finished with it:
- * <pre>
- * myServer.close();
- * myServer.destroy(); // closes first if close() not previously called
- * </pre>
- */
-public class JAXRSServerFactoryBean extends AbstractJAXRSFactoryBean {
-
- protected Map<Class<?>, ResourceProvider> resourceProviders = new HashMap<>();
-
- private Server server;
- private boolean start = true;
- private Map<Object, Object> languageMappings;
- private Map<Object, Object> extensionMappings;
- private ResourceComparator rc;
- private ApplicationInfo appProvider;
- private String documentLocation;
-
- public JAXRSServerFactoryBean() {
- this(new JAXRSServiceFactoryBean());
- }
-
- public JAXRSServerFactoryBean(JAXRSServiceFactoryBean sf) {
- super(sf);
- }
-
- /**
- * Saves the reference to the JAX-RS {@link Application}
- * @param app
- */
- public void setApplication(Application app) {
- setApplicationInfo(new ApplicationInfo(app, getBus()));
- }
-
- public void setApplicationInfo(ApplicationInfo provider) {
- appProvider = provider;
- Set<String> appNameBindings = AnnotationUtils.getNameBindings(bus, provider.getProvider().getClass());
- for (ClassResourceInfo cri : getServiceFactory().getClassResourceInfo()) {
- Set<String> clsNameBindings = new LinkedHashSet<>(appNameBindings);
- clsNameBindings.addAll(AnnotationUtils.getNameBindings(bus, cri.getServiceClass()));
- cri.setNameBindings(clsNameBindings);
- }
- }
-
- /**
- * Resource comparator which may be used to customize the way
- * a root resource or resource method is selected
- * @param rcomp comparator
- */
- public void setResourceComparator(ResourceComparator rcomp) {
- rc = rcomp;
- }
-
- /**
- * By default the subresources are resolved dynamically, mainly due to
- * the JAX-RS specification allowing Objects being returned from the subresource
- * locators. Setting this property to true enables the runtime to do the
- * early resolution.
- *
- * @param enableStatic enabling the static resolution if set to true
- */
- public void setStaticSubresourceResolution(boolean enableStatic) {
- serviceFactory.setEnableStaticResolution(enableStatic);
- }
-
-
- /**
- * Creates the JAX-RS Server instance
- * @return the server
- */
- public void init() {
- if (server == null) {
- create();
- }
- }
-
- /**
- * Creates the JAX-RS Server instance
- * @return the server
- */
- public Server create() {
- ClassLoaderHolder origLoader = null;
- try {
- Bus bus = getBus();
- ClassLoader loader = bus.getExtension(ClassLoader.class);
- if (loader != null) {
- origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
- }
- serviceFactory.setBus(bus);
- checkResources(true);
- if (serviceFactory.getService() == null) {
- serviceFactory.create();
- }
-
- Endpoint ep = createEndpoint();
-
- getServiceFactory().sendEvent(FactoryBeanListener.Event.PRE_SERVER_CREATE,
- server);
-
- server = new ServerImpl(getBus(),
- ep,
- getDestinationFactory(),
- getBindingFactory());
-
- Invoker invoker = serviceFactory.getInvoker();
- if (invoker == null) {
- ep.getService().setInvoker(createInvoker());
- } else {
- ep.getService().setInvoker(invoker);
- }
-
- ServerProviderFactory factory = setupFactory(ep);
-
- ep.put(Application.class.getName(), appProvider);
- factory.setRequestPreprocessor(
- new RequestPreprocessor(languageMappings, extensionMappings));
- ep.put(Bus.class.getName(), getBus());
- if (documentLocation != null) {
- ep.put(JAXRSUtils.DOC_LOCATION, documentLocation);
- }
- if (rc != null) {
- ep.put("org.apache.cxf.jaxrs.comparator", rc);
- }
- checkPrivateEndpoint(ep);
-
- applyBusFeatures(getBus());
- applyFeatures();
-
- updateClassResourceProviders(ep);
- injectContexts(factory, (ApplicationInfo)ep.get(Application.class.getName()));
- factory.applyDynamicFeatures(getServiceFactory().getClassResourceInfo());
-
-
- getServiceFactory().sendEvent(FactoryBeanListener.Event.SERVER_CREATED,
- server,
- null,
- null);
-
-
- if (start) {
- try {
- server.start();
- } catch (RuntimeException re) {
- if (!(re instanceof ServiceConstructionException
- && re.getMessage().startsWith("There is an endpoint already running on"))) {
- //avoid destroying another server on the same endpoint url
- server.destroy(); // prevent resource leak if server really started by itself
-
- }
- throw re;
- }
- }
- } catch (Exception e) {
- throw new ServiceConstructionException(e);
- } finally {
- if (origLoader != null) {
- origLoader.reset();
- }
- }
-
- return server;
- }
-
- public Server getServer() {
- return server;
- }
-
- protected ServerProviderFactory setupFactory(Endpoint ep) {
- ServerProviderFactory factory = ServerProviderFactory.createInstance(getBus());
- setBeanInfo(factory);
- factory.setApplicationProvider(appProvider);
- super.setupFactory(factory, ep);
- return factory;
- }
-
- protected void setBeanInfo(ServerProviderFactory factory) {
- List<ClassResourceInfo> cris = serviceFactory.getClassResourceInfo();
- for (ClassResourceInfo cri : cris) {
- cri.initBeanParamInfo(factory);
- }
-
- }
-
- protected void applyBusFeatures(final Bus bus) {
- if (bus.getFeatures() != null) {
- for (Feature feature : bus.getFeatures()) {
- feature.initialize(server, bus);
- }
- }
- }
-
- protected void applyFeatures() {
- if (getFeatures() != null) {
- for (Feature feature : getFeatures()) {
- feature.initialize(server, getBus());
- }
- }
- }
-
- protected Invoker createInvoker() {
- return serviceFactory.createInvoker();
- }
-
- /**
- * Sets the language mappings,
- * example, 'en' is the key and 'en-gb' is the value.
- *
- * @param lMaps the language mappings
- */
- public void setLanguageMappings(Map<Object, Object> lMaps) {
- languageMappings = lMaps;
- }
-
- /**
- * Sets the extension mappings,
- * example, 'xml' is the key and 'text/xml' is the value.
- *
- * @param extMaps the extension mappings
- */
- public void setExtensionMappings(Map<Object, Object> extMaps) {
- extensionMappings = extMaps;
- }
-
- public List<Class<?>> getResourceClasses() {
- return serviceFactory.getResourceClasses();
- }
-
- /**
- * This method is used primarily by Spring handler processing
- * the jaxrs:server/@serviceClass attribute. It delegates to
- * setResourceClasses method accepting the array of Class parameters.
- * @param clazz the service/resource class
- */
- public void setServiceClass(Class<?> clazz) {
- serviceFactory.setResourceClasses(clazz);
- }
-
- /**
- * Sets one or more root resource classes
- * @param classes the list of resource classes
- */
- public void setResourceClasses(List<Class<?>> classes) {
- serviceFactory.setResourceClasses(classes);
- }
-
- /**
- * Sets one or more root resource classes
- * @param classes the array of resource classes
- */
- public void setResourceClasses(Class<?>... classes) {
- serviceFactory.setResourceClasses(classes);
- }
-
- /**
- * Sets the resource beans. If this is set then the JAX-RS runtime
- * will not be responsible for the life-cycle of resource classes.
- *
- * @param beans the array of resource instances
- */
- public void setServiceBeanObjects(Object... beans) {
- setServiceBeans(Arrays.asList(beans));
- }
-
- /**
- * Sets the single resource bean. If this is set then the JAX-RS runtime
- * will not be responsible for the life-cycle of resource classes.
- * Please avoid setting the resource class of this bean explicitly,
- * the runtime will determine it itself.
- *
- * @param bean resource instance
- */
- public void setServiceBean(Object bean) {
- setServiceBeans(Arrays.asList(bean));
- }
-
- /**
- * Sets the resource beans. If this is set then the JAX-RS runtime
- * will not be responsible for the life-cycle of resource classes.
- *
- * @param beans the list of resource instances
- */
- public void setServiceBeans(List<Object> beans) {
- List<Object> newBeans = new ArrayList<>();
- addToBeans(newBeans, beans);
- serviceFactory.setResourceClassesFromBeans(newBeans);
- }
-
- /**
- * Sets the provider managing the life-cycle of the given resource class
- * <pre>
- * Example:
- * setResourceProvider(BookStoreInterface.class, new SingletonResourceProvider(new BookStore()));
- * </pre>
- * @param c resource class
- * @param rp resource provider
- */
- public void setResourceProvider(Class<?> c, ResourceProvider rp) {
- resourceProviders.put(c, rp);
- }
-
- /**
- * Sets the provider managing the life-cycle of the resource class
- * <pre>
- * Example:
- * setResourceProvider(new SingletonResourceProvider(new BookStore()));
- * </pre>
- * @param rp resource provider
- */
- public void setResourceProvider(ResourceProvider rp) {
- setResourceProviders(CastUtils.cast(Collections.singletonList(rp), ResourceProvider.class));
- }
-
- /**
- * Sets the list of providers managing the life-cycle of the resource classes
- *
- * @param rps resource providers
- */
- public void setResourceProviders(List<ResourceProvider> rps) {
- for (ResourceProvider rp : rps) {
- Class<?> c = rp.getResourceClass();
- setServiceClass(c);
- resourceProviders.put(c, rp);
- }
- }
-
- /**
- * Sets the custom Invoker which can be used to customize the way
- * the default JAX-RS invoker calls on the service bean
- * @param invoker
- */
- public void setInvoker(Invoker invoker) {
- serviceFactory.setInvoker(invoker);
- }
-
- /**
- * Determines whether Services are automatically started during the create() call. Default is true.
- * If false will need to call start() method on Server to activate it.
- * @param start Whether (true) or not (false) to start the Server during Server creation.
- */
- public void setStart(boolean start) {
- this.start = start;
- }
-
- protected void injectContexts(ServerProviderFactory factory, ApplicationInfo fallback) {
- // Sometimes the application provider (ApplicationInfo) is injected through
- // the endpoint, not JAXRSServerFactoryBean (like for example OpenApiFeature
- // or Swagger2Feature do). As such, without consulting the endpoint, the injection
- // may not work properly.
- final ApplicationInfo appInfoProvider = (appProvider == null) ? fallback : appProvider;
- final Application application = appInfoProvider == null ? null : appInfoProvider.getProvider();
-
- for (ClassResourceInfo cri : serviceFactory.getClassResourceInfo()) {
- if (cri.isSingleton()) {
- InjectionUtils.injectContextProxiesAndApplication(cri,
- cri.getResourceProvider().getInstance(null),
- application,
- factory);
- }
- }
- if (application != null) {
- InjectionUtils.injectContextProxiesAndApplication(appInfoProvider,
- application, null, null);
- }
- }
-
- protected void updateClassResourceProviders(Endpoint ep) {
- for (ClassResourceInfo cri : serviceFactory.getClassResourceInfo()) {
- if (cri.getResourceProvider() == null) {
- ResourceProvider rp = resourceProviders.get(cri.getResourceClass());
- if (rp != null) {
- cri.setResourceProvider(rp);
- } else {
- setDefaultResourceProvider(cri);
- }
- }
- if (cri.getResourceProvider() instanceof SingletonResourceProvider) {
- ((SingletonResourceProvider)cri.getResourceProvider()).init(ep);
- }
- }
- }
-
- protected void setDefaultResourceProvider(ClassResourceInfo cri) {
- cri.setResourceProvider(new PerRequestResourceProvider(cri.getResourceClass()));
- }
-
- /**
- * Set the reference to the document (WADL, etc) describing the endpoint
- * @param docLocation document location
- */
- public void setDocLocation(String docLocation) {
- this.documentLocation = docLocation;
- }
-
- /**
- * Get the reference to the document (WADL, etc) describing the endpoint
- * @return document location
- */
- public String getDocLocation() {
- return documentLocation;
- }
-}
diff --git a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java b/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
index 06be8a0737..5b203a6d95 100644
--- a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
+++ b/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
@@ -722,12 +722,7 @@ public abstract class AbstractJAXBProvider<T> extends AbstractConfigurableProvid
return sb;
}
- protected static void handleExceptionEnd(Throwable t, String message, boolean read) throws NoContentException {
- if (t instanceof WstxEOFException && t.getMessage().startsWith("Unexpected EOF in prolog")){
- String noContent = new org.apache.cxf.common.i18n.Message("EMPTY_BODY", BUNDLE).toString();
- LOG.warning(noContent);
- throw new NoContentException(noContent);
- }
+ protected static void handleExceptionEnd(Throwable t, String message, boolean read) {
Response.Status status = read
? Response.Status.BAD_REQUEST : Response.Status.INTERNAL_SERVER_ERROR;
Response r = JAXRSUtils.toResponseBuilder(status)
@@ -736,7 +731,7 @@ public abstract class AbstractJAXBProvider<T> extends AbstractConfigurableProvid
: ExceptionUtils.toInternalServerErrorException(t, r);
}
- protected void handleJAXBException(JAXBException e, boolean read) throws NoContentException {
+ protected void handleJAXBException(JAXBException e, boolean read) {
StringBuilder sb = handleExceptionStart(e);
Throwable linked = e.getLinkedException();
if (linked != null && linked.getMessage() != null) {
@@ -761,7 +756,7 @@ public abstract class AbstractJAXBProvider<T> extends AbstractConfigurableProvid
handleExceptionEnd(t, message, read);
}
- protected void handleXMLStreamException(XMLStreamException e, boolean read) throws NoContentException {
+ protected void handleXMLStreamException(XMLStreamException e, boolean read) {
StringBuilder sb = handleExceptionStart(e);
handleExceptionEnd(e, sb.toString(), read);
}
diff --git a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java b/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
index 787dc6a712..3327d9c6b3 100644
--- a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
+++ b/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
@@ -250,7 +250,7 @@ public abstract class ProviderFactory {
return c.newInstance(bus);
}
}
- return cls.newInstance();
+ return cls.getDeclaredConstructor().newInstance();
} catch (Throwable ex) {
String message = "Problem with creating the default provider " + className;
if (ex.getMessage() != null) {
diff --git a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java b/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
index 2c8175790b..1e41abe2da 100644
--- a/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
+++ b/deps/cxf-shade/src/patch/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
@@ -659,7 +659,7 @@ public final class InjectionUtils {
paramType,
paramAnns);
}
- bean = paramType.newInstance();
+ bean = paramType.getDeclaredConstructor().newInstance();
} catch (IllegalAccessException ex) {
reportServerError("CLASS_ACCESS_FAILURE", paramType.getName());
} catch (Exception ex) {
@@ -982,7 +982,7 @@ public final class InjectionUtils {
Object theValues = null;
if (type != null) {
try {
- theValues = type.newInstance();
+ theValues = type.getDeclaredConstructor().newInstance();
} catch (IllegalAccessException ex) {
reportServerError("CLASS_ACCESS_FAILURE", type.getName());
} catch (Exception ex) {
@@ -1169,7 +1169,7 @@ public final class InjectionUtils {
if (proxyClassName != null) {
try {
return (ThreadLocalProxy<?>)ClassLoaderUtils.loadClass(proxyClassName, InjectionUtils.class)
- .newInstance();
+ .getDeclaredConstructor().newInstance();
} catch (Throwable t) {
throw new RuntimeException(t);
}
diff --git a/deps/cxf-shade/src/patch/java/org/apache/cxf/transport/http/auth/HttpAuthHeader.java b/deps/cxf-shade/src/patch/java/org/apache/cxf/transport/http/auth/HttpAuthHeader.java
deleted file mode 100644
index ee7251899e..0000000000
--- a/deps/cxf-shade/src/patch/java/org/apache/cxf/transport/http/auth/HttpAuthHeader.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.transport.http.auth;
-
-import java.io.IOException;
-import java.io.StreamTokenizer;
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public final class HttpAuthHeader {
- public static final String AUTH_TYPE_BASIC = "Basic";
- public static final String AUTH_TYPE_DIGEST = "Digest";
- public static final String AUTH_TYPE_NEGOTIATE = "Negotiate";
-
- private final String fullHeader;
- private final String authType;
- private final String fullContent;
- private final Map<String, String> params;
-
- public HttpAuthHeader(String fullHeader) {
- this.fullHeader = (fullHeader == null) ? "" : fullHeader;
- int spacePos = this.fullHeader.indexOf(' ');
- if (spacePos == -1) {
- this.authType = this.fullHeader;
- this.fullContent = "";
- } else {
- this.authType = this.fullHeader.substring(0, spacePos);
- this.fullContent = this.fullHeader.substring(spacePos + 1);
- }
- this.params = parseHeader();
- }
- public HttpAuthHeader(List<String> params) {
- fullHeader = String.join(", ", params);
- int spacePos = this.fullHeader.indexOf(' ');
- if (spacePos == -1) {
- this.authType = this.fullHeader;
- this.fullContent = "";
- } else {
- this.authType = this.fullHeader.substring(0, spacePos);
- this.fullContent = this.fullHeader.substring(spacePos + 1);
- }
- this.params = parseHeader();
- }
-
- public HttpAuthHeader(String authType, Map<String, String> params) {
- this.authType = authType;
- this.params = params;
- this.fullContent = paramsToString();
- this.fullHeader = authType + " " + fullContent;
- }
-
- private String paramsToString() {
- StringBuilder builder = new StringBuilder();
- boolean first = true;
- for (Map.Entry<String, String> entry : params.entrySet()) {
- String param = entry.getValue();
- if (param != null) {
- if (!first) {
- builder.append(", ");
- }
- if ("nc".equals(entry.getKey())
- || "qop".equals(entry.getKey())
- || "algorithm".equals(entry.getKey())) {
- builder.append(entry.getKey()).append('=').append(param);
- } else {
- builder.append(entry.getKey()).append("=\"").append(param).append('"');
- }
- first = false;
- }
- }
- return builder.toString();
- }
-
- private Map<String, String> parseHeader() {
- Map<String, String> map = new HashMap<>();
- try {
- StreamTokenizer tok = new StreamTokenizer(new StringReader(this.fullContent)) {
- @Override
- public void parseNumbers() {
- // skip parse numbers
- wordChars('0', '9');
- wordChars('.', '.');
- wordChars('-', '-');
- }
- };
- tok.whitespaceChars('=', '=');
- tok.whitespaceChars(',', ',');
-
- while (tok.nextToken() != StreamTokenizer.TT_EOF) {
- map.put(tok.sval, tok.nextToken() != StreamTokenizer.TT_EOF ? tok.sval : null);
- }
- } catch (IOException ex) {
- //ignore can't happen for StringReader
- }
- return map;
- }
-
- /**
- * Extracts the authorization realm from the
- * "WWW-Authenticate" Http response header.
- *
- * @return The realm, or null if it is non-existent.
- */
- public String getRealm() {
- return params.get("realm");
- }
-
- public boolean authTypeIsDigest() {
- return AUTH_TYPE_DIGEST.equals(this.authType);
- }
-
- public boolean authTypeIsBasic() {
- return AUTH_TYPE_BASIC.equals(this.authType);
- }
-
- public boolean authTypeIsNegotiate() {
- return AUTH_TYPE_NEGOTIATE.equals(this.authType);
- }
-
- public String getAuthType() {
- return authType;
- }
-
- public String getFullContent() {
- return fullContent;
- }
-
- public String getFullHeader() {
- return this.fullHeader;
- }
-
- public Map<String, String> getParams() {
- return params;
- }
-
-}
diff --git a/deps/cxf-shade/src/patch/java/org/apache/cxf/transport/https/HttpsURLConnectionInfo.java b/deps/cxf-shade/src/patch/java/org/apache/cxf/transport/https/HttpsURLConnectionInfo.java
deleted file mode 100644
index 31bff301a4..0000000000
--- a/deps/cxf-shade/src/patch/java/org/apache/cxf/transport/https/HttpsURLConnectionInfo.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.transport.https;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.HttpURLConnection;
-import java.net.URI;
-import java.security.Principal;
-import java.security.cert.Certificate;
-
-import javax.net.ssl.HttpsURLConnection;
-
-import org.apache.cxf.transport.http.HttpURLConnectionInfo;
-
-/**
- * This class holds information about the HttpsURLConnection. This
- * class should be used when the getURL().getProtocol() is "https".
- */
-public class HttpsURLConnectionInfo extends HttpURLConnectionInfo {
-
- /**
- * This field contains the cipherSuite enabled in the
- * HTTPS URLconnection.
- */
- protected String enabledCipherSuite;
-
- /**
- * This field contains the certificates that were used to
- * authenticate the connection to the peer.
- */
- protected Certificate[] localCertificates;
-
- /**
- * This field contains the Principal that authenticated to the
- * peer.
- */
- protected Principal localPrincipal;
-
- /**
- * This field contains the certificates the server presented
- * to authenticate.
- */
- protected Certificate[] serverCertificates;
-
- /**
- * This field contains the Principal that represents the
- * authenticated peer.
- */
- protected Principal peerPrincipal;
-
-
- public HttpsURLConnectionInfo(URI uri,
- String method,
- String cipherSuite,
- Certificate[] localCerts,
- Principal principal,
- Certificate[] serverCerts,
- Principal peer) {
- super(uri, method);
- enabledCipherSuite = cipherSuite;
- localCertificates = localCerts;
- localPrincipal = principal;
- serverCertificates = serverCerts;
- peerPrincipal = peer;
- }
-
-
-
- /**
- * This constructor is used to create the info object
- * representing the this HttpsURLConnection. Connection parameter is
- * of supertype HttpURLConnection, which allows internal cast to
- * potentially divergent subtype (Https) implementations.
- */
- public HttpsURLConnectionInfo(HttpURLConnection connection)
- throws IOException {
- super(connection.getURL(), connection.getRequestMethod());
- if (connection instanceof HttpsURLConnection) {
- HttpsURLConnection conn = (HttpsURLConnection) connection;
- enabledCipherSuite = conn.getCipherSuite();
- localCertificates = conn.getLocalCertificates();
- localPrincipal = conn.getLocalPrincipal();
- serverCertificates = conn.getServerCertificates();
- peerPrincipal = conn.getPeerPrincipal();
- } else {
- try {
- Method method = connection.getClass().getMethod("getCipherSuite", (Class[]) null);
- enabledCipherSuite = (String) method.invoke(connection, (Object[]) null);
- method = connection.getClass().getMethod("getLocalCertificates", (Class[]) null);
- localCertificates = (Certificate[]) method.invoke(connection, (Object[]) null);
- method = connection.getClass().getMethod("getServerCertificates", (Class[]) null);
- serverCertificates = (Certificate[]) method.invoke(connection, (Object[]) null);
-
- //TODO Obtain localPrincipal and peerPrincipal using the com.sun.net.ssl api
- } catch (Exception e) {
- Throwable ex = e;
- if (e instanceof InvocationTargetException) {
- ex = ((InvocationTargetException) e).getTargetException();
- }
- if (ex instanceof IOException) {
- throw (IOException) ex;
- }
- throw new IOException("Error constructing HttpsURLConnectionInfo "
- + "for connection class "
- + connection.getClass().getName(), ex);
- }
- }
- }
-
- /**
- * This method returns the cipher suite employed in this
- * HttpsURLConnection.
- */
- public String getEnabledCipherSuite() {
- return enabledCipherSuite;
- }
-
- /**
- * This method returns the certificates that were used to
- * authenticate to the peer.
- */
- public Certificate[] getLocalCertificates() {
- return localCertificates;
- }
-
- /**
- * This method returns the Princpal that authenticated to
- * the peer.
- */
- public Principal getLocalPrincipal() {
- return localPrincipal;
- }
-
- /**
- * This method returns the certificates presented by the
- * peer for authentication.
- */
- public Certificate[] getServerCertificates() {
- return serverCertificates;
- }
-
- /**
- * This method returns the Principal that represents the
- * authenticated peer.
- */
- public Principal getPeerPrincipal() {
- return peerPrincipal;
- }
-}
diff --git a/deps/cxf-shade/src/patch/java/org/apache/cxf/validation/AbstractBeanValidationInterceptor.java b/deps/cxf-shade/src/patch/java/org/apache/cxf/validation/AbstractBeanValidationInterceptor.java
deleted file mode 100644
index 91211835d6..0000000000
--- a/deps/cxf-shade/src/patch/java/org/apache/cxf/validation/AbstractBeanValidationInterceptor.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.validation;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-import jakarta.validation.ValidationException;
-
-import org.apache.cxf.message.Message;
-
-public abstract class AbstractBeanValidationInterceptor extends AbstractValidationInterceptor {
- protected AbstractBeanValidationInterceptor(String phase) {
- super(phase);
- }
-
- @Override
- protected Object getServiceObject(Message message) {
- return checkNotNull(super.getServiceObject(message), "SERVICE_OBJECT_NULL");
- }
-
- @Override
- protected Method getServiceMethod(Message message) {
- return (Method)checkNotNull(super.getServiceMethod(message), "SERVICE_METHOD_NULL");
- }
-
- private Object checkNotNull(Object object, String name) {
- if (object == null) {
- String message = new org.apache.cxf.common.i18n.Message(name, BUNDLE).toString();
- LOG.severe(message);
- throw new ValidationException(message);
- }
- return object;
- }
-
- @Override
- protected void handleValidation(final Message message, final Object resourceInstance,
- final Method method, final List<Object> arguments) {
- if (!arguments.isEmpty()) {
- BeanValidationProvider provider = getProvider(message);
- provider.validateParameters(resourceInstance, method, unwrapArgs(arguments).toArray());
- message.getExchange().put(BeanValidationProvider.class, provider);
- }
- }
-
- protected List<Object> unwrapArgs(List<Object> arguments) {
- return arguments;
- }
-}
diff --git a/deps/cxf-shade/src/patch/java/org/apache/cxf/ws/addressing/MAPAggregator.java b/deps/cxf-shade/src/patch/java/org/apache/cxf/ws/addressing/MAPAggregator.java
deleted file mode 100644
index 206494d4bd..0000000000
--- a/deps/cxf-shade/src/patch/java/org/apache/cxf/ws/addressing/MAPAggregator.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.ws.addressing;
-
-import java.util.Collection;
-
-import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.AbstractPhaseInterceptor;
-import org.apache.cxf.phase.Phase;
-import org.apache.cxf.phase.PhaseInterceptor;
-
-/**
- * Logical Handler responsible for aggregating the Message Addressing
- * Properties for outgoing messages.
- */
-public class MAPAggregator extends AbstractPhaseInterceptor<Message> {
- public static final String USING_ADDRESSING = MAPAggregator.class.getName() + ".usingAddressing";
- public static final String ADDRESSING_DISABLED = MAPAggregator.class.getName() + ".addressingDisabled";
- public static final String DECOUPLED_DESTINATION = MAPAggregator.class.getName()
- + ".decoupledDestination";
- public static final String ACTION_VERIFIED = MAPAggregator.class.getName() + ".actionVerified";
- public static final String ADDRESSING_NAMESPACE = MAPAggregator.class.getName() + ".addressingNamespace";
-
- public interface MAPAggregatorLoader {
- MAPAggregator createImplementation(MAPAggregator mag);
- }
-
- protected MessageIdCache messageIdCache;
- protected boolean usingAddressingAdvisory = true;
- protected boolean addressingRequired;
- protected boolean allowDuplicates = true;
- protected WSAddressingFeature.AddressingResponses addressingResponses
- = WSAddressingFeature.AddressingResponses.ALL;
-
- /**
- * The real implementation of the MAPAggregator interceptor
- */
- private MAPAggregator impl;
-
- /**
- * Constructor.
- */
- public MAPAggregator() {
- super(MAPAggregator.class.getName(), Phase.PRE_LOGICAL);
- addBefore("org.apache.cxf.interceptor.OneWayProcessorInterceptor");
- }
-
- /**
- * Indicates if duplicate messageIDs are allowed.
- * @return true if duplicate messageIDs are allowed
- */
- public boolean allowDuplicates() {
- if (impl != null) {
- return impl.allowDuplicates();
- }
- return allowDuplicates;
- }
-
- /**
- * Allows/disallows duplicate messageIdDs.
- * @param ad whether duplicate messageIDs are allowed
- */
- public void setAllowDuplicates(boolean ad) {
- if (impl != null) {
- impl.setAllowDuplicates(ad);
- }
- allowDuplicates = ad;
- }
-
- /**
- * Whether the presence of the <wsaw:UsingAddressing> element
- * in the WSDL is purely advisory, i.e. its absence doesn't prevent
- * the encoding of WS-A headers.
- *
- * @return true if the presence of the <wsaw:UsingAddressing> element is
- * advisory
- */
- public boolean isUsingAddressingAdvisory() {
- if (impl != null) {
- return impl.isUsingAddressingAdvisory();
- }
- return usingAddressingAdvisory;
- }
-
- /**
- * Controls whether the presence of the <wsaw:UsingAddressing> element
- * in the WSDL is purely advisory, i.e. its absence doesn't prevent
- * the encoding of WS-A headers.
- *
- * @param advisory true if the presence of the <wsaw:UsingAddressing>
- * element is to be advisory
- */
- public void setUsingAddressingAdvisory(boolean advisory) {
- if (impl != null) {
- impl.setUsingAddressingAdvisory(advisory);
- }
- usingAddressingAdvisory = advisory;
- }
-
- /**
- * Whether the use of addressing is completely required for this endpoint
- *
- * @return true if addressing is required
- */
- public boolean isAddressingRequired() {
- if (impl != null) {
- return impl.addressingRequired;
- }
- return addressingRequired;
- }
- /**
- * Sets whether the use of addressing is completely required for this endpoint
- *
- */
- public void setAddressingRequired(boolean required) {
- if (impl != null) {
- impl.setAddressingRequired(required);
- }
- addressingRequired = required;
- }
-
- /**
- * Sets Addresing Response
- *
- */
- public void setAddressingResponses(WSAddressingFeature.AddressingResponses responses) {
- if (impl != null) {
- impl.setAddressingResponses(responses);
- }
- addressingResponses = responses;
- }
-
- /**
- * Returns the cache used to enforce duplicate message IDs when
- * {@link #allowDuplicates()} returns {@code false}.
- *
- * @return the cache used to enforce duplicate message IDs
- */
- public MessageIdCache getMessageIdCache() {
- if (impl != null) {
- return impl.getMessageIdCache();
- }
- return messageIdCache;
- }
-
- /**
- * Sets the cache used to enforce duplicate message IDs when
- * {@link #allowDuplicates()} returns {@code false}.
- *
- * @param messageIdCache the cache to use
- *
- * @throws NullPointerException if {@code messageIdCache} is {@code null}
- */
- public void setMessageIdCache(MessageIdCache messageIdCache) {
- if (messageIdCache == null) {
- throw new NullPointerException("messageIdCache cannot be null.");
- }
- if (impl != null) {
- impl.setMessageIdCache(messageIdCache);
- }
- this.messageIdCache = messageIdCache;
- }
-
- /**
- * Sets Addressing Response
- *
- */
- public WSAddressingFeature.AddressingResponses getAddressingResponses() {
- if (impl != null) {
- return impl.getAddressingResponses();
- }
- return addressingResponses;
- }
-
- /**
- * Invoked for normal processing of inbound and outbound messages.
- *
- * @param message the current message
- */
- public void handleMessage(Message message) {
- if (impl == null) {
- //load impl
- MAPAggregatorLoader loader = message.getExchange().getBus()
- .getExtension(MAPAggregatorLoader.class);
- impl = loader.createImplementation(this);
- }
- impl.handleMessage(message);
- }
-
- @Override
- public void handleFault(Message message) {
- if (impl != null) {
- impl.handleFault(message);
- }
- }
-
-
- @Override
- public Collection<PhaseInterceptor<? extends Message>> getAdditionalInterceptors() {
- if (impl != null) {
- return impl.getAdditionalInterceptors();
- }
- return super.getAdditionalInterceptors();
- }
-
-
-}