use of lucee.runtime.coder.CoderException in project Lucee by lucee.
the class Base64Encoder method decodeGroup.
/**
* Decode four chars from data into 0-3 bytes of data starting at position in array.
* @return the number of bytes decoded.
*/
private static int decodeGroup(char[] data, byte[] array, int position) throws CoderException {
int b1, b2, b3, b4;
try {
b1 = REVERSE.get(data[0]);
b2 = REVERSE.get(data[1]);
b3 = REVERSE.get(data[2]);
b4 = REVERSE.get(data[3]);
} catch (NullPointerException e) {
// If auto-boxing fails
throw new CoderException("Illegal characters in the sequence to be " + "decoded: " + Arrays.toString(data));
}
array[position] = (byte) ((b1 << 2) | (b2 >> 4));
array[position + 1] = (byte) ((b2 << 4) | (b3 >> 2));
array[position + 2] = (byte) ((b3 << 6) | (b4));
// Check the amount of data decoded
if (data[0] == PAD)
return 0;
if (data[1] == PAD) {
throw new CoderException("Illegal character padding in sequence to be " + "decoded: " + Arrays.toString(data));
}
if (data[2] == PAD)
return 1;
if (data[3] == PAD)
return 2;
return 3;
}
Aggregations