Package org.opensaml.xml.signature

Examples of org.opensaml.xml.signature.KeyValue


     * @param pk the native Java {@link PublicKey} to add
     * @throws IllegalArgumentException thrown if an unsupported public key
     *          type is passed
     */
    public static void addPublicKey(KeyInfo keyInfo, PublicKey pk) throws IllegalArgumentException {
        KeyValue keyValue = (KeyValue) Configuration.getBuilderFactory()
            .getBuilder(KeyValue.DEFAULT_ELEMENT_NAME)
            .buildObject(KeyValue.DEFAULT_ELEMENT_NAME);
       
        if (pk instanceof RSAPublicKey) {
            keyValue.setRSAKeyValue(buildRSAKeyValue((RSAPublicKey) pk));
        } else if (pk instanceof DSAPublicKey) {
            keyValue.setDSAKeyValue(buildDSAKeyValue((DSAPublicKey) pk));
        } else {
           throw new IllegalArgumentException("Only RSAPublicKey and DSAPublicKey are supported");
        }
       
        keyInfo.getKeyValues().add(keyValue);
View Full Code Here


        if (keyValueList.size() > 1) {
          throw new RelyingPartyException("invalidKeyValueCount");
        }

        KeyValue val = null;
        RSAKeyValue rsaKey = null;
        Element modElem = null;
        Element expElem = null;
        Element elem = null;
        OMElement omElem = null;
        BigInteger mod = null;
        BigInteger exp = null;

        val = (KeyValue) keyValueList.get(0);
        rsaKey = val.getRSAKeyValue();
        elem = rsaKey.getDOM();
        omElem = (OMElement) new OMDOMFactory().getDocument().importNode(elem, true);
        modElem = (Element) omElem.getFirstChildWithName(Modulus.DEFAULT_ELEMENT_NAME);
        expElem = (Element) omElem.getFirstChildWithName(Exponent.DEFAULT_ELEMENT_NAME);
        mod = Base64.decodeBigIntegerFromElement(modElem);
View Full Code Here

public class KeyValueUnmarshaller extends AbstractXMLSignatureUnmarshaller {

    /** {@inheritDoc} */
    protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject)
            throws UnmarshallingException {
        KeyValue keyValue = (KeyValue) parentXMLObject;

        if (childXMLObject instanceof DSAKeyValue) {
            keyValue.setDSAKeyValue((DSAKeyValue) childXMLObject);
        } else if (childXMLObject instanceof RSAKeyValue) {
            keyValue.setRSAKeyValue((RSAKeyValue) childXMLObject);
        } else {
            // There can be only one...
            if (keyValue.getUnknownXMLObject() == null) {
                keyValue.setUnknownXMLObject(childXMLObject);
            } else {
                // If this happens, throw the others up to the parent class to be logged/handled.
                super.processChildElement(parentXMLObject, childXMLObject);
            }
        }
View Full Code Here

     * @param pk the native Java {@link PublicKey} to add
     * @throws IllegalArgumentException thrown if an unsupported public key
     *          type is passed
     */
    public static void addPublicKey(KeyInfo keyInfo, PublicKey pk) throws IllegalArgumentException {
        KeyValue keyValue = (KeyValue) Configuration.getBuilderFactory()
            .getBuilder(KeyValue.DEFAULT_ELEMENT_NAME)
            .buildObject(KeyValue.DEFAULT_ELEMENT_NAME);
       
        if (pk instanceof RSAPublicKey) {
            keyValue.setRSAKeyValue(buildRSAKeyValue((RSAPublicKey) pk));
        } else if (pk instanceof DSAPublicKey) {
            keyValue.setDSAKeyValue(buildDSAKeyValue((DSAPublicKey) pk));
        } else {
           throw new IllegalArgumentException("Only RSAPublicKey and DSAPublicKey are supported");
        }
       
        keyInfo.getKeyValues().add(keyValue);
View Full Code Here

     * @param pk the native Java {@link PublicKey} to add
     * @throws IllegalArgumentException thrown if an unsupported public key
     *          type is passed
     */
    public static void addPublicKey(KeyInfo keyInfo, PublicKey pk) throws IllegalArgumentException {
        KeyValue keyValue = (KeyValue) Configuration.getBuilderFactory()
            .getBuilder(KeyValue.DEFAULT_ELEMENT_NAME)
            .buildObject(KeyValue.DEFAULT_ELEMENT_NAME);
       
        if (pk instanceof RSAPublicKey) {
            keyValue.setRSAKeyValue(buildRSAKeyValue((RSAPublicKey) pk));
        } else if (pk instanceof DSAPublicKey) {
            keyValue.setDSAKeyValue(buildDSAKeyValue((DSAPublicKey) pk));
        } else {
           throw new IllegalArgumentException("Only RSAPublicKey and DSAPublicKey are supported");
        }
       
        keyInfo.getKeyValues().add(keyValue);
View Full Code Here

public class KeyValueUnmarshaller extends AbstractXMLSignatureUnmarshaller {

    /** {@inheritDoc} */
    protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject)
            throws UnmarshallingException {
        KeyValue keyValue = (KeyValue) parentXMLObject;

        if (childXMLObject instanceof DSAKeyValue) {
            keyValue.setDSAKeyValue((DSAKeyValue) childXMLObject);
        } else if (childXMLObject instanceof RSAKeyValue) {
            keyValue.setRSAKeyValue((RSAKeyValue) childXMLObject);
        } else {
            // There can be only one...
            if (keyValue.getUnknownXMLObject() == null) {
                keyValue.setUnknownXMLObject(childXMLObject);
            } else {
                // If this happens, throw the others up to the parent class to be logged/handled.
                super.processChildElement(parentXMLObject, childXMLObject);
            }
        }
View Full Code Here

TOP

Related Classes of org.opensaml.xml.signature.KeyValue

Copyright © 2018 www.massapicom. 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.