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

📄 xyzkeyfactory.java

📁 xyqkeygeneradtor的生成与实现算法 身份认证的实现以及研究
💻 JAVA
字号:
package javasec.samples.ch09;import java.security.*;import java.security.spec.*;public class XYZKeyFactory extends KeyFactorySpi {    protected PublicKey engineGeneratePublic(KeySpec ks)                                   throws InvalidKeySpecException {        // Convert from the key spec to the key. In our case, the        // spec holds the rot value, so we can just construct the        // key        if (!(ks instanceof XYZKeySpec))            throw new InvalidKeySpecException("Expecting XYZKeySpec");        XYZKey k = new XYZKey();        k.rotValue = ((XYZKeySpec) ks).rotValue;        return k;    }    protected PrivateKey engineGeneratePrivate(KeySpec ks)                                   throws InvalidKeySpecException {        if (!(ks instanceof XYZKeySpec))            throw new InvalidKeySpecException("Expecting XYZKeySpec");        XYZKey k = new XYZKey();        k.rotValue = ((XYZKeySpec) ks).rotValue;        return k;    }    protected KeySpec engineGetKeySpec(Key key, Class specClass)                                   throws InvalidKeySpecException {        if (specClass != XYZKeySpec.class)            throw new InvalidKeySpecException("Expecting XYZKeySpec");        if (!(key instanceof XYZKey))            throw new IllegalArgumentException("Expecting XYZ Key");        return new XYZKeySpec((XYZKey) key);    }    protected Key engineTranslateKey(Key key) throws InvalidKeyException {        // Translate key formats by getting the encoded key and creating        // the type of key we know about.        XYZKey k = new XYZKey();        if (k.getFormat() != key.getFormat())            throw new InvalidKeyException("Expecting XYZ Special Format Key");        byte[] b = key.getEncoded();        k.rotValue = (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0];        return k;    }}

⌨️ 快捷键说明

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