feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,272 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
// Cut & paste from tomcat
/**
* This class provides encode/decode for RFC 2045 Base64 as
* defined by RFC 2045, N. Freed and N. Borenstein.
* RFC 2045: Multipurpose Internet Mail Extensions (MIME)
* Part One: Format of Internet Message Bodies. Reference
* 1996 Available at: http://www.ietf.org/rfc/rfc2045.txt
* This class is used by XML Schema binary format validation
*
* @author Jeffrey Rodriguez
* @version
*/
public final class Base64 {
static private final int BASELENGTH = 255;
static private final int LOOKUPLENGTH = 63;
static private final int TWENTYFOURBITGROUP = 24;
static private final int EIGHTBIT = 8;
static private final int SIXTEENBIT = 16;
static private final int SIXBIT = 6;
static private final int FOURBYTE = 4;
static private final byte PAD = ( byte ) '=';
static private byte [] base64Alphabet = new byte[BASELENGTH];
static private byte [] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
static {
for (int i = 0; i<BASELENGTH; i++ ) {
base64Alphabet[i] = -1;
}
for ( int i = 'Z'; i >= 'A'; i-- ) {
base64Alphabet[i] = (byte) (i-'A');
}
for ( int i = 'z'; i>= 'a'; i--) {
base64Alphabet[i] = (byte) ( i-'a' + 26);
}
for ( int i = '9'; i >= '0'; i--) {
base64Alphabet[i] = (byte) (i-'0' + 52);
}
base64Alphabet['+'] = 62;
base64Alphabet['/'] = 63;
for (int i = 0; i<=25; i++ )
lookUpBase64Alphabet[i] = (byte) ('A'+i );
for (int i = 26, j = 0; i<=51; i++, j++ )
lookUpBase64Alphabet[i] = (byte) ('a'+ j );
for (int i = 52, j = 0; i<=61; i++, j++ )
lookUpBase64Alphabet[i] = (byte) ('0' + j );
}
static boolean isBase64( byte octect ) {
//shall we ignore white space? JEFF??
return(octect == PAD || base64Alphabet[octect] != -1 );
}
static boolean isArrayByteBase64( byte[] arrayOctect ) {
int length = arrayOctect.length;
if ( length == 0 )
return false;
for ( int i=0; i < length; i++ ) {
if ( Base64.isBase64( arrayOctect[i] ) == false)
return false;
}
return true;
}
/**
* Encodes hex octects into Base64
*
* @param binaryData Array containing binaryData
* @return Encoded Base64 array
*/
public static byte[] encode( byte[] binaryData ) {
int lengthDataBits = binaryData.length*EIGHTBIT;
int fewerThan24bits = lengthDataBits%TWENTYFOURBITGROUP;
int numberTriplets = lengthDataBits/TWENTYFOURBITGROUP;
byte encodedData[] = null;
if ( fewerThan24bits != 0 ) //data not divisible by 24 bit
encodedData = new byte[ (numberTriplets + 1 )*4 ];
else // 16 or 8 bit
encodedData = new byte[ numberTriplets*4 ];
byte k=0, l=0, b1=0,b2=0,b3=0;
int encodedIndex = 0;
int dataIndex = 0;
int i = 0;
for ( i = 0; i<numberTriplets; i++ ) {
dataIndex = i*3;
b1 = binaryData[dataIndex];
b2 = binaryData[dataIndex + 1];
b3 = binaryData[dataIndex + 2];
l = (byte)(b2 & 0x0f);
k = (byte)(b1 & 0x03);
encodedIndex = i*4;
encodedData[encodedIndex] = lookUpBase64Alphabet[ b1 >>2 ];
encodedData[encodedIndex+1] = lookUpBase64Alphabet[(b2 >>4 ) |
( k<<4 )];
encodedData[encodedIndex+2] = lookUpBase64Alphabet[ (l <<2 ) |
( b3>>6)];
encodedData[encodedIndex+3] = lookUpBase64Alphabet[ b3 & 0x3f ];
}
// form integral number of 6-bit groups
dataIndex = i*3;
encodedIndex = i*4;
if (fewerThan24bits == EIGHTBIT ) {
b1 = binaryData[dataIndex];
k = (byte) ( b1 &0x03 );
encodedData[encodedIndex] = lookUpBase64Alphabet[ b1 >>2 ];
encodedData[encodedIndex + 1] = lookUpBase64Alphabet[ k<<4 ];
encodedData[encodedIndex + 2] = PAD;
encodedData[encodedIndex + 3] = PAD;
} else if ( fewerThan24bits == SIXTEENBIT ) {
b1 = binaryData[dataIndex];
b2 = binaryData[dataIndex +1 ];
l = ( byte ) ( b2 &0x0f );
k = ( byte ) ( b1 &0x03 );
encodedData[encodedIndex] = lookUpBase64Alphabet[ b1 >>2 ];
encodedData[encodedIndex + 1] = lookUpBase64Alphabet[ (b2 >>4 )
| ( k<<4 )];
encodedData[encodedIndex + 2] = lookUpBase64Alphabet[ l<<2 ];
encodedData[encodedIndex + 3] = PAD;
}
return encodedData;
}
/**
* Decodes Base64 data into octects
*
* @param binaryData Byte array containing Base64 data
* @return Array containind decoded data.
*/
public byte[] decode( byte[] base64Data ) {
int numberQuadruple = base64Data.length/FOURBYTE;
byte decodedData[] = null;
byte b1=0,b2=0,b3=0, b4=0, marker0=0, marker1=0;
// Throw away anything not in base64Data
// Adjust size
int encodedIndex = 0;
int dataIndex = 0;
decodedData = new byte[ numberQuadruple*3 + 1 ];
for (int i = 0; i<numberQuadruple; i++ ) {
dataIndex = i*4;
marker0 = base64Data[dataIndex +2];
marker1 = base64Data[dataIndex +3];
b1 = base64Alphabet[base64Data[dataIndex]];
b2 = base64Alphabet[base64Data[dataIndex +1]];
if ( marker0 != PAD && marker1 != PAD ) { //No PAD e.g 3cQl
b3 = base64Alphabet[ marker0 ];
b4 = base64Alphabet[ marker1 ];
decodedData[encodedIndex] = (byte)( b1 <<2 | b2>>4 ) ;
decodedData[encodedIndex+1] = (byte)(((b2 & 0xf)<<4 ) |(
(b3>>2) & 0xf) );
decodedData[encodedIndex+2] = (byte)( b3<<6 | b4 );
} else if ( marker0 == PAD ) { //Two PAD e.g. 3c[Pad][Pad]
decodedData[encodedIndex] = (byte)( b1 <<2 | b2>>4 ) ;
decodedData[encodedIndex+1] = (byte)((b2 & 0xf)<<4 );
decodedData[encodedIndex+2] = (byte) 0;
} else if ( marker1 == PAD ) { //One PAD e.g. 3cQ[Pad]
b3 = base64Alphabet[ marker0 ];
decodedData[encodedIndex] = (byte)( b1 <<2 | b2>>4 );
decodedData[encodedIndex+1] = (byte)(((b2 & 0xf)<<4 ) |(
(b3>>2) & 0xf) );
decodedData[encodedIndex+2] = (byte)( b3<<6);
}
encodedIndex += 3;
}
return decodedData;
}
static final int base64[]= {
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64,
64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64,
64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
};
public static String base64Decode( String orig ) {
char chars[]=orig.toCharArray();
StringBuffer sb=new StringBuffer();
int i=0;
int shift = 0; // # of excess bits stored in accum
int acc = 0;
for (i=0; i<chars.length; i++) {
int v = base64[ chars[i] & 0xFF ];
if ( v >= 64 ) {
if( chars[i] != '=' )
System.out.println("Wrong char in base64: " + chars[i]);
} else {
acc= ( acc << 6 ) | v;
shift += 6;
if ( shift >= 8 ) {
shift -= 8;
sb.append( (char) ((acc >> shift) & 0xff));
}
}
}
return sb.toString();
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.io.ByteArrayInputStream;
import java.io.IOException;
// This class just gives access to the underlying buffer without copying.
public class ByteInputStream extends ByteArrayInputStream {
private static final byte[] EMPTY_ARRAY = new byte[0];
public ByteInputStream() {
this(EMPTY_ARRAY, 0);
}
public ByteInputStream(byte buf[], int length) {
super(buf, 0, length);
}
public ByteInputStream(byte buf[], int offset, int length) {
super(buf, offset, length);
}
public byte[] getBytes() {
return buf;
}
public int getCount() {
return count;
}
public void close() throws IOException {
reset();
}
public void setBuf(byte[] buf) {
this.buf = buf;
this.pos = 0;
this.count = buf.length;
}
}

View File

@@ -0,0 +1,180 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
/**
* Customized {@link BufferedOutputStream}.
*
* <p>
* Compared to {@link BufferedOutputStream},
* this class:
*
* <ol>
* <li>doesn't do synchronization
* <li>allows access to the raw buffer
* <li>almost no parameter check
*/
public final class ByteOutputStream extends OutputStream {
/**
* The buffer where data is stored.
*/
protected byte[] buf;
/**
* The number of valid bytes in the buffer.
*/
protected int count = 0;
public ByteOutputStream() {
this(1024);
}
public ByteOutputStream(int size) {
buf = new byte[size];
}
/**
* Copies all the bytes from this input into this buffer.
*/
public void write(InputStream in) throws IOException {
if (in instanceof ByteArrayInputStream) {
int size = in.available();
ensureCapacity(size);
count += in.read(buf,count,size);
return;
}
while(true) {
int cap = buf.length-count;
int sz = in.read(buf,count,cap);
if(sz<0) return; // hit EOS
count += sz;
if(cap==sz)
// the buffer filled up. double the buffer
ensureCapacity(count);
}
}
public void write(int b) {
ensureCapacity(1);
buf[count] = (byte) b;
count++;
}
/**
* Ensure that the buffer has at least this much space.
*/
private void ensureCapacity(int space) {
int newcount = space + count;
if (newcount > buf.length) {
byte[] newbuf = new byte[Math.max(buf.length << 1, newcount)];
System.arraycopy(buf, 0, newbuf, 0, count);
buf = newbuf;
}
}
public void write(byte[] b, int off, int len) {
ensureCapacity(len);
System.arraycopy(b, off, buf, count, len);
count += len;
}
public void write(byte[] b) {
write(b, 0, b.length);
}
/**
* Writes a string as ASCII string.
*/
public void writeAsAscii(String s) {
int len = s.length();
ensureCapacity(len);
int ptr = count;
for( int i=0; i<len; i++ )
buf[ptr++] = (byte)s.charAt(i);
count = ptr;
}
public void writeTo(OutputStream out) throws IOException {
out.write(buf, 0, count);
}
public void reset() {
count = 0;
}
/**
* Evil buffer reallocation method.
* Don't use it unless you absolutely have to.
*
* @deprecated
* because this is evil!
*/
public byte toByteArray()[] {
byte[] newbuf = new byte[count];
System.arraycopy(buf, 0, newbuf, 0, count);
return newbuf;
}
public int size() {
return count;
}
public ByteInputStream newInputStream() {
return new ByteInputStream(buf,count);
}
/**
* Converts the buffer's contents into a string, translating bytes into
* characters according to the platform's default character encoding.
*
* @return String translated from the buffer's contents.
* @since JDK1.1
*/
public String toString() {
return new String(buf, 0, count);
}
public void close() {
}
public byte[] getBytes() {
return buf;
}
public int getCount() {
return count;
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.io.CharArrayReader;
// This class just gives access to the underlying buffer without copying.
public class CharReader extends CharArrayReader {
public CharReader(char buf[], int length) {
super(buf, 0, length);
}
public CharReader(char buf[], int offset, int length) {
super(buf, offset, length);
}
public char[] getChars() {
return buf;
}
public int getCount() {
return count;
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.io.CharArrayWriter;
// This class just gives access to the underlying buffer without copying.
public class CharWriter extends CharArrayWriter {
public CharWriter () {
super();
}
public CharWriter(int size) {
super(size);
}
public char[] getChars() {
return buf;
}
public int getCount() {
return count;
}
}

View File

@@ -0,0 +1,240 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.lang.reflect.*;
import javax.xml.transform.Source;
import javax.xml.transform.Result;
import java.io.InputStream;
import java.io.OutputStream;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
/**
*
* @author Santiago.PericasGeertsen@sun.com
* @author Paul.Sandoz@sun.com
*/
public class FastInfosetReflection {
/**
* FI DOMDocumentParser constructor using reflection.
*/
static Constructor fiDOMDocumentParser_new;
/**
* FI <code>DOMDocumentParser.parse()</code> method via reflection.
*/
static Method fiDOMDocumentParser_parse;
/**
* FI DOMDocumentSerializer constructor using reflection.
*/
static Constructor fiDOMDocumentSerializer_new;
/**
* FI <code>FastInfosetSource.serialize(Document)</code> method via reflection.
*/
static Method fiDOMDocumentSerializer_serialize;
/**
* FI <code>FastInfosetSource.setOutputStream(OutputStream)</code> method via reflection.
*/
static Method fiDOMDocumentSerializer_setOutputStream;
/**
* FI FastInfosetSource constructor using reflection.
*/
static Class fiFastInfosetSource_class;
/**
* FI FastInfosetSource constructor using reflection.
*/
static Constructor fiFastInfosetSource_new;
/**
* FI <code>FastInfosetSource.getInputStream()</code> method via reflection.
*/
static Method fiFastInfosetSource_getInputStream;
/**
* FI <code>FastInfosetSource.setInputSTream()</code> method via reflection.
*/
static Method fiFastInfosetSource_setInputStream;
/**
* FI FastInfosetResult constructor using reflection.
*/
static Constructor fiFastInfosetResult_new;
/**
* FI <code>FastInfosetResult.getOutputSTream()</code> method via reflection.
*/
static Method fiFastInfosetResult_getOutputStream;
static {
try {
Class clazz = Class.forName("com.sun.xml.internal.fastinfoset.dom.DOMDocumentParser");
fiDOMDocumentParser_new = clazz.getConstructor((Class[]) null);
fiDOMDocumentParser_parse = clazz.getMethod("parse",
new Class[] { org.w3c.dom.Document.class, java.io.InputStream.class });
clazz = Class.forName("com.sun.xml.internal.fastinfoset.dom.DOMDocumentSerializer");
fiDOMDocumentSerializer_new = clazz.getConstructor((Class[])null);
fiDOMDocumentSerializer_serialize = clazz.getMethod("serialize",
new Class[] { org.w3c.dom.Node.class });
fiDOMDocumentSerializer_setOutputStream = clazz.getMethod("setOutputStream",
new Class[] { java.io.OutputStream.class });
fiFastInfosetSource_class = clazz = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetSource");
fiFastInfosetSource_new = clazz.getConstructor(
new Class[] { java.io.InputStream.class });
fiFastInfosetSource_getInputStream = clazz.getMethod("getInputStream", (Class[]) null);
fiFastInfosetSource_setInputStream = clazz.getMethod("setInputStream",
new Class[] { java.io.InputStream.class });
clazz = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetResult");
fiFastInfosetResult_new = clazz.getConstructor(
new Class[] { java.io.OutputStream.class });
fiFastInfosetResult_getOutputStream = clazz.getMethod("getOutputStream", (Class[]) null);
}
catch (Exception e) {
// falls through
}
}
// -- DOMDocumentParser ----------------------------------------------
public static Object DOMDocumentParser_new() throws Exception {
if (fiDOMDocumentParser_new == null) {
throw new RuntimeException("Unable to locate Fast Infoset implementation");
}
return fiDOMDocumentParser_new.newInstance((Object[])null);
}
public static void DOMDocumentParser_parse(Object parser,
Document d, InputStream s) throws Exception
{
if (fiDOMDocumentParser_parse == null) {
throw new RuntimeException("Unable to locate Fast Infoset implementation");
}
fiDOMDocumentParser_parse.invoke(parser, new Object[] { d, s });
}
// -- DOMDocumentSerializer-------------------------------------------
public static Object DOMDocumentSerializer_new() throws Exception {
if (fiDOMDocumentSerializer_new == null) {
throw new RuntimeException("Unable to locate Fast Infoset implementation");
}
return fiDOMDocumentSerializer_new.newInstance((Object[])null);
}
public static void DOMDocumentSerializer_serialize(Object serializer, Node node)
throws Exception
{
if (fiDOMDocumentSerializer_serialize == null) {
throw new RuntimeException("Unable to locate Fast Infoset implementation");
}
fiDOMDocumentSerializer_serialize.invoke(serializer, new Object[] { node });
}
public static void DOMDocumentSerializer_setOutputStream(Object serializer,
OutputStream os) throws Exception
{
if (fiDOMDocumentSerializer_setOutputStream == null) {
throw new RuntimeException("Unable to locate Fast Infoset implementation");
}
fiDOMDocumentSerializer_setOutputStream.invoke(serializer, new Object[] { os });
}
// -- FastInfosetSource ----------------------------------------------
public static boolean isFastInfosetSource(Source source) {
return source.getClass().getName().equals(
"com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetSource");
}
public static Class getFastInfosetSource_class() {
if (fiFastInfosetSource_class == null) {
throw new RuntimeException("Unable to locate Fast Infoset implementation");
}
return fiFastInfosetSource_class;
}
public static Source FastInfosetSource_new(InputStream is)
throws Exception
{
if (fiFastInfosetSource_new == null) {
throw new RuntimeException("Unable to locate Fast Infoset implementation");
}
return (Source) fiFastInfosetSource_new.newInstance(new Object[] { is });
}
public static InputStream FastInfosetSource_getInputStream(Source source)
throws Exception
{
if (fiFastInfosetSource_getInputStream == null) {
throw new RuntimeException("Unable to locate Fast Infoset implementation");
}
return (InputStream) fiFastInfosetSource_getInputStream.invoke(source, (Object[])null);
}
public static void FastInfosetSource_setInputStream(Source source,
InputStream is) throws Exception
{
if (fiFastInfosetSource_setInputStream == null) {
throw new RuntimeException("Unable to locate Fast Infoset implementation");
}
fiFastInfosetSource_setInputStream.invoke(source, new Object[] { is });
}
// -- FastInfosetResult ----------------------------------------------
public static boolean isFastInfosetResult(Result result) {
return result.getClass().getName().equals(
"com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetResult");
}
public static Result FastInfosetResult_new(OutputStream os)
throws Exception
{
if (fiFastInfosetResult_new == null) {
throw new RuntimeException("Unable to locate Fast Infoset implementation");
}
return (Result) fiFastInfosetResult_new.newInstance(new Object[] { os });
}
public static OutputStream FastInfosetResult_getOutputStream(Result result)
throws Exception
{
if (fiFastInfosetResult_getOutputStream == null) {
throw new RuntimeException("Unable to locate Fast Infoset implementation");
}
return (OutputStream) fiFastInfosetResult_getOutputStream.invoke(result, (Object[])null);
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.util.ArrayList;
import java.util.Collection;
/**
* {@link ArrayList} with a final marker to help JIT.
* @author Kohsuke Kawaguchi
*/
public final class FinalArrayList extends ArrayList {
public FinalArrayList(int initialCapacity) {
super(initialCapacity);
}
public FinalArrayList() {
}
public FinalArrayList(Collection collection) {
super(collection);
}
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.io.*;
import javax.xml.transform.stream.StreamSource;
/**
*
* @author Anil Vijendran
*/
public class JAXMStreamSource extends StreamSource {
InputStream in;
Reader reader;
private static final boolean lazyContentLength;
static {
lazyContentLength = SAAJUtil.getSystemBoolean("saaj.lazy.contentlength");
}
public JAXMStreamSource(InputStream is) throws IOException {
if (lazyContentLength) {
in = is;
} else if (is instanceof ByteInputStream) {
this.in = (ByteInputStream) is;
} else {
ByteOutputStream bout = new ByteOutputStream();
bout.write(is);
this.in = bout.newInputStream();
}
}
public JAXMStreamSource(Reader rdr) throws IOException {
if (lazyContentLength) {
this.reader = rdr;
return;
}
CharWriter cout = new CharWriter();
char[] temp = new char[1024];
int len;
while (-1 != (len = rdr.read(temp)))
cout.write(temp, 0, len);
this.reader = new CharReader(cout.getChars(), cout.getCount());
}
public InputStream getInputStream() {
return in;
}
public Reader getReader() {
return reader;
}
public void reset() throws IOException {
if (in != null)
in.reset();
if (reader != null)
reader.reset();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
/**
* @author Manveen Kaur (manveen.kaur@eng.sun.com)
*/
/**
* This interface defines a number of constants pertaining to Logging domains.
*/
public interface LogDomainConstants {
public static String MODULE_TOPLEVEL_DOMAIN =
"com.sun.xml.internal.messaging.saaj";
// First Level Domain
public static String CLIENT_DOMAIN =
MODULE_TOPLEVEL_DOMAIN + ".client";
public static String SOAP_DOMAIN =
MODULE_TOPLEVEL_DOMAIN + ".soap";
public static String UTIL_DOMAIN =
MODULE_TOPLEVEL_DOMAIN + ".util";
// Second Level Domain
public static String HTTP_CONN_DOMAIN =
CLIENT_DOMAIN + ".p2p";
public static String NAMING_DOMAIN =
SOAP_DOMAIN + ".name";
public static String SOAP_IMPL_DOMAIN =
SOAP_DOMAIN + ".impl";
public static String SOAP_VER1_1_DOMAIN =
SOAP_DOMAIN + ".ver1_1";
public static String SOAP_VER1_2_DOMAIN =
SOAP_DOMAIN + ".ver1_2";
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.util.Iterator;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
public class MimeHeadersUtil {
public static MimeHeaders copy(MimeHeaders headers) {
MimeHeaders newHeaders = new MimeHeaders();
Iterator eachHeader = headers.getAllHeaders();
while (eachHeader.hasNext()) {
MimeHeader currentHeader = (MimeHeader) eachHeader.next();
newHeaders.addHeader(
currentHeader.getName(),
currentHeader.getValue());
}
return newHeaders;
}
}

View File

@@ -0,0 +1,122 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.w3c.dom.*;
public class NamespaceContextIterator implements Iterator {
Node context;
NamedNodeMap attributes = null;
int attributesLength;
int attributeIndex;
Attr next = null;
Attr last = null;
boolean traverseStack = true;
public NamespaceContextIterator(Node context) {
this.context = context;
findContextAttributes();
}
public NamespaceContextIterator(Node context, boolean traverseStack) {
this(context);
this.traverseStack = traverseStack;
}
protected void findContextAttributes() {
while (context != null) {
int type = context.getNodeType();
if (type == Node.ELEMENT_NODE) {
attributes = context.getAttributes();
attributesLength = attributes.getLength();
attributeIndex = 0;
return;
} else {
context = null;
}
}
}
protected void findNext() {
while (next == null && context != null) {
for (; attributeIndex < attributesLength; ++attributeIndex) {
Node currentAttribute = attributes.item(attributeIndex);
String attributeName = currentAttribute.getNodeName();
if (attributeName.startsWith("xmlns")
&& (attributeName.length() == 5
|| attributeName.charAt(5) == ':')) {
next = (Attr) currentAttribute;
++attributeIndex;
return;
}
}
if (traverseStack) {
context = context.getParentNode();
findContextAttributes();
} else {
context = null;
}
}
}
public boolean hasNext() {
findNext();
return next != null;
}
public Object next() {
return getNext();
}
public Attr nextNamespaceAttr() {
return getNext();
}
protected Attr getNext() {
findNext();
if (next == null) {
throw new NoSuchElementException();
}
last = next;
next = null;
return last;
}
public void remove() {
if (last == null) {
throw new IllegalStateException();
}
((Element) context).removeAttributeNode(last);
}
}

View File

@@ -0,0 +1,93 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
// Cut&paste from sun.net.www.ParseUtil: decode, unescape
public class ParseUtil {
/**
* Un-escape and return the character at position i in string s.
*/
private static char unescape(String s, int i) {
return (char) Integer.parseInt(s.substring(i+1,i+3),16);
}
/**
* Returns a new String constructed from the specified String by replacing
* the URL escape sequences and UTF8 encoding with the characters they
* represent.
*/
public static String decode(String s) {
StringBuffer sb = new StringBuffer();
int i=0;
while (i<s.length()) {
char c = s.charAt(i);
char c2, c3;
if (c != '%') {
i++;
} else {
try {
c = unescape(s, i);
i += 3;
if ((c & 0x80) != 0) {
switch (c >> 4) {
case 0xC: case 0xD:
c2 = unescape(s, i);
i += 3;
c = (char)(((c & 0x1f) << 6) | (c2 & 0x3f));
break;
case 0xE:
c2 = unescape(s, i);
i += 3;
c3 = unescape(s, i);
i += 3;
c = (char)(((c & 0x0f) << 12) |
((c2 & 0x3f) << 6) |
(c3 & 0x3f));
break;
default:
throw new IllegalArgumentException();
}
}
} catch (NumberFormatException e) {
throw new IllegalArgumentException();
}
}
sb.append(c);
}
return sb.toString();
}
}

View File

@@ -0,0 +1,110 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
import org.xml.sax.SAXException;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
/**
* Pool of SAXParser objects
*/
public class ParserPool {
private final BlockingQueue queue;
private SAXParserFactory factory;
private int capacity;
public ParserPool(int capacity) {
this.capacity = capacity;
queue = new ArrayBlockingQueue(capacity);
//factory = SAXParserFactory.newInstance();
factory = new com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl();
factory.setNamespaceAware(true);
for (int i=0; i < capacity; i++) {
try {
queue.put(factory.newSAXParser());
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new RuntimeException(ex);
} catch (ParserConfigurationException ex) {
throw new RuntimeException(ex);
} catch (SAXException ex) {
throw new RuntimeException(ex);
}
}
}
public SAXParser get() throws ParserConfigurationException,
SAXException {
try {
return (SAXParser) queue.take();
} catch (InterruptedException ex) {
throw new SAXException(ex);
}
}
public void put(SAXParser parser) {
queue.offer(parser);
}
public void returnParser(SAXParser saxParser) {
saxParser.reset();
resetSaxParser(saxParser);
put(saxParser);
}
/**
* SAAJ Issue 46 :https://saaj.dev.java.net/issues/show_bug.cgi?id=46
* Xerces does not provide a way to reset the SymbolTable
* So we are trying to reset it using the proprietary code below.
* Temporary Until the bug : https://jaxp.dev.java.net/issues/show_bug.cgi?id=59
* is fixed.
* @param parser the parser from the pool whose Symbol Table needs to be reset.
*/
private void resetSaxParser(SAXParser parser) {
try {
//Object obj = parser.getProperty("http://apache.org/xml/properties/internal/symbol-table");
com.sun.org.apache.xerces.internal.util.SymbolTable table = new com.sun.org.apache.xerces.internal.util.SymbolTable();
parser.setProperty("http://apache.org/xml/properties/internal/symbol-table", table);
//obj = parser.getProperty("http://apache.org/xml/properties/internal/symbol-table");
} catch (SAXNotRecognizedException ex) {
//nothing to do
} catch (SAXNotSupportedException ex) {
//nothing to do
}
}
}

View File

@@ -0,0 +1,182 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.util.logging.Logger;
import javax.xml.parsers.SAXParser;
import javax.xml.soap.SOAPException;
import org.xml.sax.*;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.XMLFilterImpl;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import org.xml.sax.helpers.AttributesImpl;
/**
* Users of this class see a SAX2 XMLReader (via XMLFilterImpl). This
* class creates a parent XMLReader via JAXP and installs itself as a SAX2
* extension LexicalHandler which rejects document type declarations
* because they are not legal in SOAP. If the user of this class sets a
* LexicalHandler, then it forwards events to that handler.
*
*
* @author Edwin Goei
*/
public class RejectDoctypeSaxFilter extends XMLFilterImpl implements XMLReader, LexicalHandler{
protected static final Logger log =
Logger.getLogger(LogDomainConstants.UTIL_DOMAIN,
"com.sun.xml.internal.messaging.saaj.util.LocalStrings");
/** Standard SAX 2.0 ext property */
static final String LEXICAL_HANDLER_PROP =
"http://xml.org/sax/properties/lexical-handler";
static final String WSU_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd".intern();
static final String SIGNATURE_LNAME = "Signature".intern();
static final String ENCRYPTED_DATA_LNAME = "EncryptedData".intern();
static final String DSIG_NS = "http://www.w3.org/2000/09/xmldsig#".intern();
static final String XENC_NS = "http://www.w3.org/2001/04/xmlenc#".intern();
static final String ID_NAME = "ID".intern();
/** LexicalHandler to forward events to, if any */
private LexicalHandler lexicalHandler;
public RejectDoctypeSaxFilter(SAXParser saxParser) throws SOAPException {
XMLReader xmlReader;
try {
xmlReader = saxParser.getXMLReader();
} catch (Exception e) {
log.severe("SAAJ0602.util.getXMLReader.exception");
throw new SOAPExceptionImpl(
"Couldn't get an XMLReader while constructing a RejectDoctypeSaxFilter",
e);
}
// Set ourselves up to be the SAX LexicalHandler
try {
xmlReader.setProperty(LEXICAL_HANDLER_PROP, this);
} catch (Exception e) {
log.severe("SAAJ0603.util.setProperty.exception");
throw new SOAPExceptionImpl(
"Couldn't set the lexical handler property while constructing a RejectDoctypeSaxFilter",
e);
}
// Set the parent XMLReader of this SAX filter
setParent(xmlReader);
}
/*
* Override setProperty() to capture any LexicalHandler that is set for
* forwarding of events.
*/
public void setProperty(String name, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException {
if (LEXICAL_HANDLER_PROP.equals(name)) {
lexicalHandler = (LexicalHandler) value;
} else {
super.setProperty(name, value);
}
}
//
// Beginning of SAX LexicalHandler callbacks...
//
public void startDTD(String name, String publicId, String systemId)
throws SAXException {
throw new SAXException("Document Type Declaration is not allowed");
}
public void endDTD() throws SAXException {
}
public void startEntity(String name) throws SAXException {
if (lexicalHandler != null) {
lexicalHandler.startEntity(name);
}
}
public void endEntity(String name) throws SAXException {
if (lexicalHandler != null) {
lexicalHandler.endEntity(name);
}
}
public void startCDATA() throws SAXException {
if (lexicalHandler != null) {
lexicalHandler.startCDATA();
}
}
public void endCDATA() throws SAXException {
if (lexicalHandler != null) {
lexicalHandler.endCDATA();
}
}
public void comment(char[] ch, int start, int length) throws SAXException {
if (lexicalHandler != null) {
lexicalHandler.comment(ch, start, length);
}
}
//
// End of SAX LexicalHandler callbacks
//
public void startElement(String namespaceURI, String localName,
String qName, Attributes atts) throws SAXException{
if(atts != null ){
boolean eos = false;
if(namespaceURI == DSIG_NS || XENC_NS == namespaceURI){
eos = true;
}
int length = atts.getLength();
AttributesImpl attrImpl = new AttributesImpl();
for(int i=0; i< length;i++){
String name = atts.getLocalName(i);
if(name!=null && (name.equals("Id"))){
if(eos || atts.getURI(i) == WSU_NS ){
attrImpl.addAttribute(atts.getURI(i), atts.getLocalName(i),
atts.getQName(i), ID_NAME, atts.getValue(i));
}else{
attrImpl.addAttribute(atts.getURI(i), atts.getLocalName(i), atts.getQName(i), atts.getType(i), atts.getValue(i));
}
}else{
attrImpl.addAttribute(atts.getURI(i), atts.getLocalName(i),
atts.getQName(i), atts.getType(i), atts.getValue(i));
}
}
super.startElement(namespaceURI,localName, qName,attrImpl);
}else{
super.startElement(namespaceURI,localName, qName, null);
}
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.security.AccessControlException;
/**
*
* @author vbkumarjayanti
*/
public final class SAAJUtil {
public static boolean getSystemBoolean(String arg) {
try {
return Boolean.getBoolean(arg);
} catch (AccessControlException ex) {
return false;
}
}
public static String getSystemProperty(String arg) {
try {
return System.getProperty(arg);
} catch (SecurityException ex) {
return null;
}
}
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Created on Feb 28, 2003
*
* To change this generated comment go to
* Window>Preferences>Java>Code Generation>Code Template
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.io.*;
/**
* @author pgoodwin
*/
public class TeeInputStream extends InputStream {
protected InputStream source;
protected OutputStream copySink;
public TeeInputStream(InputStream source, OutputStream sink) {
super();
this.copySink = sink;
this.source = source;
}
public int read() throws IOException {
int result = source.read();
copySink.write(result);
return result;
}
public int available() throws IOException {
return source.available();
}
public void close() throws IOException {
source.close();
}
public synchronized void mark(int readlimit) {
source.mark(readlimit);
}
public boolean markSupported() {
return source.markSupported();
}
public int read(byte[] b, int off, int len) throws IOException {
int result = source.read(b, off, len);
copySink.write(b, off, len);
return result;
}
public int read(byte[] b) throws IOException {
int result = source.read(b);
copySink.write(b);
return result;
}
public synchronized void reset() throws IOException {
source.reset();
}
public long skip(long n) throws IOException {
return source.skip(n);
}
}

View File

@@ -0,0 +1,179 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.util;
import java.io.*;
import javax.xml.transform.TransformerException;
/*
* Class that parses the very first construct in the document i.e.
* <?xml ... ?>
*
* @author Panos Kougiouris (panos@acm.org)
* @version
*/
public class XMLDeclarationParser {
private String m_encoding;
private PushbackReader m_pushbackReader;
private boolean m_hasHeader; // preserve the case where no XML Header exists
private String xmlDecl = null;
static String gt16 = null;
static String utf16Decl = null;
static {
try {
gt16 = new String(">".getBytes("utf-16"));
utf16Decl = new String("<?xml".getBytes("utf-16"));
} catch (Exception e) {}
}
//---------------------------------------------------------------------
public XMLDeclarationParser(PushbackReader pr)
{
m_pushbackReader = pr;
m_encoding = "utf-8";
m_hasHeader = false;
}
//---------------------------------------------------------------------
public String getEncoding()
{
return m_encoding;
}
public String getXmlDeclaration() {
return xmlDecl;
}
//---------------------------------------------------------------------
public void parse() throws TransformerException, IOException
{
int c = 0;
int index = 0;
char[] aChar = new char[65535];
StringBuffer xmlDeclStr = new StringBuffer();
while ((c = m_pushbackReader.read()) != -1) {
aChar[index] = (char)c;
xmlDeclStr.append((char)c);
index++;
if (c == '>') {
break;
}
}
int len = index;
String decl = xmlDeclStr.toString();
boolean utf16 = false;
boolean utf8 = false;
int xmlIndex = decl.indexOf(utf16Decl);
if (xmlIndex > -1) {
utf16 = true;
} else {
xmlIndex = decl.indexOf("<?xml");
if (xmlIndex > -1) {
utf8 = true;
}
}
// no XML decl
if (!utf16 && !utf8) {
m_pushbackReader.unread(aChar, 0, len);
return;
}
m_hasHeader = true;
if (utf16) {
xmlDecl = new String(decl.getBytes(), "utf-16");
xmlDecl = xmlDecl.substring(xmlDecl.indexOf("<"));
} else {
xmlDecl = decl;
}
// do we want to check that there are no other characters preceeding <?xml
if (xmlIndex != 0) {
throw new IOException("Unexpected characters before XML declaration");
}
int versionIndex = xmlDecl.indexOf("version");
if (versionIndex == -1) {
throw new IOException("Mandatory 'version' attribute Missing in XML declaration");
}
// now set
int encodingIndex = xmlDecl.indexOf("encoding");
if (encodingIndex == -1) {
return;
}
if (versionIndex > encodingIndex) {
throw new IOException("The 'version' attribute should preceed the 'encoding' attribute in an XML Declaration");
}
int stdAloneIndex = xmlDecl.indexOf("standalone");
if ((stdAloneIndex > -1) && ((stdAloneIndex < versionIndex) || (stdAloneIndex < encodingIndex))) {
throw new IOException("The 'standalone' attribute should be the last attribute in an XML Declaration");
}
int eqIndex = xmlDecl.indexOf("=", encodingIndex);
if (eqIndex == -1) {
throw new IOException("Missing '=' character after 'encoding' in XML declaration");
}
m_encoding = parseEncoding(xmlDecl, eqIndex);
if(m_encoding.startsWith("\"")){
m_encoding = m_encoding.substring(m_encoding.indexOf("\"")+1, m_encoding.lastIndexOf("\""));
} else if(m_encoding.startsWith("\'")){
m_encoding = m_encoding.substring(m_encoding.indexOf("\'")+1, m_encoding.lastIndexOf("\'"));
}
}
//--------------------------------------------------------------------
public void writeTo(Writer wr) throws IOException {
if (!m_hasHeader) return;
wr.write(xmlDecl.toString());
}
private String parseEncoding(String xmlDeclFinal, int eqIndex) throws IOException {
java.util.StringTokenizer strTok = new java.util.StringTokenizer(
xmlDeclFinal.substring(eqIndex + 1));
if (strTok.hasMoreTokens()) {
String encodingTok = strTok.nextToken();
int indexofQ = encodingTok.indexOf("?");
if (indexofQ > -1) {
return encodingTok.substring(0,indexofQ);
} else {
return encodingTok;
}
} else {
throw new IOException("Error parsing 'encoding' attribute in XML declaration");
}
}
}

View File

@@ -0,0 +1,423 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* EfficientStreamingTransformer.java
*
* Created on July 29, 2002, 3:49 PM
*/
package com.sun.xml.internal.messaging.saaj.util.transform;
import java.io.*;
import java.net.URISyntaxException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Document;
import com.sun.xml.internal.messaging.saaj.util.XMLDeclarationParser;
import com.sun.xml.internal.messaging.saaj.util.FastInfosetReflection;
import java.net.URI;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
/**
* This class is a proxy for a Transformer object with optimizations
* for certain cases. If source and result are of type stream, then
* bytes are simply copied whenever possible (note that this assumes
* that the input is well formed). In addition, it provides support for
* FI using native DOM parsers and serializers.
*
* @author Panos Kougiouris panos@acm.org
* @author Santiago.PericasGeertsen@sun.com
*
*/
public class EfficientStreamingTransformer
extends javax.xml.transform.Transformer {
//static final String version;
//static final String vendor;
// removing static : security issue : CR 6813167Z
private final TransformerFactory transformerFactory = TransformerFactory.newInstance();
/**
removing support for Java 1.4 and 1.3 : CR6658158
static {
version = System.getProperty("java.vm.version");
vendor = System.getProperty("java.vm.vendor");
if (vendor.startsWith("Sun") &&
(version.startsWith("1.4") || version.startsWith("1.3"))) {
transformerFactory =
new com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl();
}
}*/
/**
* TransformerFactory instance.
*/
/**
* Underlying XSLT transformer.
*/
private Transformer m_realTransformer = null;
/**
* Undelying FI DOM parser.
*/
private Object m_fiDOMDocumentParser = null;
/**
* Underlying FI DOM serializer.
*/
private Object m_fiDOMDocumentSerializer = null;
private EfficientStreamingTransformer() {
}
private void materialize() throws TransformerException {
if (m_realTransformer == null) {
m_realTransformer = transformerFactory.newTransformer();
}
}
public void clearParameters() {
if (m_realTransformer != null)
m_realTransformer.clearParameters();
}
public javax.xml.transform.ErrorListener getErrorListener() {
try {
materialize();
return m_realTransformer.getErrorListener();
} catch (TransformerException e) {
// will be caught later
}
return null;
}
public java.util.Properties getOutputProperties() {
try {
materialize();
return m_realTransformer.getOutputProperties();
} catch (TransformerException e) {
// will be caught later
}
return null;
}
public String getOutputProperty(String str)
throws java.lang.IllegalArgumentException {
try {
materialize();
return m_realTransformer.getOutputProperty(str);
} catch (TransformerException e) {
// will be caught later
}
return null;
}
public Object getParameter(String str) {
try {
materialize();
return m_realTransformer.getParameter(str);
} catch (TransformerException e) {
// will be caught later
}
return null;
}
public javax.xml.transform.URIResolver getURIResolver() {
try {
materialize();
return m_realTransformer.getURIResolver();
} catch (TransformerException e) {
// will be caught later
}
return null;
}
public void setErrorListener(
javax.xml.transform.ErrorListener errorListener)
throws java.lang.IllegalArgumentException {
try {
materialize();
m_realTransformer.setErrorListener(errorListener);
} catch (TransformerException e) {
// will be caught later
}
}
public void setOutputProperties(java.util.Properties properties)
throws java.lang.IllegalArgumentException {
try {
materialize();
m_realTransformer.setOutputProperties(properties);
} catch (TransformerException e) {
// will be caught later
}
}
public void setOutputProperty(String str, String str1)
throws java.lang.IllegalArgumentException {
try {
materialize();
m_realTransformer.setOutputProperty(str, str1);
} catch (TransformerException e) {
// will be caught later
}
}
public void setParameter(String str, Object obj) {
try {
materialize();
m_realTransformer.setParameter(str, obj);
} catch (TransformerException e) {
// will be caught later
}
}
public void setURIResolver(javax.xml.transform.URIResolver uRIResolver) {
try {
materialize();
m_realTransformer.setURIResolver(uRIResolver);
} catch (TransformerException e) {
// will be caught later
}
}
private InputStream getInputStreamFromSource(StreamSource s)
throws TransformerException {
InputStream stream = s.getInputStream();
if (stream != null)
return stream;
if (s.getReader() != null)
return null;
String systemId = s.getSystemId();
if (systemId != null) {
try {
String fileURL = systemId;
if (systemId.startsWith("file:///"))
{
/*
systemId is:
file:///<drive>:/some/path/file.xml
or
file:///some/path/file.xml
*/
String absolutePath = systemId.substring(7);
/*
/<drive>:/some/path/file.xml
or
/some/path/file.xml
*/
boolean hasDriveDesignator = absolutePath.indexOf(":") > 0;
if (hasDriveDesignator) {
String driveDesignatedPath = absolutePath.substring(1);
/*
<drive>:/some/path/file.xml */
fileURL = driveDesignatedPath;
}
else {
/*
/some/path/file.xml */
fileURL = absolutePath;
}
}
//return new FileInputStream(fileURL);
try {
return new FileInputStream(new File(new URI(fileURL)));
} catch (URISyntaxException ex) {
throw new TransformerException(ex);
}
} catch (IOException e) {
throw new TransformerException(e.toString());
}
}
throw new TransformerException("Unexpected StreamSource object");
}
//------------------------------------------------------------------------
public void transform(
javax.xml.transform.Source source,
javax.xml.transform.Result result)
throws javax.xml.transform.TransformerException
{
// StreamSource -> StreamResult
if ((source instanceof StreamSource)
&& (result instanceof StreamResult)) {
try {
StreamSource streamSource = (StreamSource) source;
InputStream is = getInputStreamFromSource(streamSource);
OutputStream os = ((StreamResult) result).getOutputStream();
if (os == null)
// TODO: We might want to fix this if it were to be used beyond
// XmlDataContentHandler that we know uses only OutputStream
throw new TransformerException("Unexpected StreamResult object contains null OutputStream");
if (is != null) {
if (is.markSupported())
is.mark(Integer.MAX_VALUE);
int num;
byte[] b = new byte[8192];
while ((num = is.read(b)) != -1) {
os.write(b, 0, num);
}
if (is.markSupported())
is.reset();
return;
}
Reader reader = streamSource.getReader();
if (reader != null) {
if (reader.markSupported())
reader.mark(Integer.MAX_VALUE);
PushbackReader pushbackReader = new PushbackReader(reader, 4096);
//some size to unread <?xml ....?>
XMLDeclarationParser ev =
new XMLDeclarationParser(pushbackReader);
try {
ev.parse();
} catch (Exception ex) {
throw new TransformerException(
"Unable to run the JAXP transformer on a stream "
+ ex.getMessage());
}
Writer writer =
new OutputStreamWriter(os /*, ev.getEncoding()*/);
ev.writeTo(writer); // doesn't write any, if no header
int num;
char[] ac = new char[8192];
while ((num = pushbackReader.read(ac)) != -1) {
writer.write(ac, 0, num);
}
writer.flush();
if (reader.markSupported())
reader.reset();
return;
}
} catch (IOException e) {
e.printStackTrace();
throw new TransformerException(e.toString());
}
throw new TransformerException("Unexpected StreamSource object");
}
// FastInfosetSource -> DOMResult
else if (FastInfosetReflection.isFastInfosetSource(source)
&& (result instanceof DOMResult))
{
try {
// Use reflection to avoid a static dep with FI
if (m_fiDOMDocumentParser == null) {
m_fiDOMDocumentParser = FastInfosetReflection.DOMDocumentParser_new();
}
// m_fiDOMDocumentParser.parse(document, source.getInputStream())
FastInfosetReflection.DOMDocumentParser_parse(
m_fiDOMDocumentParser,
(Document) ((DOMResult) result).getNode(),
FastInfosetReflection.FastInfosetSource_getInputStream(source));
// We're done!
return;
}
catch (Exception e) {
throw new TransformerException(e);
}
}
// DOMSource -> FastInfosetResult
else if ((source instanceof DOMSource)
&& FastInfosetReflection.isFastInfosetResult(result))
{
try {
// Use reflection to avoid a static dep with FI
if (m_fiDOMDocumentSerializer == null) {
m_fiDOMDocumentSerializer = FastInfosetReflection.DOMDocumentSerializer_new();
}
// m_fiDOMDocumentSerializer.setOutputStream(result.getOutputStream())
FastInfosetReflection.DOMDocumentSerializer_setOutputStream(
m_fiDOMDocumentSerializer,
FastInfosetReflection.FastInfosetResult_getOutputStream(result));
// m_fiDOMDocumentSerializer.serialize(node)
FastInfosetReflection.DOMDocumentSerializer_serialize(
m_fiDOMDocumentSerializer,
((DOMSource) source).getNode());
// We're done!
return;
}
catch (Exception e) {
throw new TransformerException(e);
}
}
// All other cases -- use transformer object
materialize();
m_realTransformer.transform(source, result);
}
/**
* Threadlocal to hold a Transformer instance for this thread.
* CR : 6813167
*/
//private static ThreadLocal effTransformer = new ThreadLocal();
/**
* Return Transformer instance for this thread, allocating a new one if
* necessary. Note that this method does not clear global parameters,
* properties or any other data set on a previously used transformer.
*/
public static Transformer newTransformer() {
//CR : 6813167
/*Transformer tt = (Transformer) effTransformer.get();
if (tt == null) {
effTransformer.set(tt = new EfficientStreamingTransformer());
}
return tt;*/
return new EfficientStreamingTransformer();
}
}