Examples of DEREncodedKeyValue


Examples of org.opensaml.xml.signature.DEREncodedKeyValue

     * @throws NoSuchAlgorithmException if the key type is unsupported
     * @throws InvalidKeySpecException if the key type does not support X.509 SPKI encoding
     */
    public static void addDEREncodedPublicKey(KeyInfo keyInfo, PublicKey pk)
            throws NoSuchAlgorithmException, InvalidKeySpecException {
        DEREncodedKeyValue keyValue = (DEREncodedKeyValue) Configuration.getBuilderFactory()
            .getBuilder(DEREncodedKeyValue.DEFAULT_ELEMENT_NAME)
            .buildObject(DEREncodedKeyValue.DEFAULT_ELEMENT_NAME);
       
        KeyFactory keyFactory = KeyFactory.getInstance(pk.getAlgorithm());
        X509EncodedKeySpec keySpec = keyFactory.getKeySpec(pk, X509EncodedKeySpec.class);
        keyValue.setValue(Base64.encodeBytes(keySpec.getEncoded()));
        keyInfo.getXMLObjects().add(keyValue);
    }   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.