JBossWS SVN: r19569 - in stack/cxf/branches/management/modules: server/src/main/java/org/jboss/wsf/stack/cxf/configuration and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2015-03-16 05:53:57 -0400 (Mon, 16 Mar 2015)
New Revision: 19569
Added:
stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/AbstractEndpintManagementInterceptor.java
stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsPutInterceptor.java
stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsPutOutIntercetpor.java
Modified:
stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetInterceptor.java
stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetOutIntercetpor.java
stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextJSETestCase.java
Log:
[JBWS-3881]:Add interceptor to allow configure runtime configurations on Endpoint
Modified: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
===================================================================
--- stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2015-03-16 09:28:45 UTC (rev 19568)
+++ stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2015-03-16 09:53:57 UTC (rev 19569)
@@ -22,8 +22,6 @@
package org.jboss.wsf.stack.cxf;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
@@ -50,7 +48,7 @@
import org.jboss.ws.common.management.AbstractServerConfig;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.invocation.InvocationContext;
+import org.jboss.wsf.spi.deployment.RuntimeConfig;
import org.jboss.wsf.spi.invocation.RequestHandler;
import org.jboss.wsf.spi.management.EndpointMetrics;
import org.jboss.wsf.spi.management.ServerConfig;
@@ -94,7 +92,7 @@
out.close();
return;
}
- final boolean statisticsEnabled = getServerConfig().isStatisticsEnabled();
+ final boolean statisticsEnabled = getServerConfig().isStatisticsEnabled() || "true".equals(ep.getRuntimeProperty(RuntimeConfig.STATISTICS_ENABLED));
final Long beginTime = statisticsEnabled == true ? initRequestMetrics(ep) : 0;
final Deployment dep = ep.getService().getDeployment();
final AbstractHTTPDestination dest = findDestination(req, dep.getAttachment(BusHolder.class).getBus());
Modified: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
--- stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2015-03-16 09:28:45 UTC (rev 19568)
+++ stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2015-03-16 09:53:57 UTC (rev 19569)
@@ -72,6 +72,7 @@
import org.jboss.wsf.stack.cxf.interceptor.EnableDecoupledFaultInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.EndpointAssociationInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.EndpointConfigsGetInterceptor;
+import org.jboss.wsf.stack.cxf.interceptor.EndpointConfigsPutInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.HandlerAuthInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.NsCtxSelectorStoreInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.WSDLSoapAddressRewriteInterceptor;
@@ -206,6 +207,7 @@
bus.getInInterceptors().add(new EndpointAssociationInterceptor());
bus.getInInterceptors().add(new EnableDecoupledFaultInterceptor());
bus.getInInterceptors().add(new EndpointConfigsGetInterceptor());
+ bus.getInInterceptors().add(new EndpointConfigsPutInterceptor());
bus.getInInterceptors().add(new NsCtxSelectorStoreInterceptor());
final String p = (props != null) ? props.get(Constants.JBWS_CXF_DISABLE_HANDLER_AUTH_CHECKS) : null;
Added: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/AbstractEndpintManagementInterceptor.java
===================================================================
--- stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/AbstractEndpintManagementInterceptor.java (rev 0)
+++ stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/AbstractEndpintManagementInterceptor.java 2015-03-16 09:53:57 UTC (rev 19569)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2015, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.interceptor;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cxf.common.util.UrlUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.MessageSenderInterceptor;
+import org.apache.cxf.interceptor.OutgoingChainInterceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor;
+
+/**
+ * All endpoint management interceptor should extend this class to get allowed http methods etc.
+ * @author <a href="mailto:ema@redhat.com/>Jim Ma</a>
+ *
+ */
+public abstract class AbstractEndpintManagementInterceptor extends AbstractPhaseInterceptor<Message>
+{
+ private static final String TRANSFORM_SKIP = "transform.skip";
+
+ public AbstractEndpintManagementInterceptor(String phase)
+ {
+ super(phase);
+ }
+
+ abstract Set<String> getAllowedMethod();
+
+ protected boolean isAllowed(final Message message) throws Fault
+ {
+ String method = (String)message.get(Message.HTTP_REQUEST_METHOD);
+ if (getAllowedMethod().contains(method) && isValidUser(getHttpRequest(message)))
+ {
+ return true;
+ }
+ return false;
+
+ }
+
+ private boolean isValidUser(final HttpServletRequest req)
+ {
+ if (req.getUserPrincipal() != null && req.isUserInRole("admin"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ protected HttpServletRequest getHttpRequest(Message message)
+ {
+ return (HttpServletRequest)message.get("HTTP.REQUEST");
+ }
+
+ protected Map<String, String> getQueryMap(Message message)
+ {
+ String query = (String)message.get(Message.QUERY_STRING);
+ Map<String, String> map = UrlUtils.parseQueryString(query);
+ return map;
+ }
+
+ protected void cleanUpOutInterceptors(Message outMessage)
+ {
+ // TODO - how can I improve this to provide a specific interceptor chain that just has the
+ // stax, gzip and message sender components, while also ensuring that GZIP is only provided
+ // if its already configured for the endpoint.
+ Iterator<Interceptor<? extends Message>> iterator = outMessage.getInterceptorChain().iterator();
+ while (iterator.hasNext())
+ {
+ Interceptor<? extends Message> inInterceptor = iterator.next();
+ if (!inInterceptor.getClass().equals(GZIPOutInterceptor.class) && !inInterceptor.getClass().equals(MessageSenderInterceptor.class))
+ {
+ outMessage.getInterceptorChain().remove(inInterceptor);
+ }
+ }
+ outMessage.getExchange().put(TRANSFORM_SKIP, Boolean.TRUE);
+
+ }
+
+ protected Message createOutMessage(Message message)
+ {
+ Message mout = new MessageImpl();
+ mout.setExchange(message.getExchange());
+ mout = message.getExchange().get(org.apache.cxf.endpoint.Endpoint.class).getBinding().createMessage(mout);
+ mout.setInterceptorChain(OutgoingChainInterceptor.getOutInterceptorChain(message.getExchange()));
+ message.getExchange().setOutMessage(mout);
+ return mout;
+ }
+}
Property changes on: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/AbstractEndpintManagementInterceptor.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetInterceptor.java
===================================================================
--- stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetInterceptor.java 2015-03-16 09:28:45 UTC (rev 19568)
+++ stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetInterceptor.java 2015-03-16 09:53:57 UTC (rev 19569)
@@ -21,23 +21,16 @@
*/
package org.jboss.wsf.stack.cxf.interceptor;
-import java.util.Iterator;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
-import javax.servlet.http.HttpServletRequest;
-
import org.apache.cxf.binding.soap.interceptor.EndpointSelectionInterceptor;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.common.util.UrlUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.interceptor.Interceptor;
-import org.apache.cxf.interceptor.MessageSenderInterceptor;
import org.apache.cxf.interceptor.OutgoingChainInterceptor;
import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageImpl;
-import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
-import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor;
import org.jboss.wsf.spi.deployment.Endpoint;
/**
* Interceptor to get json format endpoint config info. This interceptor is only
@@ -46,11 +39,16 @@
*
*/
-public class EndpointConfigsGetInterceptor extends AbstractPhaseInterceptor<Message> {
+public class EndpointConfigsGetInterceptor extends AbstractEndpintManagementInterceptor {
public static final EndpointConfigsGetInterceptor INSTANCE = new EndpointConfigsGetInterceptor();
public static final String ENDPOINT_CONFIGS = EndpointConfigsGetInterceptor.class.getName() + ".EndpointConfigs";
+ public static final Set<String> httpMethods = new HashSet<String>(4);
private Interceptor<Message> configsOutInteceptor = EndpointConfigsGetOutIntercetpor.INSTANCE;
private static final String TRANSFORM_SKIP = "transform.skip";
+ static {
+ httpMethods.add("GET");
+ httpMethods.add("POST");
+ }
public EndpointConfigsGetInterceptor() {
super(Phase.READ);
getAfter().add(EndpointSelectionInterceptor.class.getName());
@@ -63,34 +61,19 @@
}
public void handleMessage(Message message) throws Fault {
- String method = (String)message.get(Message.HTTP_REQUEST_METHOD);
- String query = (String)message.get(Message.QUERY_STRING);
- HttpServletRequest request = (HttpServletRequest)message.get("HTTP.REQUEST");
- if (!"GET".equals(method) || StringUtils.isEmpty(query) || !isValidUser(request)) {
- return;
+ if (!isAllowed(message)) {
+ return;
}
-
- /*String baseUri = (String)message.get(Message.REQUEST_URL);
- String ctx = (String)message.get(Message.PATH_INFO);*/
-
- Map<String, String> map = UrlUtils.parseQueryString(query);
- if (isRecognizedQuery(map)) {
-
+ if (isRecognizedQuery(getQueryMap(message))) {
+ Message mout = this.createOutMessage(message);
Endpoint endpoint = message.getExchange().get(Endpoint.class);
-
- Message mout = new MessageImpl();
- mout.setExchange(message.getExchange());
- mout = message.getExchange().get(org.apache.cxf.endpoint.Endpoint.class).getBinding().createMessage(mout);
- mout.setInterceptorChain(OutgoingChainInterceptor.getOutInterceptorChain(message.getExchange()));
- message.getExchange().setOutMessage(mout);
-
mout.put(ENDPOINT_CONFIGS, endpoint.getAllConfigsMap());
mout.put(Message.CONTENT_TYPE, "text/xml");
// just remove the interceptor which should not be used
cleanUpOutInterceptors(mout);
// notice this is being added after the purge above, don't swap the order!
+
mout.getInterceptorChain().add(configsOutInteceptor);
-
message.getExchange().put(TRANSFORM_SKIP, Boolean.TRUE);
// skip the service executor and goto the end of the chain.
message.getInterceptorChain().doInterceptStartingAt(
@@ -99,32 +82,19 @@
}
}
- protected void cleanUpOutInterceptors(Message outMessage) {
- // TODO - how can I improve this to provide a specific interceptor chain that just has the
- // stax, gzip and message sender components, while also ensuring that GZIP is only provided
- // if its already configured for the endpoint.
- Iterator<Interceptor<? extends Message>> iterator = outMessage.getInterceptorChain().iterator();
- while (iterator.hasNext()) {
- Interceptor<? extends Message> inInterceptor = iterator.next();
- if (!inInterceptor.getClass().equals(GZIPOutInterceptor.class)
- && !inInterceptor.getClass().equals(MessageSenderInterceptor.class)) {
- outMessage.getInterceptorChain().remove(inInterceptor);
- }
- }
-
- }
- private boolean isRecognizedQuery(Map<String, String> map) {
- if (map.containsKey("config")) {
+ private boolean isRecognizedQuery(Map<String, String> map) {
+ if (map.containsKey("config") && map.size() == 1) {
return true;
}
return false;
}
+
+ @Override
+ Set<String> getAllowedMethod()
+ {
+ return httpMethods;
+ }
- private boolean isValidUser(HttpServletRequest req) {
- if (req.getUserPrincipal() != null && req.isUserInRole("admin")) {
- return true;
- }
- return false;
- }
+
}
\ No newline at end of file
Modified: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetOutIntercetpor.java
===================================================================
--- stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetOutIntercetpor.java 2015-03-16 09:28:45 UTC (rev 19568)
+++ stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetOutIntercetpor.java 2015-03-16 09:53:57 UTC (rev 19569)
@@ -36,70 +36,88 @@
import org.codehaus.jettison.AbstractXMLStreamWriter;
import org.codehaus.jettison.mapped.MappedNamespaceConvention;
import org.codehaus.jettison.mapped.MappedXMLStreamWriter;
+
/**
* Out Interceptor to get json format endpoint config info. This interceptor is only
* responds to get url like http://localhost:8080/context/wsendpoint/management?config
*@author <a href="mailto:ema@redhat.com>Jim Ma</a>
*
*/
-public class EndpointConfigsGetOutIntercetpor extends AbstractPhaseInterceptor<Message> {
- public static final EndpointConfigsGetOutIntercetpor INSTANCE = new EndpointConfigsGetOutIntercetpor();
+public class EndpointConfigsGetOutIntercetpor extends AbstractPhaseInterceptor<Message>
+{
+ public static final EndpointConfigsGetOutIntercetpor INSTANCE = new EndpointConfigsGetOutIntercetpor();
- public EndpointConfigsGetOutIntercetpor() {
- super(Phase.PRE_STREAM);
- getAfter().add(StaxOutInterceptor.class.getName());
- }
+ public EndpointConfigsGetOutIntercetpor()
+ {
+ super(Phase.PRE_STREAM);
+ getAfter().add(StaxOutInterceptor.class.getName());
+ }
- public void handleMessage(Message message) throws Fault {
- @SuppressWarnings("unchecked")
- Map<String, String> configMaps = (Map<String, String>)message.get(EndpointConfigsGetInterceptor.ENDPOINT_CONFIGS);
- if (configMaps == null) {
- return;
- }
- message.remove(EndpointConfigsGetInterceptor.ENDPOINT_CONFIGS);
- OutputStream out = message.getContent(OutputStream.class);
- if (out == null) {
- return;
- }
- message.put(Message.CONTENT_TYPE, "text/xml");
- OutputStreamWriter writer = null;
- AbstractXMLStreamWriter mappedWriter = null;
- try {
- writer= new OutputStreamWriter(out, getEncoding(message));
- mappedWriter = new MappedXMLStreamWriter(new MappedNamespaceConvention(), writer);
- mappedWriter.writeStartDocument();
- for (String key : configMaps.keySet()) {
- String value = configMaps.get(key);
- if (StringUtils.isEmpty(value)) {
- mappedWriter.writeEmptyElement(key);
- } else {
- mappedWriter.writeStartElement(key);
- mappedWriter.writeCharacters(configMaps.get(key));
- mappedWriter.writeEndElement();
- }
+ public void handleMessage(Message message) throws Fault
+ {
+ @SuppressWarnings("unchecked")
+ Map<String, String> configMaps = (Map<String, String>)message.get(EndpointConfigsGetInterceptor.ENDPOINT_CONFIGS);
+ if (configMaps == null)
+ {
+ return;
+ }
+ message.remove(EndpointConfigsGetInterceptor.ENDPOINT_CONFIGS);
+ OutputStream out = message.getContent(OutputStream.class);
+ if (out == null)
+ {
+ return;
+ }
+ message.put(Message.CONTENT_TYPE, "text/xml");
+ OutputStreamWriter writer = null;
+ AbstractXMLStreamWriter mappedWriter = null;
+ try
+ {
+ writer = new OutputStreamWriter(out, getEncoding(message));
+ mappedWriter = new MappedXMLStreamWriter(new MappedNamespaceConvention(), writer);
+ mappedWriter.writeStartDocument();
+ for (String key : configMaps.keySet())
+ {
+ String value = configMaps.get(key);
+ if (StringUtils.isEmpty(value))
+ {
+ mappedWriter.writeEmptyElement(key);
}
- mappedWriter.writeEndDocument();
- out.flush();
- } catch (Exception e) {
- throw new Fault(e);
- } finally {
- StaxUtils.close(mappedWriter);
- }
-
- }
- private String getEncoding(Message message) {
- Exchange ex = message.getExchange();
- String encoding = (String)message.get(Message.ENCODING);
- if (encoding == null && ex.getInMessage() != null) {
- encoding = (String) ex.getInMessage().get(Message.ENCODING);
- message.put(Message.ENCODING, encoding);
- }
-
- if (encoding == null) {
- encoding = "UTF-8";
- message.put(Message.ENCODING, encoding);
- }
- return encoding;
- }
+ else
+ {
+ mappedWriter.writeStartElement(key);
+ mappedWriter.writeCharacters(configMaps.get(key));
+ mappedWriter.writeEndElement();
+ }
+ }
+ mappedWriter.writeEndDocument();
+ out.flush();
+ }
+ catch (Exception e)
+ {
+ throw new Fault(e);
+ }
+ finally
+ {
+ StaxUtils.close(mappedWriter);
+ }
+
+ }
+
+ private String getEncoding(Message message)
+ {
+ Exchange ex = message.getExchange();
+ String encoding = (String)message.get(Message.ENCODING);
+ if (encoding == null && ex.getInMessage() != null)
+ {
+ encoding = (String)ex.getInMessage().get(Message.ENCODING);
+ message.put(Message.ENCODING, encoding);
+ }
+
+ if (encoding == null)
+ {
+ encoding = "UTF-8";
+ message.put(Message.ENCODING, encoding);
+ }
+ return encoding;
+ }
}
-
Added: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsPutInterceptor.java
===================================================================
--- stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsPutInterceptor.java (rev 0)
+++ stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsPutInterceptor.java 2015-03-16 09:53:57 UTC (rev 19569)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2015, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.interceptor;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.cxf.binding.soap.interceptor.EndpointSelectionInterceptor;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.OutgoingChainInterceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * Interceptor to set runtime configuration with http put url like: http://localhost:8080/context/endpoint?statistics-enabled=true
+ *@author <a href="mailto:ema@redhat.com>Jim Ma</a>
+ *
+ */
+public class EndpointConfigsPutInterceptor extends AbstractEndpintManagementInterceptor
+{
+ public static final EndpointConfigsPutInterceptor INSTANCE = new EndpointConfigsPutInterceptor();
+ public static final String CONFIG_RESULT = EndpointConfigsPutInterceptor.class.getName() + ".EndpointConfigPutResult";
+ public static final Set<String> httpMethods;
+ private Interceptor<Message> configPutOutInteceptor = EndpointConfigsPutOutIntercetpor.INSTANCE;
+
+ static
+ {
+ httpMethods = new HashSet<String>(4);
+ httpMethods.add("PUT");
+ httpMethods.add("GET");
+ }
+
+ public EndpointConfigsPutInterceptor()
+ {
+ super(Phase.READ);
+ getAfter().add(EndpointSelectionInterceptor.class.getName());
+ }
+
+ public EndpointConfigsPutInterceptor(Interceptor<Message> outInterceptor)
+ {
+ this();
+ configPutOutInteceptor = outInterceptor;
+ }
+
+ @Override
+ public void handleMessage(Message message) throws Fault
+ {
+ if (!isAllowed(message))
+ {
+ return;
+ }
+ Map<String, String> queryMaps = getQueryMap(message);
+ Endpoint endpoint = message.getExchange().get(Endpoint.class);
+ for (String key : queryMaps.keySet())
+ {
+ if (!endpoint.getRuntimeConfigFlags().contains(key))
+ {
+ return;
+ }
+ }
+ Message mout = this.createOutMessage(message);
+ for (String key : queryMaps.keySet())
+ {
+ endpoint.setRuntimeProperty(key, queryMaps.get(key));
+ }
+ mout.put(CONFIG_RESULT, "Successfully set endpoint runtime configurations.");
+ cleanUpOutInterceptors(mout);
+ mout.getInterceptorChain().add(configPutOutInteceptor);
+ message.getInterceptorChain().doInterceptStartingAt(message, OutgoingChainInterceptor.class.getName());
+ }
+
+ @Override
+ Set<String> getAllowedMethod()
+ {
+ return httpMethods;
+ }
+}
Property changes on: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsPutInterceptor.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsPutOutIntercetpor.java
===================================================================
--- stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsPutOutIntercetpor.java (rev 0)
+++ stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsPutOutIntercetpor.java 2015-03-16 09:53:57 UTC (rev 19569)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2015, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.interceptor;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.StaxOutInterceptor;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.codehaus.jettison.AbstractXMLStreamWriter;
+import org.codehaus.jettison.mapped.MappedNamespaceConvention;
+import org.codehaus.jettison.mapped.MappedXMLStreamWriter;
+
+/**
+ * Out Interceptor to write json format endpoint config set result. This interceptor is added to interceptorchain by
+ * @see org.jboss.wsf.stack.cxf.interceptor.EndpointsConfigsPutInterceptor
+ * @author <a href="mailto:ema@redhat.com">Jim Ma</a>
+ *
+ */
+public class EndpointConfigsPutOutIntercetpor extends AbstractPhaseInterceptor<Message>
+{
+ public static final EndpointConfigsPutOutIntercetpor INSTANCE = new EndpointConfigsPutOutIntercetpor();
+
+ public EndpointConfigsPutOutIntercetpor()
+ {
+ super(Phase.PRE_STREAM);
+ getAfter().add(StaxOutInterceptor.class.getName());
+ }
+
+ public void handleMessage(Message message) throws Fault
+ {
+ String configResult = (String)message.get(EndpointConfigsPutInterceptor.CONFIG_RESULT);
+ if (configResult == null)
+ {
+ return;
+ }
+ message.remove(EndpointConfigsPutInterceptor.CONFIG_RESULT);
+ OutputStream out = message.getContent(OutputStream.class);
+ if (out == null)
+ {
+ return;
+ }
+ message.put(Message.CONTENT_TYPE, "text/xml");
+ OutputStreamWriter writer = null;
+ AbstractXMLStreamWriter mappedWriter = null;
+ try
+ {
+ writer = new OutputStreamWriter(out, getEncoding(message));
+ mappedWriter = new MappedXMLStreamWriter(new MappedNamespaceConvention(), writer);
+ mappedWriter.writeStartDocument();
+
+ mappedWriter.writeStartElement("result");
+ mappedWriter.writeCharacters(configResult);
+ mappedWriter.writeEndElement();
+
+ mappedWriter.writeEndDocument();
+ out.flush();
+ }
+ catch (Exception e)
+ {
+ throw new Fault(e);
+ }
+ finally
+ {
+ StaxUtils.close(mappedWriter);
+ }
+
+ }
+
+ private String getEncoding(Message message)
+ {
+ Exchange ex = message.getExchange();
+ String encoding = (String)message.get(Message.ENCODING);
+ if (encoding == null && ex.getInMessage() != null)
+ {
+ encoding = (String)ex.getInMessage().get(Message.ENCODING);
+ message.put(Message.ENCODING, encoding);
+ }
+
+ if (encoding == null)
+ {
+ encoding = "UTF-8";
+ message.put(Message.ENCODING, encoding);
+ }
+ return encoding;
+ }
+}
Property changes on: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsPutOutIntercetpor.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified: stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextJSETestCase.java
===================================================================
--- stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextJSETestCase.java 2015-03-16 09:28:45 UTC (rev 19568)
+++ stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextJSETestCase.java 2015-03-16 09:53:57 UTC (rev 19569)
@@ -70,6 +70,7 @@
.addAsManifestResource(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/samples/context/META-INF/permissions.xml"), "permissions.xml")
.addAsWebInfResource(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/samples/context/WEB-INF/jboss-web.xml"), "jboss-web.xml")
.setWebXML(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/samples/context/WEB-INF/web.xml"));
+ JBossWSTestHelper.writeToFile(archive);
return archive;
}
@@ -125,16 +126,26 @@
@Test
@RunAsClient
- public void testManagementURL() throws Exception {
- URL url = new URL(baseURL + "/jaxws-samples-context-jse/management?config");
- String encoding = Base64.encodeBytes("jbossws:jbossws".getBytes());
- HttpURLConnection connenction = (HttpURLConnection)url.openConnection();
- connenction.setRequestProperty("Authorization", "Basic " + encoding);
- connenction.connect();
- assertEquals(200, connenction.getResponseCode());
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- IOUtils.copy(connenction.getInputStream(), bout);
- assertTrue("Unexpected response", bout.toString().contains("\"type\":\"JAXWS_JSE\",\"securityDomain\":\"JBossWS\""));
-
+ public void testManagementURL() throws Exception
+ {
+ URL url = new URL(baseURL + "/jaxws-samples-context-jse/management?config");
+ String encoding = Base64.encodeBytes("jbossws:jbossws".getBytes());
+ HttpURLConnection connenction = (HttpURLConnection)url.openConnection();
+ connenction.setRequestProperty("Authorization", "Basic " + encoding);
+ connenction.connect();
+ assertEquals(200, connenction.getResponseCode());
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ IOUtils.copy(connenction.getInputStream(), bout);
+ assertTrue("Unexpected response", bout.toString().contains("\"type\":\"JAXWS_JSE\",\"securityDomain\":\"JBossWS\""));
+
+ url = new URL(baseURL + "/jaxws-samples-context-jse/management?statistics-enabled=true");
+ connenction = (HttpURLConnection)url.openConnection();
+ connenction.setRequestProperty("Authorization", "Basic " + encoding);
+ connenction.connect();
+ assertEquals(200, connenction.getResponseCode());
+ bout = new ByteArrayOutputStream();
+ IOUtils.copy(connenction.getInputStream(), bout);
+ assertTrue("Unexpected response", bout.toString().contains("Successfully set endpoint runtime configurations"));
+
}
}
9 years, 9 months
JBossWS SVN: r19568 - in hudson/trunk/hudson-home: jobs and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: asoldano
Date: 2015-03-16 05:28:45 -0400 (Mon, 16 Mar 2015)
New Revision: 19568
Added:
hudson/trunk/hudson-home/jobs/CXF-CORE-AS-8.0.0-IPV6/
hudson/trunk/hudson-home/jobs/CXF-CORE-AS-8.0.0-IPV6/config.xml
Modified:
hudson/trunk/hudson-home/config.xml
Log:
Try adding a job using IPv6
Modified: hudson/trunk/hudson-home/config.xml
===================================================================
--- hudson/trunk/hudson-home/config.xml 2015-03-16 03:37:27 UTC (rev 19567)
+++ hudson/trunk/hudson-home/config.xml 2015-03-16 09:28:45 UTC (rev 19568)
@@ -77,6 +77,7 @@
<string>CXF-ALL</string>
<string>CXF-CORE-AS-8.0.0</string>
<string>CXF-CORE-AS-8.0.0-SECMGR</string>
+ <string>CXF-CORE-AS-8.0.0-IPV6</string>
<string>CXF-CORE-AS-8.1.0</string>
<string>CXF-CORE-AS-8.2.0</string>
<string>CXF-CORE-AS-8.1.0-SECMGR</string>
Added: hudson/trunk/hudson-home/jobs/CXF-CORE-AS-8.0.0-IPV6/config.xml
===================================================================
--- hudson/trunk/hudson-home/jobs/CXF-CORE-AS-8.0.0-IPV6/config.xml (rev 0)
+++ hudson/trunk/hudson-home/jobs/CXF-CORE-AS-8.0.0-IPV6/config.xml 2015-03-16 09:28:45 UTC (rev 19568)
@@ -0,0 +1,73 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<project>
+ <builders class="vector">
+ <hudson.tasks.Shell>
+ <command>
+#
+# Module settings
+#
+MODULE=CXF-CORE-AS-8.0.0-IPV6
+
+WORKSPACE=`pwd`
+STACK_ID=cxf
+JAVA_HOME=(a)java.home.sun.jdk6@
+SCRIPTS_DIR=$WORKSPACE/hudson-scripts
+STACK_DIR=$WORKSPACE/stack-cxf
+TEST_OPTS=-Djboss.bind.address=[::1] -DadditionalJvmArgs="-Djava.net.preferIPv4Stack=false -Djava.net.preferIPv6Addresses=true" -Djava.net.preferIPv4Stack=false -Djava.net.preferIPv6Addresses=true
+JBOSS_TARGET=wildfly800
+JBOSS_INSTANCE=@hudson.home@/jobs/AS-8.0.0-SECMGR/workspace/build/target/(a)hudson.jboss800.build@
+
+#
+# load test functions
+#
+. $SCRIPTS_DIR/jbossws-qa.sh
+
+#
+# execute core tests
+#
+coreTest
+
+</command>
+ </hudson.tasks.Shell>
+ </builders>
+ <publishers class="vector">
+ <hudson.tasks.junit.JUnitResultArchiver>
+ <testResults>stack-cxf/**/target/surefire-reports/*.xml</testResults>
+ </hudson.tasks.junit.JUnitResultArchiver>
+ <hudson.tasks.Mailer>
+ <recipients>@hudson.mail.recipients@</recipients>
+ <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
+ <sendToIndividuals>true</sendToIndividuals>
+ </hudson.tasks.Mailer>
+ </publishers>
+ <buildWrappers class="vector"/>
+ <scm class="hudson.scm.SubversionSCM">
+ <locations>
+ <hudson.scm.SubversionSCM-ModuleLocation>
+ <remote>@jbossws.hudson.url@/scripts</remote>
+ <local>hudson-scripts</local>
+ </hudson.scm.SubversionSCM-ModuleLocation>
+ <hudson.scm.SubversionSCM-ModuleLocation>
+ <remote>@hudson.cxf.url@</remote>
+ <local>stack-cxf</local>
+ </hudson.scm.SubversionSCM-ModuleLocation>
+ </locations>
+ <useUpdate>true</useUpdate>
+ <browser class="hudson.scm.browsers.FishEyeSVN">
+ <url>http://fisheye.jboss.com/browse/JBossWS/</url>
+ <rootModule></rootModule>
+ </browser>
+ </scm>
+ <canRoam>true</canRoam>
+ <disabled>false</disabled>
+ <enableRemoteTrigger>false</enableRemoteTrigger>
+ <triggers class="vector"/>
+ <logRotator>
+ <daysToKeep>14</daysToKeep>
+ <numToKeep>-1</numToKeep>
+ </logRotator>
+ <keepDependencies>false</keepDependencies>
+ <properties/>
+ <description>Build and test jbossws-cxf-(a)version.id@ against @hudson.jboss800.build@ using IPv6</description>
+ <actions class="vector"/>
+</project>
Property changes on: hudson/trunk/hudson-home/jobs/CXF-CORE-AS-8.0.0-IPV6/config.xml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
9 years, 9 months
JBossWS SVN: r19567 - stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2015-03-15 23:37:27 -0400 (Sun, 15 Mar 2015)
New Revision: 19567
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java
Log:
Fix wrong change in the previous commit
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2015-03-16 03:28:34 UTC (rev 19566)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2015-03-16 03:37:27 UTC (rev 19567)
@@ -224,6 +224,7 @@
String epurl = SoapAddressRewriteHelper.getRewrittenPublishedEndpointUrl(ei.getAddress(), metadata);
ei.setAddress(epurl);
}
+ }
}
}
}
9 years, 9 months
JBossWS SVN: r19566 - in stack/cxf/trunk/modules: testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2015-03-15 23:28:34 -0400 (Sun, 15 Mar 2015)
New Revision: 19566
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java
Log:
Enable test
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2015-03-16 03:27:45 UTC (rev 19565)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2015-03-16 03:28:34 UTC (rev 19566)
@@ -224,7 +224,6 @@
String epurl = SoapAddressRewriteHelper.getRewrittenPublishedEndpointUrl(ei.getAddress(), metadata);
ei.setAddress(epurl);
}
- }
}
}
}
Modified: stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java 2015-03-16 03:27:45 UTC (rev 19565)
+++ stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java 2015-03-16 03:28:34 UTC (rev 19566)
@@ -38,7 +38,6 @@
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestHelper;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -210,7 +209,6 @@
@Test
@RunAsClient
@OperateOnDeployment(DEPLOYMENT1)
- @Ignore(value="Wait for [WFLY-2129][WFLY-3988] merge")
public void testOneWay() throws Exception
{
//test unthenticated
@@ -245,7 +243,6 @@
@Test
@RunAsClient
@OperateOnDeployment(DEPLOYMENT2)
- @Ignore(value="Wait for [WFLY-2129][WFLY-3988] merge")
public void testEjbSecurityAuth() throws Exception
{
URL wsdlURL = new URL(baseURL + "/jaxws-securityDomain2/authz?wsdl");
9 years, 9 months
JBossWS SVN: r19565 - container/wildfly82/branches/jbossws-wildfly820/server-integration/src/main/java/org/jboss/as/webservices/deployers.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2015-03-15 23:27:45 -0400 (Sun, 15 Mar 2015)
New Revision: 19565
Modified:
container/wildfly82/branches/jbossws-wildfly820/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_EJB.java
Log:
Backport fix [WFLY-2129][WFLY-3988]:Fix ejb method level annotation @PermitAll;Honors the ejb method level security permission if there is no class level security permission
Modified: container/wildfly82/branches/jbossws-wildfly820/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_EJB.java
===================================================================
--- container/wildfly82/branches/jbossws-wildfly820/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_EJB.java 2015-03-16 03:27:42 UTC (rev 19564)
+++ container/wildfly82/branches/jbossws-wildfly820/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_EJB.java 2015-03-16 03:27:45 UTC (rev 19565)
@@ -179,15 +179,21 @@
// process @PermitAll annotation
if (webServiceClassInfo.annotations().containsKey(PERMIT_ALL_ANNOTATION)) {
- final AnnotationInstance permitAll = webServiceClassInfo.annotations().get(PERMIT_ALL_ANNOTATION).iterator().next();
- if (permitAll.target().equals(webServiceClassInfo)) {
- securityRoles.add("*");
+ for (AnnotationInstance permitAll : webServiceClassInfo.annotations().get(PERMIT_ALL_ANNOTATION)) {
+ if (permitAll.target().equals(webServiceClassInfo)) {
+ securityRoles.add("*");
+ break;
+ }
}
}
-
- return (securityRoles.size() > 0) ? Collections.unmodifiableSet(securityRoles) : Collections.<String>emptySet();
+ //if there is no class level security annotation, it will delegate to ejb's security check
+ if (securityRoles.isEmpty()) {
+ securityRoles.add("*");
+ }
+ return Collections.unmodifiableSet(securityRoles);
}
+
private static final class WebContextAnnotationWrapper {
private final String authMethod;
private final String transportGuarantee;
9 years, 9 months
JBossWS SVN: r19564 - container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2015-03-15 23:27:42 -0400 (Sun, 15 Mar 2015)
New Revision: 19564
Modified:
container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_EJB.java
Log:
Backport fix [WFLY-2129][WFLY-3988]:Fix ejb method level annotation @PermitAll;Honors the ejb method level security permission if there is no class level security permission
Modified: container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_EJB.java
===================================================================
--- container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_EJB.java 2015-03-16 03:27:21 UTC (rev 19563)
+++ container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_EJB.java 2015-03-16 03:27:42 UTC (rev 19564)
@@ -179,15 +179,21 @@
// process @PermitAll annotation
if (webServiceClassInfo.annotations().containsKey(PERMIT_ALL_ANNOTATION)) {
- final AnnotationInstance permitAll = webServiceClassInfo.annotations().get(PERMIT_ALL_ANNOTATION).iterator().next();
- if (permitAll.target().equals(webServiceClassInfo)) {
- securityRoles.add("*");
+ for (AnnotationInstance permitAll : webServiceClassInfo.annotations().get(PERMIT_ALL_ANNOTATION)) {
+ if (permitAll.target().equals(webServiceClassInfo)) {
+ securityRoles.add("*");
+ break;
+ }
}
}
-
- return (securityRoles.size() > 0) ? Collections.unmodifiableSet(securityRoles) : Collections.<String>emptySet();
+ //if there is no class level security annotation, it will delegate to ejb's security check
+ if (securityRoles.isEmpty()) {
+ securityRoles.add("*");
+ }
+ return Collections.unmodifiableSet(securityRoles);
}
+
private static final class WebContextAnnotationWrapper {
private final String authMethod;
private final String transportGuarantee;
9 years, 9 months
JBossWS SVN: r19563 - container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/deployers.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2015-03-15 23:27:21 -0400 (Sun, 15 Mar 2015)
New Revision: 19563
Modified:
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_EJB.java
Log:
Backport fix [WFLY-2129][WFLY-3988]:Fix ejb method level annotation @PermitAll;Honors the ejb method level security permission if there is no class level security permission
Modified: container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_EJB.java
===================================================================
--- container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_EJB.java 2015-03-13 17:14:11 UTC (rev 19562)
+++ container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_EJB.java 2015-03-16 03:27:21 UTC (rev 19563)
@@ -168,15 +168,21 @@
// process @PermitAll annotation
if (webServiceClassInfo.annotations().containsKey(PERMIT_ALL_ANNOTATION)) {
- final AnnotationInstance permitAll = webServiceClassInfo.annotations().get(PERMIT_ALL_ANNOTATION).iterator().next();
- if (permitAll.target().equals(webServiceClassInfo)) {
- securityRoles.add("*");
+ for (AnnotationInstance permitAll : webServiceClassInfo.annotations().get(PERMIT_ALL_ANNOTATION)) {
+ if (permitAll.target().equals(webServiceClassInfo)) {
+ securityRoles.add("*");
+ break;
+ }
}
}
-
- return (securityRoles.size() > 0) ? Collections.unmodifiableSet(securityRoles) : Collections.<String>emptySet();
+ //if there is no class level security annotation, it will delegate to ejb's security check
+ if (securityRoles.isEmpty()) {
+ securityRoles.add("*");
+ }
+ return Collections.unmodifiableSet(securityRoles);
}
+
private static final class WebContextAnnotationWrapper {
private final String authMethod;
private final String transportGuarantee;
9 years, 9 months
JBossWS SVN: r19562 - in stack/cxf/trunk/modules: client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: asoldano
Date: 2015-03-13 13:14:11 -0400 (Fri, 13 Mar 2015)
New Revision: 19562
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSBusFactory.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringConfigurer.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java
Log:
[JBWS-3884] Deprecating Spring facilities in jbossws-cxf-client module and adding a WARN on Spring integration being deprecated in jbossws-cxf-server module.
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java 2015-03-13 10:10:15 UTC (rev 19561)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java 2015-03-13 17:14:11 UTC (rev 19562)
@@ -240,4 +240,8 @@
@LogMessage(level = WARN)
@Message(id = 24106, value = "Could not remove previuosly set features on client: %s")
void couldNoRemoveFeaturesOnClient(String feature);
+
+ @LogMessage(level = WARN)
+ @Message(id = 24107, value = "JBossWS-CXF integration with Spring is deprecated and will be dropped in a future release. See https://issues.jboss.org/browse/JBWS-3884 for details.")
+ void deprecatedSpringIntegration();
}
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSBusFactory.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSBusFactory.java 2015-03-13 10:10:15 UTC (rev 19561)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSBusFactory.java 2015-03-13 17:14:11 UTC (rev 19562)
@@ -50,6 +50,7 @@
{
private static final Map<ClassLoader, Bus> classLoaderBusses = new WeakHashMap<ClassLoader, Bus>();
+ @SuppressWarnings("deprecation")
private JBossWSSpringBusFactory springBusFactory;
private JBossWSNonSpringBusFactory nonSpringBusFactory;
@@ -74,41 +75,49 @@
}
/** JBossWSSpringBusFactory methods **/
+ @Deprecated
public Bus createBus(String cfgFile)
{
return getSpringBusFactory().createBus(cfgFile, true);
}
+ @Deprecated
public Bus createBus(String cfgFiles[])
{
return getSpringBusFactory().createBus(cfgFiles, true);
}
+ @Deprecated
public Bus createBus(String cfgFile, boolean includeDefaults)
{
return getSpringBusFactory().createBus(cfgFile, includeDefaults);
}
+ @Deprecated
public Bus createBus(String cfgFiles[], boolean includeDefaults)
{
return getSpringBusFactory().createBus(cfgFiles, includeDefaults);
}
+ @Deprecated
public Bus createBus(URL url)
{
return getSpringBusFactory().createBus(url);
}
+ @Deprecated
public Bus createBus(URL[] urls)
{
return getSpringBusFactory().createBus(urls);
}
+ @Deprecated
public Bus createBus(URL url, boolean includeDefaults)
{
return getSpringBusFactory().createBus(url, includeDefaults);
}
+ @Deprecated
public Bus createBus(URL[] urls, boolean includeDefaults)
{
return getSpringBusFactory().createBus(urls, includeDefaults);
@@ -125,6 +134,7 @@
return getNonSpringBusFactory().createBus(extensions, properties);
}
+ @Deprecated
public synchronized JBossWSSpringBusFactory getSpringBusFactory()
{
if (springBusFactory == null)
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java 2015-03-13 10:10:15 UTC (rev 19561)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java 2015-03-13 17:14:11 UTC (rev 19562)
@@ -44,6 +44,7 @@
* @since 25-May-2010
*
*/
+@Deprecated
public class JBossWSSpringBusFactory extends SpringBusFactory
{
private boolean customContextProvided = false;
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringConfigurer.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringConfigurer.java 2015-03-13 10:10:15 UTC (rev 19561)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringConfigurer.java 2015-03-13 17:14:11 UTC (rev 19562)
@@ -36,6 +36,7 @@
* @author alessio.soldano(a)jboss.com
* @since 05-Oct-2009
*/
+@Deprecated
public class JBossWSSpringConfigurer implements JBossWSConfigurer, ApplicationContextAware, BusExtension
{
private BeanCustomizer customizer;
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java 2015-03-13 10:10:15 UTC (rev 19561)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java 2015-03-13 17:14:11 UTC (rev 19562)
@@ -46,7 +46,6 @@
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
-import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.configuration.Configurer;
import org.jboss.ws.common.Messages;
import org.jboss.wsf.spi.WSFException;
@@ -56,7 +55,7 @@
import org.jboss.wsf.stack.cxf.client.ClientBusSelector;
import org.jboss.wsf.stack.cxf.client.Constants;
import org.jboss.wsf.stack.cxf.client.UseThreadBusFeature;
-import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory;
+import org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory;
/**
* This ServiceObjectFactory reconstructs a javax.xml.ws.Service
@@ -516,13 +515,14 @@
{});
}
+ @SuppressWarnings("deprecation")
private Bus createNewBus(final UnifiedServiceRefMetaData serviceRefMD)
{
final Bus bus;
final URL cxfConfig = this.getCXFConfiguration(serviceRefMD.getVfsRoot());
if (cxfConfig != null)
{
- final SpringBusFactory busFactory = new JBossWSSpringBusFactory();
+ final JBossWSBusFactory busFactory = new JBossWSBusFactory();
bus = busFactory.createBus(cxfConfig);
BusFactory.setThreadDefaultBus(bus);
}
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java 2015-03-13 10:10:15 UTC (rev 19561)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java 2015-03-13 17:14:11 UTC (rev 19562)
@@ -66,6 +66,7 @@
//create additional DD if user provided jbossws-cxf.xml and Spring is available OR spring descriptor generation is forced
if (cxfURL != null || PREFER_SPRING_DESCRIPTOR_GENERATION)
{
+ DEPLOYMENT_LOGGER.deprecatedSpringIntegration();
URL generated = dd.createFileURL();
DEPLOYMENT_LOGGER.jbwscxfConfGenerated(generated);
putCXFConfigToDeployment(dep, BusHolder.PARAM_CXF_GEN_URL, generated);
9 years, 9 months
JBossWS SVN: r19561 - in stack/cxf/branches/management/modules/testsuite/shared-tests/src/test: java/org/jboss/test/ws/jaxws/samples/context and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2015-03-13 06:10:15 -0400 (Fri, 13 Mar 2015)
New Revision: 19561
Modified:
stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/etc/jbossws-roles.properties
stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/etc/jbossws-users.properties
stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextJSETestCase.java
Log:
[JBWS-3881]:Add test to get endpoint config info from management url
Modified: stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/etc/jbossws-roles.properties
===================================================================
--- stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/etc/jbossws-roles.properties 2015-03-13 08:20:28 UTC (rev 19560)
+++ stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/etc/jbossws-roles.properties 2015-03-13 10:10:15 UTC (rev 19561)
@@ -1,2 +1,3 @@
# A sample roles.properties file for use with the UsersRolesLoginModule
-kermit=friend
\ No newline at end of file
+kermit=friend
+jbossws=admin
\ No newline at end of file
Modified: stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/etc/jbossws-users.properties
===================================================================
--- stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/etc/jbossws-users.properties 2015-03-13 08:20:28 UTC (rev 19560)
+++ stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/etc/jbossws-users.properties 2015-03-13 10:10:15 UTC (rev 19561)
@@ -1,2 +1,3 @@
# A sample users.properties file for use with the UsersRolesLoginModule
-kermit=thefrog
\ No newline at end of file
+kermit=thefrog
+jbossws=jbossws
\ No newline at end of file
Modified: stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextJSETestCase.java
===================================================================
--- stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextJSETestCase.java 2015-03-13 08:20:28 UTC (rev 19560)
+++ stack/cxf/branches/management/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextJSETestCase.java 2015-03-13 10:10:15 UTC (rev 19561)
@@ -21,13 +21,16 @@
*/
package org.jboss.test.ws.jaxws.samples.context;
+import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.net.HttpURLConnection;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
+import org.apache.cxf.helpers.IOUtils;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
@@ -35,6 +38,7 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.ws.common.utils.Base64;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestHelper;
import org.junit.AfterClass;
@@ -118,4 +122,19 @@
{
assertTrue("kermit is my friend", port.testIsUserInRole("friend"));
}
+
+ @Test
+ @RunAsClient
+ public void testManagementURL() throws Exception {
+ URL url = new URL(baseURL + "/jaxws-samples-context-jse/management?config");
+ String encoding = Base64.encodeBytes("jbossws:jbossws".getBytes());
+ HttpURLConnection connenction = (HttpURLConnection)url.openConnection();
+ connenction.setRequestProperty("Authorization", "Basic " + encoding);
+ connenction.connect();
+ assertEquals(200, connenction.getResponseCode());
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ IOUtils.copy(connenction.getInputStream(), bout);
+ assertTrue("Unexpected response", bout.toString().contains("\"type\":\"JAXWS_JSE\",\"securityDomain\":\"JBossWS\""));
+
+ }
}
9 years, 9 months
JBossWS SVN: r19560 - in stack/cxf/branches/management: modules/resources/src/main/resources/modules/wildfly800/org/jboss/ws/cxf/jbossws-cxf-server/main and 4 other directories.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2015-03-13 04:20:28 -0400 (Fri, 13 Mar 2015)
New Revision: 19560
Added:
stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetInterceptor.java
stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetOutIntercetpor.java
Modified:
stack/cxf/branches/management/modules/resources/src/main/resources/modules/wildfly800/org/jboss/ws/cxf/jbossws-cxf-server/main/module.xml
stack/cxf/branches/management/modules/resources/src/main/resources/modules/wildfly900/org/jboss/ws/cxf/jbossws-cxf-server/main/module.xml
stack/cxf/branches/management/modules/server/pom.xml
stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/branches/management/pom.xml
Log:
[JBWS-3881]:Create intereceptors to respond the url which query endpoint configuration and metrics
Modified: stack/cxf/branches/management/modules/resources/src/main/resources/modules/wildfly800/org/jboss/ws/cxf/jbossws-cxf-server/main/module.xml
===================================================================
--- stack/cxf/branches/management/modules/resources/src/main/resources/modules/wildfly800/org/jboss/ws/cxf/jbossws-cxf-server/main/module.xml 2015-03-13 08:15:43 UTC (rev 19559)
+++ stack/cxf/branches/management/modules/resources/src/main/resources/modules/wildfly800/org/jboss/ws/cxf/jbossws-cxf-server/main/module.xml 2015-03-13 08:20:28 UTC (rev 19560)
@@ -68,6 +68,7 @@
<module name="org.jboss.logging" />
<module name="org.apache.ws.security" />
<module name="org.picketbox" />
+ <module name="org.codehaus.jettison" />
<module name="org.springframework.spring" optional="true">
<imports>
<include path="META-INF"/>
Modified: stack/cxf/branches/management/modules/resources/src/main/resources/modules/wildfly900/org/jboss/ws/cxf/jbossws-cxf-server/main/module.xml
===================================================================
--- stack/cxf/branches/management/modules/resources/src/main/resources/modules/wildfly900/org/jboss/ws/cxf/jbossws-cxf-server/main/module.xml 2015-03-13 08:15:43 UTC (rev 19559)
+++ stack/cxf/branches/management/modules/resources/src/main/resources/modules/wildfly900/org/jboss/ws/cxf/jbossws-cxf-server/main/module.xml 2015-03-13 08:20:28 UTC (rev 19560)
@@ -68,6 +68,7 @@
<module name="org.jboss.logging" />
<module name="org.apache.ws.security" />
<module name="org.picketbox" />
+ <module name="org.codehaus.jettison"/>
<module name="org.springframework.spring" optional="true">
<imports>
<include path="META-INF"/>
Modified: stack/cxf/branches/management/modules/server/pom.xml
===================================================================
--- stack/cxf/branches/management/modules/server/pom.xml 2015-03-13 08:15:43 UTC (rev 19559)
+++ stack/cxf/branches/management/modules/server/pom.xml 2015-03-13 08:20:28 UTC (rev 19560)
@@ -251,6 +251,10 @@
<artifactId>jboss-jms-api_1.1_spec</artifactId>
</dependency>
<dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
Modified: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
--- stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2015-03-13 08:15:43 UTC (rev 19559)
+++ stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2015-03-13 08:20:28 UTC (rev 19560)
@@ -71,6 +71,7 @@
import org.jboss.wsf.stack.cxf.extensions.policy.PolicySetsAnnotationListener;
import org.jboss.wsf.stack.cxf.interceptor.EnableDecoupledFaultInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.EndpointAssociationInterceptor;
+import org.jboss.wsf.stack.cxf.interceptor.EndpointConfigsGetInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.HandlerAuthInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.NsCtxSelectorStoreInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.WSDLSoapAddressRewriteInterceptor;
@@ -204,6 +205,7 @@
//with the proper spi Endpoint retrieved in CXFServletExt
bus.getInInterceptors().add(new EndpointAssociationInterceptor());
bus.getInInterceptors().add(new EnableDecoupledFaultInterceptor());
+ bus.getInInterceptors().add(new EndpointConfigsGetInterceptor());
bus.getInInterceptors().add(new NsCtxSelectorStoreInterceptor());
final String p = (props != null) ? props.get(Constants.JBWS_CXF_DISABLE_HANDLER_AUTH_CHECKS) : null;
Added: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetInterceptor.java
===================================================================
--- stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetInterceptor.java (rev 0)
+++ stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetInterceptor.java 2015-03-13 08:20:28 UTC (rev 19560)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2015, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.interceptor;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cxf.binding.soap.interceptor.EndpointSelectionInterceptor;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.common.util.UrlUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.MessageSenderInterceptor;
+import org.apache.cxf.interceptor.OutgoingChainInterceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor;
+import org.jboss.wsf.spi.deployment.Endpoint;
+/**
+ * Interceptor to get json format endpoint config info. This interceptor is only
+ * responds to get url like http://localhost:8080/context/wsendpoint/management?config
+ *@author <a href="mailto:ema@redhat.com>Jim Ma</a>
+ *
+ */
+
+public class EndpointConfigsGetInterceptor extends AbstractPhaseInterceptor<Message> {
+ public static final EndpointConfigsGetInterceptor INSTANCE = new EndpointConfigsGetInterceptor();
+ public static final String ENDPOINT_CONFIGS = EndpointConfigsGetInterceptor.class.getName() + ".EndpointConfigs";
+ private Interceptor<Message> configsOutInteceptor = EndpointConfigsGetOutIntercetpor.INSTANCE;
+ private static final String TRANSFORM_SKIP = "transform.skip";
+ public EndpointConfigsGetInterceptor() {
+ super(Phase.READ);
+ getAfter().add(EndpointSelectionInterceptor.class.getName());
+ }
+
+ public EndpointConfigsGetInterceptor(Interceptor<Message> outInterceptor) {
+ this();
+ // Let people override the EndpointConfigsGetOutIntercetpor
+ configsOutInteceptor = outInterceptor;
+ }
+
+ public void handleMessage(Message message) throws Fault {
+ String method = (String)message.get(Message.HTTP_REQUEST_METHOD);
+ String query = (String)message.get(Message.QUERY_STRING);
+ HttpServletRequest request = (HttpServletRequest)message.get("HTTP.REQUEST");
+ if (!"GET".equals(method) || StringUtils.isEmpty(query) || !isValidUser(request)) {
+ return;
+ }
+
+ /*String baseUri = (String)message.get(Message.REQUEST_URL);
+ String ctx = (String)message.get(Message.PATH_INFO);*/
+
+ Map<String, String> map = UrlUtils.parseQueryString(query);
+ if (isRecognizedQuery(map)) {
+
+ Endpoint endpoint = message.getExchange().get(Endpoint.class);
+
+ Message mout = new MessageImpl();
+ mout.setExchange(message.getExchange());
+ mout = message.getExchange().get(org.apache.cxf.endpoint.Endpoint.class).getBinding().createMessage(mout);
+ mout.setInterceptorChain(OutgoingChainInterceptor.getOutInterceptorChain(message.getExchange()));
+ message.getExchange().setOutMessage(mout);
+
+ mout.put(ENDPOINT_CONFIGS, endpoint.getAllConfigsMap());
+ mout.put(Message.CONTENT_TYPE, "text/xml");
+ // just remove the interceptor which should not be used
+ cleanUpOutInterceptors(mout);
+ // notice this is being added after the purge above, don't swap the order!
+ mout.getInterceptorChain().add(configsOutInteceptor);
+
+ message.getExchange().put(TRANSFORM_SKIP, Boolean.TRUE);
+ // skip the service executor and goto the end of the chain.
+ message.getInterceptorChain().doInterceptStartingAt(
+ message,
+ OutgoingChainInterceptor.class.getName());
+ }
+ }
+
+ protected void cleanUpOutInterceptors(Message outMessage) {
+ // TODO - how can I improve this to provide a specific interceptor chain that just has the
+ // stax, gzip and message sender components, while also ensuring that GZIP is only provided
+ // if its already configured for the endpoint.
+ Iterator<Interceptor<? extends Message>> iterator = outMessage.getInterceptorChain().iterator();
+ while (iterator.hasNext()) {
+ Interceptor<? extends Message> inInterceptor = iterator.next();
+ if (!inInterceptor.getClass().equals(GZIPOutInterceptor.class)
+ && !inInterceptor.getClass().equals(MessageSenderInterceptor.class)) {
+ outMessage.getInterceptorChain().remove(inInterceptor);
+ }
+ }
+
+ }
+ private boolean isRecognizedQuery(Map<String, String> map) {
+
+ if (map.containsKey("config")) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isValidUser(HttpServletRequest req) {
+ if (req.getUserPrincipal() != null && req.isUserInRole("admin")) {
+ return true;
+ }
+ return false;
+ }
+}
\ No newline at end of file
Property changes on: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetInterceptor.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetOutIntercetpor.java
===================================================================
--- stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetOutIntercetpor.java (rev 0)
+++ stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetOutIntercetpor.java 2015-03-13 08:20:28 UTC (rev 19560)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2015, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.interceptor;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.util.Map;
+
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.StaxOutInterceptor;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.codehaus.jettison.AbstractXMLStreamWriter;
+import org.codehaus.jettison.mapped.MappedNamespaceConvention;
+import org.codehaus.jettison.mapped.MappedXMLStreamWriter;
+/**
+ * Out Interceptor to get json format endpoint config info. This interceptor is only
+ * responds to get url like http://localhost:8080/context/wsendpoint/management?config
+ *@author <a href="mailto:ema@redhat.com>Jim Ma</a>
+ *
+ */
+public class EndpointConfigsGetOutIntercetpor extends AbstractPhaseInterceptor<Message> {
+ public static final EndpointConfigsGetOutIntercetpor INSTANCE = new EndpointConfigsGetOutIntercetpor();
+
+ public EndpointConfigsGetOutIntercetpor() {
+ super(Phase.PRE_STREAM);
+ getAfter().add(StaxOutInterceptor.class.getName());
+ }
+
+ public void handleMessage(Message message) throws Fault {
+ @SuppressWarnings("unchecked")
+ Map<String, String> configMaps = (Map<String, String>)message.get(EndpointConfigsGetInterceptor.ENDPOINT_CONFIGS);
+ if (configMaps == null) {
+ return;
+ }
+ message.remove(EndpointConfigsGetInterceptor.ENDPOINT_CONFIGS);
+ OutputStream out = message.getContent(OutputStream.class);
+ if (out == null) {
+ return;
+ }
+ message.put(Message.CONTENT_TYPE, "text/xml");
+ OutputStreamWriter writer = null;
+ AbstractXMLStreamWriter mappedWriter = null;
+ try {
+ writer= new OutputStreamWriter(out, getEncoding(message));
+ mappedWriter = new MappedXMLStreamWriter(new MappedNamespaceConvention(), writer);
+ mappedWriter.writeStartDocument();
+ for (String key : configMaps.keySet()) {
+ String value = configMaps.get(key);
+ if (StringUtils.isEmpty(value)) {
+ mappedWriter.writeEmptyElement(key);
+ } else {
+ mappedWriter.writeStartElement(key);
+ mappedWriter.writeCharacters(configMaps.get(key));
+ mappedWriter.writeEndElement();
+ }
+ }
+ mappedWriter.writeEndDocument();
+ out.flush();
+ } catch (Exception e) {
+ throw new Fault(e);
+ } finally {
+ StaxUtils.close(mappedWriter);
+ }
+
+ }
+ private String getEncoding(Message message) {
+ Exchange ex = message.getExchange();
+ String encoding = (String)message.get(Message.ENCODING);
+ if (encoding == null && ex.getInMessage() != null) {
+ encoding = (String) ex.getInMessage().get(Message.ENCODING);
+ message.put(Message.ENCODING, encoding);
+ }
+
+ if (encoding == null) {
+ encoding = "UTF-8";
+ message.put(Message.ENCODING, encoding);
+ }
+ return encoding;
+ }
+}
+
Property changes on: stack/cxf/branches/management/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/EndpointConfigsGetOutIntercetpor.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified: stack/cxf/branches/management/pom.xml
===================================================================
--- stack/cxf/branches/management/pom.xml 2015-03-13 08:15:43 UTC (rev 19559)
+++ stack/cxf/branches/management/pom.xml 2015-03-13 08:20:28 UTC (rev 19560)
@@ -111,6 +111,7 @@
<arquillian-wildfly-container.version>1.0.0.Alpha5</arquillian-wildfly-container.version>
<jaspi.api.version>1.0.0.Alpha1</jaspi.api.version>
<javax.inject.version>1</javax.inject.version>
+ <jettison.version>1.3.1</jettison.version>
</properties>
@@ -1273,6 +1274,17 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ <version>${jettison.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
</dependencyManagement>
9 years, 9 months