FileDocCategorySizeDatePackage
XYZKeyFactory.javaAPI DocExample1862Sat Jan 13 13:28:50 GMT 2001javasec.samples.ch09

XYZKeyFactory

public class XYZKeyFactory extends KeyFactorySpi

Fields Summary
Constructors Summary
Methods Summary
protected java.security.PrivateKeyengineGeneratePrivate(java.security.spec.KeySpec ks)

        if (!(ks instanceof XYZKeySpec))
            throw new InvalidKeySpecException("Expecting XYZKeySpec");
        XYZKey k = new XYZKey();
        k.rotValue = ((XYZKeySpec) ks).rotValue;
        return k;
    
protected java.security.PublicKeyengineGeneratePublic(java.security.spec.KeySpec ks)

        // 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 java.security.spec.KeySpecengineGetKeySpec(java.security.Key key, java.lang.Class specClass)

        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 java.security.KeyengineTranslateKey(java.security.Key key)

        // 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;