/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* KeyFactory base class. Provides common infrastructure for the RSA, DSA,
* and DH implementations.
*
* The subclasses support conversion between keys and keyspecs
* using X.509, PKCS#8, and their individual algorithm specific formats,
* assuming keys are extractable.
*
* @author Andreas Sterbenz
* @since 1.5
*/
// token instance
// algorithm name, currently one of RSA, DSA, DH
super();
}
/**
* Convert an arbitrary key of algorithm into a P11Key of token.
* Used by P11Signature.init() and RSACipher.init().
*/
throws InvalidKeyException {
}
// see JCA spec
throws InvalidKeySpecException {
token.ensureValid();
throw new InvalidKeySpecException
("key and keySpec must not be null");
}
// delegate to our Java based providers for PKCS#8 and X.509
try {
} catch (GeneralSecurityException e) {
throw new InvalidKeySpecException("Could not encode key", e);
}
}
// first translate into a key of this token, if it is not already
try {
} catch (InvalidKeyException e) {
throw new InvalidKeySpecException("Could not convert key", e);
}
try {
} else {
}
} catch (PKCS11Exception e) {
throw new InvalidKeySpecException("Could not generate KeySpec", e);
} finally {
}
}
// see JCA spec
token.ensureValid();
throw new InvalidKeyException("Key must not be null");
}
throw new InvalidKeyException
("Key algorithm must be " + algorithm);
}
// already a key of this token, no need to translate
return key;
}
}
return p11Key;
}
return publicKey;
} else if (key instanceof PrivateKey) {
return privateKey;
} else {
throw new InvalidKeyException
("Key must be instance of PublicKey or PrivateKey");
}
}
throws InvalidKeyException;
throws InvalidKeyException;
}