org.tukaani.xz.UnsupportedOptionsException Java Examples

The following examples show how to use org.tukaani.xz.UnsupportedOptionsException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Check.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public static Check getInstance(int checkType)
        throws UnsupportedOptionsException {
    switch (checkType) {
        case XZ.CHECK_NONE:
            return new None();

        case XZ.CHECK_CRC32:
            return new CRC32();

        case XZ.CHECK_CRC64:
            return new CRC64();

        case XZ.CHECK_SHA256:
            try {
                return new SHA256();
            } catch (java.security.NoSuchAlgorithmException e) {}

            break;
    }

    throw new UnsupportedOptionsException(
            "Unsupported Check ID " + checkType);
}
 
Example #2
Source File: DecoderUtil.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public static StreamFlags decodeStreamHeader(byte[] buf)
        throws IOException {
    for (int i = 0; i < XZ.HEADER_MAGIC.length; ++i)
        if (buf[i] != XZ.HEADER_MAGIC[i])
            throw new XZFormatException();

    if (!isCRC32Valid(buf, XZ.HEADER_MAGIC.length, 2,
                      XZ.HEADER_MAGIC.length + 2))
        throw new CorruptedInputException("XZ Stream Header is corrupt");

    try {
        return decodeStreamFlags(buf, XZ.HEADER_MAGIC.length);
    } catch (UnsupportedOptionsException e) {
        throw new UnsupportedOptionsException(
                "Unsupported options in XZ Stream Header");
    }
}
 
Example #3
Source File: Check.java    From LocalGSMLocationProvider with Apache License 2.0 6 votes vote down vote up
public static Check getInstance(int checkType)
        throws UnsupportedOptionsException {
    switch (checkType) {
        case XZ.CHECK_NONE:
            return new None();

        case XZ.CHECK_CRC32:
            return new CRC32();

        case XZ.CHECK_CRC64:
            return new CRC64();

        case XZ.CHECK_SHA256:
            try {
                return new SHA256();
            } catch (java.security.NoSuchAlgorithmException e) {}

            break;
    }

    throw new UnsupportedOptionsException(
            "Unsupported Check ID " + checkType);
}
 
Example #4
Source File: DecoderUtil.java    From LocalGSMLocationProvider with Apache License 2.0 6 votes vote down vote up
public static StreamFlags decodeStreamHeader(byte[] buf)
        throws IOException {
    for (int i = 0; i < XZ.HEADER_MAGIC.length; ++i)
        if (buf[i] != XZ.HEADER_MAGIC[i])
            throw new XZFormatException();

    if (!isCRC32Valid(buf, XZ.HEADER_MAGIC.length, 2,
                      XZ.HEADER_MAGIC.length + 2))
        throw new CorruptedInputException("XZ Stream Header is corrupt");

    try {
        return decodeStreamFlags(buf, XZ.HEADER_MAGIC.length);
    } catch (UnsupportedOptionsException e) {
        throw new UnsupportedOptionsException(
                "Unsupported options in XZ Stream Header");
    }
}
 
Example #5
Source File: DecoderUtil.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public static StreamFlags decodeStreamFooter(byte[] buf)
        throws IOException {
    if (buf[10] != XZ.FOOTER_MAGIC[0] || buf[11] != XZ.FOOTER_MAGIC[1]) {
        // NOTE: The exception could be XZFormatException too.
        // It depends on the situation which one is better.
        throw new CorruptedInputException("XZ Stream Footer is corrupt");
    }

    if (!isCRC32Valid(buf, 4, 6, 0))
        throw new CorruptedInputException("XZ Stream Footer is corrupt");

    StreamFlags streamFlags;
    try {
        streamFlags = decodeStreamFlags(buf, 8);
    } catch (UnsupportedOptionsException e) {
        throw new UnsupportedOptionsException(
                "Unsupported options in XZ Stream Footer");
    }

    streamFlags.backwardSize = 0;
    for (int i = 0; i < 4; ++i)
        streamFlags.backwardSize |= (buf[i + 4] & 0xFF) << (i * 8);

    streamFlags.backwardSize = (streamFlags.backwardSize + 1) * 4;

    return streamFlags;
}
 
Example #6
Source File: DecoderUtil.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private static StreamFlags decodeStreamFlags(byte[] buf, int off)
        throws UnsupportedOptionsException {
    if (buf[off] != 0x00 || (buf[off + 1] & 0xFF) >= 0x10)
        throw new UnsupportedOptionsException();

    StreamFlags streamFlags = new StreamFlags();
    streamFlags.checkType = buf[off + 1];

    return streamFlags;
}
 
Example #7
Source File: DecoderUtil.java    From LocalGSMLocationProvider with Apache License 2.0 5 votes vote down vote up
public static StreamFlags decodeStreamFooter(byte[] buf)
        throws IOException {
    if (buf[10] != XZ.FOOTER_MAGIC[0] || buf[11] != XZ.FOOTER_MAGIC[1]) {
        // NOTE: The exception could be XZFormatException too.
        // It depends on the situation which one is better.
        throw new CorruptedInputException("XZ Stream Footer is corrupt");
    }

    if (!isCRC32Valid(buf, 4, 6, 0))
        throw new CorruptedInputException("XZ Stream Footer is corrupt");

    StreamFlags streamFlags;
    try {
        streamFlags = decodeStreamFlags(buf, 8);
    } catch (UnsupportedOptionsException e) {
        throw new UnsupportedOptionsException(
                "Unsupported options in XZ Stream Footer");
    }

    streamFlags.backwardSize = 0;
    for (int i = 0; i < 4; ++i)
        streamFlags.backwardSize |= (buf[i + 4] & 0xFF) << (i * 8);

    streamFlags.backwardSize = (streamFlags.backwardSize + 1) * 4;

    return streamFlags;
}
 
Example #8
Source File: DecoderUtil.java    From LocalGSMLocationProvider with Apache License 2.0 5 votes vote down vote up
private static StreamFlags decodeStreamFlags(byte[] buf, int off)
        throws UnsupportedOptionsException {
    if (buf[off] != 0x00 || (buf[off + 1] & 0xFF) >= 0x10)
        throw new UnsupportedOptionsException();

    StreamFlags streamFlags = new StreamFlags();
    streamFlags.checkType = buf[off + 1];

    return streamFlags;
}