Package com.sun.xml.wss.impl.misc
Class Base64
- java.lang.Object
-
- com.sun.xml.wss.impl.misc.Base64
-
public class Base64 extends Object
Implementation of MIME's Base64 encoding and decoding conversions. Optimized code. (raw version taken from oreilly.jonathan.util, and currently com.sun.org.apache.xerces.internal.ds.util.Base64)- Author:
- Raul Benito(Of the xerces copy, and little adaptations)., Anli Shundi, Christian Geuer-Pollmann
- See Also:
- RFC 2045,
TransformBase64Decode
-
-
Field Summary
Fields Modifier and Type Field Description static int
BASE64DEFAULTLENGTH
Field BASE64DEFAULTLENGTH
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static byte[]
decode(byte[] base64Data)
static void
decode(byte[] base64Data, OutputStream os)
Decodes Base64 data into outputstreamstatic void
decode(InputStream is, OutputStream os)
Decodes Base64 data into outputstreamstatic byte[]
decode(String encoded)
Decodes Base64 data into octectsprotected static byte[]
decodeInternal(byte[] base64Data)
static String
encode(byte[] binaryData)
static String
encode(byte[] binaryData, int length)
char[]
encodeData(byte[] binaryData)
Encodes hex octects into Base64static char[]
encodeData(byte[] binaryData, int length)
Encode a byte array in Base64 format and return an optionally wrapped line.static void
encodeToStream(byte[] binaryData, int offset, int length, OutputStream stream)
static void
encodeToStream(byte[] binaryData, int length, OutputStream stream)
static void
encodeToStream(ByteArray binaryData, int length, OutputStream stream)
protected static boolean
isPad(byte octect)
protected static boolean
isWhiteSpace(byte octect)
protected static int
removeWhiteSpace(byte[] data)
remove WhiteSpace from MIME containing encoded Base64 data.
-
-
-
Field Detail
-
BASE64DEFAULTLENGTH
public static final int BASE64DEFAULTLENGTH
Field BASE64DEFAULTLENGTH- See Also:
- Constant Field Values
-
-
Method Detail
-
isWhiteSpace
protected static final boolean isWhiteSpace(byte octect)
-
isPad
protected static final boolean isPad(byte octect)
-
encodeData
public char[] encodeData(byte[] binaryData)
Encodes hex octects into Base64- Parameters:
binaryData
- Array containing binaryData- Returns:
- Encoded Base64 array
-
encodeData
public static char[] encodeData(byte[] binaryData, int length)
Encode a byte array in Base64 format and return an optionally wrapped line.- Parameters:
binaryData
-byte[]
data to be encodedlength
-int
length of wrapped lines; No wrapping if less than 4.
- Returns:
- a
String
with encoded data
-
encode
public static String encode(byte[] binaryData, int length)
-
encode
public static String encode(byte[] binaryData)
-
encodeToStream
public static void encodeToStream(byte[] binaryData, int length, OutputStream stream) throws IOException
- Throws:
IOException
-
encodeToStream
public static void encodeToStream(byte[] binaryData, int offset, int length, OutputStream stream) throws IOException
- Throws:
IOException
-
encodeToStream
public static void encodeToStream(ByteArray binaryData, int length, OutputStream stream) throws IOException
- Throws:
IOException
-
decode
public static final byte[] decode(String encoded) throws org.apache.xml.security.exceptions.Base64DecodingException
Decodes Base64 data into octects- Parameters:
encoded
- Byte array containing Base64 data- Returns:
- Array containind decoded data.
- Throws:
org.apache.xml.security.exceptions.Base64DecodingException
-
decode
public static final byte[] decode(byte[] base64Data) throws org.apache.xml.security.exceptions.Base64DecodingException
- Throws:
org.apache.xml.security.exceptions.Base64DecodingException
-
decodeInternal
protected static final byte[] decodeInternal(byte[] base64Data) throws org.apache.xml.security.exceptions.Base64DecodingException
- Throws:
org.apache.xml.security.exceptions.Base64DecodingException
-
decode
public static final void decode(byte[] base64Data, OutputStream os) throws org.apache.xml.security.exceptions.Base64DecodingException, IOException
Decodes Base64 data into outputstream- Parameters:
base64Data
- Byte array containing Base64 dataos
- the outputstream- Throws:
IOException
org.apache.xml.security.exceptions.Base64DecodingException
-
decode
public static final void decode(InputStream is, OutputStream os) throws org.apache.xml.security.exceptions.Base64DecodingException, IOException
Decodes Base64 data into outputstream- Parameters:
is
- containing Base64 dataos
- the outputstream- Throws:
IOException
org.apache.xml.security.exceptions.Base64DecodingException
-
removeWhiteSpace
protected static int removeWhiteSpace(byte[] data)
remove WhiteSpace from MIME containing encoded Base64 data.- Parameters:
data
- the byte array of base64 data (with WS)- Returns:
- the new length
-
-