Java Code Examples for com.alibaba.com.caucho.hessian.io.Hessian2Input#close()

The following examples show how to use com.alibaba.com.caucho.hessian.io.Hessian2Input#close() . 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: X509Encryption.java    From dubbo-hessian-lite with Apache License 2.0 6 votes vote down vote up
@Override
public void close()
        throws IOException {
    Hessian2Input in = _in;
    _in = null;

    if (in != null) {
        _cipherIn.close();
        _bodyIn.close();

        int len = in.readInt();

        if (len != 0)
            throw new IOException("Unexpected footer");

        in.completeEnvelope();

        in.close();
    }
}
 
Example 2
Source File: X509Encryption.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
public void close()
        throws IOException {
    Hessian2Input in = _in;
    _in = null;

    if (in != null) {
        _cipherIn.close();
        _bodyIn.close();

        int len = in.readInt();

        if (len != 0)
            throw new IOException("Unexpected footer");

        in.completeEnvelope();

        in.close();
    }
}
 
Example 3
Source File: X509Signature.java    From dubbo-hessian-lite with Apache License 2.0 5 votes vote down vote up
@Override
public void close()
        throws IOException {
    Hessian2Input in = _in;
    _in = null;

    if (in != null) {
        _bodyIn.close();

        int len = in.readInt();
        byte[] signature = null;

        for (int i = 0; i < len; i++) {
            String header = in.readString();

            if ("signature".equals(header))
                signature = in.readBytes();
        }

        in.completeEnvelope();
        in.close();


        if (signature == null)
            throw new IOException("Expected signature");

        byte[] sig = _mac.doFinal();

        if (sig.length != signature.length)
            throw new IOException("mismatched signature");

        for (int i = 0; i < sig.length; i++) {
            if (signature[i] != sig[i])
                throw new IOException("mismatched signature");
        }

        // XXX: save principal
    }
}
 
Example 4
Source File: HessianUtil.java    From j360-dubbo-app-all with Apache License 2.0 5 votes vote down vote up
private static void closeQuietly(Hessian2Input hessian2Input) {
    try {
        if (hessian2Input != null) {
            hessian2Input.close();
        }
    } catch (IOException e) {
        logger.warn("close hessian2Input failed");
    }
}
 
Example 5
Source File: X509Signature.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void close()
        throws IOException {
    Hessian2Input in = _in;
    _in = null;

    if (in != null) {
        _bodyIn.close();

        int len = in.readInt();
        byte[] signature = null;

        for (int i = 0; i < len; i++) {
            String header = in.readString();

            if ("signature".equals(header))
                signature = in.readBytes();
        }

        in.completeEnvelope();
        in.close();


        if (signature == null)
            throw new IOException("Expected signature");

        byte[] sig = _mac.doFinal();

        if (sig.length != signature.length)
            throw new IOException("mismatched signature");

        for (int i = 0; i < sig.length; i++) {
            if (signature[i] != sig[i])
                throw new IOException("mismatched signature");
        }

        // XXX: save principal
    }
}