⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 signatureoutputstream.java

📁 一个java开发的非常全面的关于证书发放
💻 JAVA
字号:
package net.sourceforge.jcetaglib.tools;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.security.Signature;
import java.security.SignatureException;


/**
 * Signature output stream is a stream wrapper that
 * passes data though a Signature object before passing it on.
 */


public class SignatureOutputStream
        extends FilterOutputStream {
    private Signature sig = null;

    public SignatureOutputStream(OutputStream out,
                                 Signature sig) {
        super(out);
        this.sig = sig;
    }

    public void write(int b)
            throws IOException {
        try {
            sig.update((byte) b);
        } catch (SignatureException s_ex) {
            throw new IOException(s_ex.getMessage());
        }
        out.write(b);
    }

    public void write(byte[] b)
            throws IOException {
        try {
            sig.update(b);
        } catch (SignatureException s_ex) {
            throw new IOException(s_ex.getMessage());
        }

        out.write(b);
    }

    public void write(byte[] b,
                      int o,
                      int l)
            throws IOException {
        try {
            sig.update(b, o, l);
        } catch (SignatureException s_ex) {
            throw(new IOException(s_ex.getMessage()));
        }

        out.write(b, o, l);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -