Author: asoldano
Date: 2014-08-08 04:51:48 -0400 (Fri, 08 Aug 2014)
New Revision: 18831
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/WSDLSoapAddressRewriteInterceptor.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/util/
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/util/WSDLSoapAddressRewriteUtils.java
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/jbws2150/JBWS2150TestCaseForked.java
Log:
[JBWS-3750] Fixing build (broken due to commit 18830) by copying missing classes from
rsearls branch; also updating JBWS2150TestCaseForked to test additions
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java 2014-08-08
08:51:48 UTC (rev 18831)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.addressRewrite;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A map from char to char. The mappings for the most common 256 source
+ * characters are simply kept in a char array. For all other more exotic source
+ * characters, a proper hash map is used to store the mapping.
+ */
+final class CharMap {
+
+ private final char[] map = new char[256];
+ private final Map<Character, Character> extendedMap = new HashMap<Character,
Character>();
+
+ /**
+ * Creates a char map with the given source and destination characters. If
+ * the strings do not have the same length, subsequent characters in the
+ * longer string are ignored. The first mapping is defined as
+ * {@code source[0] --> destination[0]}, all other mappings in an analogous
+ * way with matching character indices in the two strings.
+ *
+ * @param source
+ * source characters
+ * @param destination
+ * destination characters
+ * @throws IllegalArgumentException
+ * if any of the destination characters is the zero character
+ */
+ public CharMap(String source, String destination) {
+ add(source, destination);
+ }
+
+ private void add(String source, String destination) {
+ final int len = Math.min(source.length(), destination.length());
+ for (int i = 0; i < len; i++) {
+ add(source.charAt(i), destination.charAt(i));
+ }
+ }
+
+ private void add(char source, char destination) {
+ if (destination == 0) {
+ throw new IllegalArgumentException("cannot map to zero character");
+ }
+ if (source < 256) {
+ map[source] = destination;
+ } else {
+ extendedMap.put(source, destination);
+ }
+ }
+
+ public char map(char source) {
+ if (source < 256) {
+ return map[source];
+ }
+ final Character mapped = extendedMap.get(source);
+ return mapped == null ? 0 : mapped.charValue();
+ }
+}
Property changes on:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java 2014-08-08
08:51:48 UTC (rev 18831)
@@ -0,0 +1,435 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.addressRewrite;
+
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+final class SEDProcessor {
+
+ private static enum SEDCommand {
+ SUBSTITUTE, TRANSLATE
+ }
+
+ private static final int[] EMPTY_OCCURRENCE = new int[0];
+
+ private final SEDCommand command;
+ private final String replacement;
+ private final int[] occurrences;
+ private final Pattern regexp;
+ private final SedArguments args;
+ private final CharMap charMap;
+
+ private SEDProcessor(String script, SEDCommand command)
+ {
+ this.command = command;
+ this.args = deriveArgs(script);
+ if (args.isIgnoreCase())
+ {
+ this.regexp = Pattern.compile(getRegexp(args), Pattern.CASE_INSENSITIVE);
+ }
+ else
+ {
+ this.regexp = Pattern.compile(getRegexp(args));
+ }
+ this.replacement = getReplacement(args);
+ this.occurrences = args.isOccurrenceSet() ? args.getOccurrence() :
EMPTY_OCCURRENCE;
+ for (int i = 0; i < occurrences.length; i++)
+ {
+ if (occurrences[i] <= 0)
+ {
+ throw new IllegalArgumentException("invalid occurrence index " +
occurrences[i] + " in sed command");
+ }
+ }
+ Arrays.sort(occurrences);
+ if (command == SEDCommand.TRANSLATE)
+ {
+ this.charMap = new CharMap(args.getString1(), args.getString2());
+ }
+ else
+ {
+ this.charMap = null;
+ }
+ }
+
+ /**
+ * Returns the regexp operand from args, either called "regexp" or
+ * "string1". If none of the two is set, an empty string is returned.
+ *
+ * @param args
+ * the args with operand values
+ * @return the regexp argument from "regexp" or "string1" or an
empty string
+ * of none of the two operands is set
+ */
+ private static String getRegexp(SedArguments args)
+ {
+ if (args.isRegexpSet())
+ {
+ return args.getRegexp();
+ }
+ if (args.isString1Set())
+ {
+ return args.getString1();
+ }
+ return "";
+ }
+
+ /**
+ * Returns the replacement operand from args, either called "replacement"
or
+ * "string2". If none of the two is set, an empty string is returned.
+ *
+ * @param args
+ * the args with operand values
+ * @return the replacement argument from "replacement" or
"string2" or an
+ * empty string of none of the two operands is set
+ */
+ private static String getReplacement(SedArguments args)
+ {
+ if (args.isReplacementSet())
+ {
+ return args.getReplacement();
+ }
+ if (args.isString2Set())
+ {
+ return args.getString2();
+ }
+ return "";
+ }
+
+ private SedArguments deriveArgs(String script)
+ {
+ final int start = findStartTrimWhitespace(script) + 1;
+ final int mid = indexOfNextDelimiter(script, start);
+ final int end = indexOfNextDelimiter(script, mid);
+ if (mid < 0 || end < 0)
+ {
+ throw new IllegalArgumentException("invalid script for sed command: "
+ script);
+ }
+ if (command == SEDCommand.SUBSTITUTE)
+ {
+ SedArguments args = parseSubstituteFlags(script, end + 1);
+ args.setRegexp(script.substring(start + 1, mid));
+ args.setReplacement(script.substring(mid + 1, end));
+ return args;
+ }
+ else if (command == SEDCommand.TRANSLATE)
+ {
+ SedArguments args = new SedArguments();
+ args.setScript(script);
+ args.setTranslate(true);
+ final int scriptEnd = findEndTrimWhitespace(script);
+ if (end + 1 < scriptEnd)
+ {
+ throw new IllegalArgumentException("non-whitespace characters found
after " + command + " command in sed script: " + script);
+ }
+ args.setString1(script.substring(start + 1, mid));
+ args.setString2(script.substring(mid + 1, end));
+ return args;
+ }
+ else
+ {
+ throw new IllegalStateException();
+ }
+ }
+
+ private static SedArguments parseSubstituteFlags(String script, int start)
+ {
+ final int end = findWhitespace(script, start);
+ if (end < findEndTrimWhitespace(script))
+ {
+ throw new IllegalArgumentException("extra non-whitespace characters found
after substitute command in sed script: " + script);
+ }
+ SedArguments args = new SedArguments();
+ args.setScript(script);
+ args.setSubstitute(true);
+ if (start < end)
+ {
+ //g, I flags
+ int index;
+ for (index = end - 1; index >= start; index--)
+ {
+ final char flag = script.charAt(index);
+ if (flag == 'g')
+ {
+ args.setGlobal(true);
+ }
+ else if (flag == 'I')
+ {
+ args.setIgnoreCase(true);
+ }
+ else
+ {
+ break;
+ }
+ }
+ //occurrence index
+ if (index >= start)
+ {
+ final String occurrenceStr = script.substring(start, index + 1);
+ final int occurrence;
+ try
+ {
+ occurrence = Integer.parseInt(occurrenceStr);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException("invalid substitute flags in sed
script: " + script, e);
+ }
+ if (occurrence <= 0)
+ {
+ throw new IllegalArgumentException("invalid occurrence index " +
occurrence + " in sed script: " + script);
+ }
+ args.setOccurrence(occurrence);
+ }
+ }
+ return args;
+ }
+
+ public String processLine(String line)
+ {
+ if (command == SEDCommand.SUBSTITUTE)
+ {
+ final Matcher matcher = regexp.matcher(line);
+ if (matcher.find())
+ {
+ boolean matches = true;
+ final StringBuffer changed = new StringBuffer();//cannot use StringBuilder
here since matcher does not support it
+ if (occurrences.length > 0)
+ {
+ int current = 1;
+ for (int i = 0; i < occurrences.length; i++)
+ {
+ final int occurrence = occurrences[i];
+ while (matches && current < occurrence)
+ {
+ matches = matcher.find();
+ current++;
+ }
+ if (matches)
+ {
+ matcher.appendReplacement(changed, replacement);
+ }
+ else
+ {
+ break;
+ }
+ }
+ if (matches && occurrences.length == 1 &&
args.isGlobal())
+ {
+ matches = matcher.find();
+ while (matches)
+ {
+ matcher.appendReplacement(changed, replacement);
+ matches = matcher.find();
+ }
+ }
+ }
+ else
+ {
+ while (matches)
+ {
+ matcher.appendReplacement(changed, replacement);
+ matches = args.isGlobal() && matcher.find();
+ }
+ }
+ matcher.appendTail(changed);
+ return changed.toString();
+ }
+ else
+ {
+ return line;
+ }
+ }
+ else if (command == SEDCommand.TRANSLATE)
+ {
+ char[] changed = null;
+ final int len = line.length();
+ for (int i = 0; i < len; i++)
+ {
+ final char src = line.charAt(i);
+ final char dst = charMap.map(src);
+ if (dst != 0)
+ {
+ if (changed == null)
+ {
+ changed = new char[len];
+ for (int j = 0; j < i; j++)
+ {
+ changed[j] = line.charAt(j);
+ }
+ }
+ changed[i] = dst;
+ }
+ else
+ {
+ if (changed != null)
+ {
+ changed[i] = src;
+ }
+ }
+ }
+ return changed != null ? String.valueOf(changed) : line;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns the index of the next delimiter in the given sed script. The
+ * character at {@code indexOfPreviousDelimiter} is taken as delimiter. The
+ * method handles escaped delimiters and returns -1 if no further delimiter
+ * is found.
+ *
+ * @param script
+ * the script to analyze
+ * @param indexOfPreviousDelimiter
+ * the index of the previous delimiter
+ * @return the index of the next delimiter after
+ * {@code indexOfPreviousDelimiter}, or -1 if no further delimiter
+ * exists of if {@code indexOfNextDelimiter < 0}
+ */
+ private static int indexOfNextDelimiter(String script, int indexOfPreviousDelimiter)
+ {
+ if (indexOfPreviousDelimiter < 0 || script.length() <=
indexOfPreviousDelimiter)
+ {
+ return -1;
+ }
+ final char delim = script.charAt(indexOfPreviousDelimiter);
+ if (delim == '\\')
+ {
+ throw new IllegalArgumentException("invalid delimiter '\\' in sed
script: " + script);
+ }
+ int index = indexOfPreviousDelimiter;
+ do
+ {
+ index = script.indexOf(delim, index + 1);
+ }
+ while (index >= 0 && isEscaped(script, index));
+ return index;
+ }
+
+ private static boolean isEscaped(String script, int index)
+ {
+ int backslashCount = 0;
+ index--;
+ while (index >= 0 && script.charAt(index) == '\\')
+ {
+ backslashCount++;
+ index--;
+ }
+ // an uneven count of backslashes means that the character at position
+ // index is escaped (an even count of backslashes escapes backslashes)
+ return backslashCount % 2 == 1;
+ }
+
+ /**
+ * Finds and returns the start of the given sequence after trimming
+ * whitespace characters from the left.
+ *
+ * @param s
+ * the character sequence
+ * @return the index containing the first non-whitespace character, or the
+ * length of the character sequence if all characters are blank
+ */
+ private static int findStartTrimWhitespace(CharSequence s)
+ {
+ final int len = s.length();
+ for (int i = 0; i < len; i++)
+ {
+ if (!Character.isWhitespace(s.charAt(i)))
+ {
+ return i;
+ }
+ }
+ return len;
+ }
+
+ /**
+ * Finds and returns the first whitespace character in the given sequence at
+ * or after start. Returns the length of the string if no whitespace is
+ * found.
+ *
+ * @param s
+ * the character sequence
+ * @param start
+ * the first index to consider in the char sequence
+ * @return the index containing the first whitespace character at or after
+ * start, or the length of the character sequence if all characters
+ * are blank
+ */
+ private static int findWhitespace(CharSequence s, int start)
+ {
+ final int len = s.length();
+ for (int i = start; i < len; i++)
+ {
+ if (Character.isWhitespace(s.charAt(i)))
+ {
+ return i;
+ }
+ }
+ return len;
+ }
+
+ /**
+ * Finds and returns the end of the given character sequence after trimming
+ * white space characters from the right. Whitespace characters are defined
+ * by {@link Character#isWhitespace(char)}. .
+ *
+ * @param s
+ * the character sequence
+ * @return the index after the last non-whitespace character, or zero if all
+ * characters are blank
+ */
+ private static int findEndTrimWhitespace(CharSequence s)
+ {
+ for (int i = s.length(); i > 0; i--)
+ {
+ if (!Character.isWhitespace(s.charAt(i - 1)))
+ {
+ return i;
+ }
+ }
+ return 0;
+ }
+
+ public static SEDProcessor newInstance(String script)
+ {
+ final int len = script.length();
+ final int scriptStart = findStartTrimWhitespace(script);
+ if (scriptStart < len)
+ {
+ final char firstChar = script.charAt(scriptStart);
+ if (firstChar == 's')
+ {
+ return new SEDProcessor(script, SEDCommand.SUBSTITUTE);
+ }
+ else if (firstChar == 'y')
+ {
+ return new SEDProcessor(script, SEDCommand.TRANSLATE);
+ }
+ }
+ throw new IllegalArgumentException("invalid script");
+ }
+}
\ No newline at end of file
Property changes on:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java 2014-08-08
08:51:48 UTC (rev 18831)
@@ -0,0 +1,211 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.addressRewrite;
+
+final class SedArguments
+{
+ private boolean isGlobal = false;
+ private boolean isIgnoreCase = false;
+ private boolean isTranslate = false;
+ private boolean isSubstitute = false;
+ private String script;
+ private boolean scriptIsSet = false;
+ private String regexp;
+ private boolean regexpIsSet = false;
+ private String string1;
+ private boolean string1IsSet = false;
+ private String replacement;
+ private boolean replacementIsSet = false;
+ private String string2;
+ private boolean string2IsSet = false;
+ private int[] occurrence;
+ private boolean occurrenceIsSet = false;
+
+ /**
+ * Constructor to use if no options are specified.
+ */
+ public SedArguments()
+ {
+
+ }
+
+ public String getScript()
+ {
+ if (scriptIsSet)
+ {
+ return script;
+ }
+ throw new IllegalStateException("operand has not been set: " + script);
+ }
+
+ public boolean isScriptSet()
+ {
+ return scriptIsSet;
+ }
+
+ public void setScript(String script)
+ {
+ this.script = script;
+ this.scriptIsSet = true;
+ }
+
+ public String getRegexp()
+ {
+ if (regexpIsSet)
+ {
+ return regexp;
+ }
+ throw new IllegalStateException("operand has not been set: " + regexp);
+ }
+
+ public boolean isRegexpSet()
+ {
+ return regexpIsSet;
+ }
+
+ public void setRegexp(String regexp)
+ {
+ this.regexp = regexp;
+ this.regexpIsSet = true;
+ }
+
+ public String getString1()
+ {
+ if (string1IsSet)
+ {
+ return string1;
+ }
+ throw new IllegalStateException("operand has not been set: " + string1);
+ }
+
+ public boolean isString1Set()
+ {
+ return string1IsSet;
+ }
+
+ public void setString1(String string1)
+ {
+ this.string1 = string1;
+ this.string1IsSet = true;
+ }
+
+ public String getReplacement()
+ {
+ if (replacementIsSet)
+ {
+ return replacement;
+ }
+ throw new IllegalStateException("operand has not been set: " +
replacement);
+ }
+
+ public boolean isReplacementSet()
+ {
+ return replacementIsSet;
+ }
+
+ public void setReplacement(String replacement)
+ {
+ this.replacement = replacement;
+ this.replacementIsSet = true;
+ }
+
+ public String getString2()
+ {
+ if (string2IsSet)
+ {
+ return string2;
+ }
+ throw new IllegalStateException("operand has not been set: " + string2);
+ }
+
+ public boolean isString2Set()
+ {
+ return string2IsSet;
+ }
+
+ public void setString2(String string2)
+ {
+ this.string2 = string2;
+ this.string2IsSet = true;
+ }
+
+ public int[] getOccurrence()
+ {
+ if (occurrenceIsSet)
+ {
+ return occurrence;
+ }
+ throw new IllegalStateException("operand has not been set: " +
occurrence);
+ }
+
+ public boolean isOccurrenceSet()
+ {
+ return occurrenceIsSet;
+ }
+
+ public void setOccurrence(int... occurrence)
+ {
+ this.occurrence = occurrence;
+ this.occurrenceIsSet = true;
+ }
+
+ public boolean isGlobal()
+ {
+ return isGlobal;
+ }
+
+ public boolean isIgnoreCase()
+ {
+ return isIgnoreCase;
+ }
+
+ public boolean isSubstitute()
+ {
+ return isSubstitute;
+ }
+
+ public boolean isTranslate()
+ {
+ return isTranslate;
+ }
+
+ public void setGlobal(boolean isGlobal)
+ {
+ this.isGlobal = isGlobal;
+ }
+
+ public void setIgnoreCase(boolean isIgnoreCase)
+ {
+ this.isIgnoreCase = isIgnoreCase;
+ }
+
+ public void setTranslate(boolean isTranslate)
+ {
+ this.isTranslate = isTranslate;
+ }
+
+ public void setSubstitute(boolean isSubstitute)
+ {
+ this.isSubstitute = isSubstitute;
+ }
+
+}
Property changes on:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
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 2014-08-07
17:03:51 UTC (rev 18830)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2014-08-08
08:51:48 UTC (rev 18831)
@@ -157,7 +157,7 @@
JaxWsImplementorInfo info = new
JaxWsImplementorInfo(getImplementorClass());
wsdlLocation = info.getWsdlLocation();
}
- updateCodeFirstSoapAddress();
+ updateSoapAddress();
wsdlPublisher.publishWsdlFiles(service.getName(), wsdlLocation,
this.getBus(), service.getServiceInfos());
}
catch (IOException ioe)
@@ -206,7 +206,7 @@
* For both code-first and wsdl-first scenarios, reset the endpoint address
* so that it is written to the generated wsdl file.
*/
- private void updateCodeFirstSoapAddress() {
+ private void updateSoapAddress() {
ServerConfig servConfig = getServerConfig();
if (servConfig.isModifySOAPAddress()) {
//- code-first handling
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/WSDLSoapAddressRewriteInterceptor.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/WSDLSoapAddressRewriteInterceptor.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/WSDLSoapAddressRewriteInterceptor.java 2014-08-08
08:51:48 UTC (rev 18831)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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 org.apache.cxf.frontend.WSDLGetUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.jboss.wsf.stack.cxf.interceptor.util.WSDLSoapAddressRewriteUtils;
+
+/**
+ * This inInterceptor registers a custom WSDLGetUtils which will preform the desired
+ * soap:address rewrite
+ *
+ * @author rsearls(a)redhat.com
+ * @since 19-May-2014
+ */
+public class WSDLSoapAddressRewriteInterceptor extends
AbstractPhaseInterceptor<Message> {
+ public static final WSDLSoapAddressRewriteInterceptor INSTANCE =
+ new WSDLSoapAddressRewriteInterceptor();
+
+ public WSDLSoapAddressRewriteInterceptor() {
+ // this must run before WSDLGetInterceptor which is in Phase.READ
+ super(Phase.POST_STREAM);
+ }
+
+ public void handleMessage(Message message) throws Fault {
+ message.setContextualProperty(WSDLGetUtils.class.getName(), new
WSDLSoapAddressRewriteUtils());
+ }
+
+}
Property changes on:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/WSDLSoapAddressRewriteInterceptor.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/util/WSDLSoapAddressRewriteUtils.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/util/WSDLSoapAddressRewriteUtils.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/util/WSDLSoapAddressRewriteUtils.java 2014-08-08
08:51:48 UTC (rev 18831)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.util;
+
+import java.security.AccessController;
+
+import javax.wsdl.Definition;
+
+import org.apache.cxf.frontend.WSDLGetUtils;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.jboss.ws.common.management.AbstractServerConfig;
+import org.jboss.wsf.spi.management.ServerConfig;
+import org.jboss.wsf.stack.cxf.addressRewrite.SoapAddressRewriteHelper;
+
+/**
+ * This is an extension of the org.apache.cxf.frontend.WSDLGetUtils; currently this
+ * is needed for properly setting the publishedEndpointURL in the code-first scenario
+ * when a path rewrite rule is specified in the server configuration.
+ *
+ * @author rsearls(a)redhat.com
+ *
+ */
+public class WSDLSoapAddressRewriteUtils extends WSDLGetUtils {
+
+ @Override
+ public String getPublishableEndpointUrl(Definition def, String epurl,
+ EndpointInfo endpointInfo){
+
+ if (endpointInfo.getProperty(PUBLISHED_ENDPOINT_URL) != null) {
+ epurl = String.valueOf(endpointInfo.getProperty(PUBLISHED_ENDPOINT_URL));
+ updatePublishedEndpointUrl(epurl, def, endpointInfo.getName());
+ } else {
+ // When using replacement path, must set replacement path in the active url.
+ final ServerConfig sc = getServerConfig();
+ if (SoapAddressRewriteHelper.isPathRewriteRequired(sc)
+ &&
endpointInfo.getAddress().contains(ServerConfig.UNDEFINED_HOSTNAME)) {
+ epurl = SoapAddressRewriteHelper.getRewrittenPublishedEndpointUrl(epurl,
sc);
+ updatePublishedEndpointUrl(epurl, def, endpointInfo.getName());
+ }
+ }
+ return epurl;
+ }
+
+ private static ServerConfig getServerConfig() {
+ if(System.getSecurityManager() == null) {
+ return AbstractServerConfig.getServerIntegrationServerConfig();
+ }
+ return
AccessController.doPrivileged(AbstractServerConfig.GET_SERVER_INTEGRATION_SERVER_CONFIG);
+ }
+}
Property changes on:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/util/WSDLSoapAddressRewriteUtils.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java 2014-08-07
17:03:51 UTC (rev 18830)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java 2014-08-08
08:51:48 UTC (rev 18831)
@@ -119,6 +119,7 @@
protected static Boolean modifySOAPAddress;
protected static String webServiceHost;
+ protected static String webServicePath;
public JBWS2150TestSetup() {
super(JBWS2150TestCaseForked.class, null);
@@ -128,6 +129,7 @@
{
modifySOAPAddress = (Boolean)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"ModifySOAPAddress");
webServiceHost = (String)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"WebServiceHost");
+ webServicePath = (String)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"WebServicePathRewriteRule");
super.setUp();
}
}
@@ -143,6 +145,8 @@
getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
attr = new Attribute("WebServiceHost",
JBWS2150TestSetup.webServiceHost);
getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
+ attr = new Attribute("WebServicePathRewriteRule",
JBWS2150TestSetup.webServicePath);
+ getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
}
private String getWebServiceHost() {
@@ -570,6 +574,168 @@
}
}
+ /**
+ * Test soap:address rewrite when a path rewrite rule is specified.
+ *
+ * @throws Exception
+ */
+ public void testRewriteWithPathRule() throws Exception
+ {
+ setModifySOAPAddress(true);
+ final String expectedContext = "xx/jaxws-jbws2150";
+ final String sedCmd = "s/jaxws-jbws2150/xx\\/jaxws-jbws2150/g";
+ setWebServicePathRewriteRule(sedCmd);
+ deploy("jaxws-jbws2150.war");
+ try
+ {
+ final String serverHost = getServerHost();
+ final List<String> wsdlLocations = new LinkedList<String>();
+ wsdlLocations.add("http://" + serverHost +
":8080/jaxws-jbws2150/ValidURL?wsdl");
+ wsdlLocations.add("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidURL?wsdl");
+ wsdlLocations.add("http://" + serverHost +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl");
+ wsdlLocations.add("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl");
+
+ for (final String wsdlLocation : wsdlLocations)
+ {
+ Definition definition = getWSDLDefinition(wsdlLocation);
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("http://" + serverHost + ":8080/" +
expectedContext + "/ValidURL", address);
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("http://" + serverHost + ":8080/" +
expectedContext + "/InvalidURL", address);
+
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("https://" + serverHost + ":8443/" +
expectedContext + "/ValidSecureURL", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("https://" + serverHost + ":8443/" +
expectedContext + "/InvalidSecureURL", address);
+
+ //check wsdl import (which is bound to the endpoint currently serving the
wsdl)
+ assertTrue(getWsdlImportAddress(definition).contains(expectedContext));
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150.war");
+ }
+ }
+
+ /**
+ * Test soap:address rewrite for code-first endpoints when a path rewrite rule is
specified
+ *
+ * @throws Exception
+ */
+ public void testRewriteCodeFirstPathRule() throws Exception
+ {
+ setModifySOAPAddress(true);
+ final String expectedContext = "xx/jaxws-jbws2150-codefirst";
+ final String sedCmd =
"s/jaxws-jbws2150-codefirst/xx\\/jaxws-jbws2150-codefirst/g";
+ setWebServicePathRewriteRule(sedCmd);
+ deploy("jaxws-jbws2150-codefirst.war");
+ try
+ {
+ final String serverHost = getServerHost();
+ final String wsdlLocation = "http://" + serverHost +
":8080/jaxws-jbws2150-codefirst/CodeFirstService?wsdl";
+
+ Definition definition = getWSDLDefinition(wsdlLocation);
+ String address = getPortAddress(definition, "CodeFirstService",
"CodeFirstPort");
+ assertEquals("http://" + serverHost + ":8080/" +
expectedContext +"/CodeFirstService", address);
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150-codefirst.war");
+ }
+ }
+
+ /**
+ * Test soap:address rewrite for code-first endpoints when a path rewrite rule is
specified and auto-rewrite is on
+ * (wsdl host prop set to ServerConfig.UNDEFINED_HOSTNAME)
+ *
+ * @throws Exception
+ */
+ public void testAutoRewriteCodeFirstPathRule() throws Exception
+ {
+ setModifySOAPAddress(true);
+ final String expectedContext = "xx/jaxws-jbws2150-codefirst";
+ final String sedCmd =
"s/jaxws-jbws2150-codefirst/xx\\/jaxws-jbws2150-codefirst/g";
+ setWebServicePathRewriteRule(sedCmd);
+ setWebServiceHost(ServerConfig.UNDEFINED_HOSTNAME);
+ deploy("jaxws-jbws2150-codefirst.war");
+ try
+ {
+ String serverHost = getServerHost();
+ final String wsdlLocation = "http://" + serverHost +
":8080/jaxws-jbws2150-codefirst/CodeFirstService?wsdl";
+
+ Definition definition = getWSDLDefinition(wsdlLocation);
+ String address = getPortAddress(definition, "CodeFirstService",
"CodeFirstPort");
+ assertEquals("http://" + serverHost + ":8080/" +
expectedContext +"/CodeFirstService", address);
+ if (isTestsuiteServerHostLocalhost()) {
+ definition =
getWSDLDefinition("http://127.0.0.1:8080/jaxws-jbws2150-codefirst/CodeFirstService?wsdl");
+ address = getPortAddress(definition, "CodeFirstService",
"CodeFirstPort");
+ assertEquals("http://127.0.0.1:8080/" + expectedContext
+"/CodeFirstService", address);
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150-codefirst.war");
+ }
+ }
+
+ /**
+ * Test soap:address rewrite with host configured to ServerConfig.UNDEFINED_HOSTNAME
and path rewrite rule specified
+ *
+ * @throws Exception
+ */
+ public void testAutoRewritePathRule() throws Exception
+ {
+ setModifySOAPAddress(true);
+ final String expectedContext = "xx/jaxws-jbws2150";
+ final String sedCmd = "s/jaxws-jbws2150/xx\\/jaxws-jbws2150/g";
+ setWebServicePathRewriteRule(sedCmd);
+ setWebServiceHost(ServerConfig.UNDEFINED_HOSTNAME);
+ deploy("jaxws-jbws2150.war");
+ try
+ {
+ final Map<String, String> wsdlLocationsMap = new HashMap<String,
String>();
+ final String serverHost = getServerHost();
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidURL?wsdl", serverHost);
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidURL?wsdl", serverHost);
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl", serverHost);
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl", serverHost);
+ if (isTestsuiteServerHostLocalhost()) {
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidURL?wsdl",
"127.0.0.1");
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidURL?wsdl",
"127.0.0.1");
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidSecureURL?wsdl",
"127.0.0.1");
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidSecureURL?wsdl",
"127.0.0.1");
+ }
+ for (Entry<String, String> entry : wsdlLocationsMap.entrySet()) {
+ String wsdlLocation = entry.getKey();
+ String host = entry.getValue();
+ Definition definition = getWSDLDefinition(wsdlLocation);
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("http://" + host + ":8080/" +
expectedContext + "/ValidURL", address);
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("http://" + host + ":8080/" +
expectedContext + "/InvalidURL", address);
+
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("http://" + host + ":8080/" +
expectedContext + "/ValidSecureURL", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("http://" + host + ":8080/" +
expectedContext + "/InvalidSecureURL", address);
+
+ //check wsdl import (which is bound to the endpoint currently serving the
wsdl)
+ assertTrue(getWsdlImportAddress(definition).contains(expectedContext));
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150.war");
+ }
+ }
+
private void checkWsdlAndInvokeCodeFirstEndpoint(String testHost, String
expectedWsdlHost, boolean setTargetAddress) throws Exception {
final String addr = "http://" + testHost +
":8080/jaxws-jbws2150-codefirst/CodeFirstService";
final String wsdlLocation = addr + "?wsdl";
@@ -600,6 +766,12 @@
Attribute attr = new Attribute("WebServiceHost", value);
getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
}
+
+ public void setWebServicePathRewriteRule(String value) throws Exception
+ {
+ Attribute attr = new Attribute("WebServicePathRewriteRule", value);
+ getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
+ }
private ServiceIface getEndpoint(String wsdlLocation, String serviceName) throws
Exception
{