Search in sources :

Example 1 with HexOutputStream

use of org.eclipse.scout.rt.platform.util.HexUtility.HexOutputStream in project scout.rt by eclipse.

the class DefaultAuthToken method createUnsignedData.

protected byte[] createUnsignedData() {
    try (ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        HexOutputStream hex = new HexOutputStream(bytes)) {
        hex.write(m_userId.getBytes(StandardCharsets.UTF_8));
        bytes.write(partsDelimiter());
        bytes.write(Long.toHexString(m_validUntil).getBytes());
        if (m_customArgs != null) {
            for (String arg : m_customArgs) {
                bytes.write(partsDelimiter());
                hex.write(arg.getBytes(StandardCharsets.UTF_8));
            }
        }
        return bytes.toByteArray();
    } catch (IOException ex) {
        throw new PlatformException("unexpected behaviour", ex);
    }
}
Also used : PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) HexOutputStream(org.eclipse.scout.rt.platform.util.HexUtility.HexOutputStream) IOException(java.io.IOException)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 PlatformException (org.eclipse.scout.rt.platform.exception.PlatformException)1 HexOutputStream (org.eclipse.scout.rt.platform.util.HexUtility.HexOutputStream)1