FileDocCategorySizeDatePackage
RSAKeyValue.javaAPI DocJava SE 6 API4234Tue Jun 10 00:23:02 BST 2008com.sun.org.apache.xml.internal.security.keys.content.keyvalues

RSAKeyValue

public class RSAKeyValue extends SignatureElementProxy implements KeyValueContent
author
$Author: raul $

Fields Summary
static Logger
log
{@link java.util.logging} logging facility
Constructors Summary
public RSAKeyValue(Element element, String BaseURI)
Constructor RSAKeyValue

param
element
param
BaseURI
throws
XMLSecurityException


               
       
             
      super(element, BaseURI);
   
public RSAKeyValue(Document doc, BigInteger modulus, BigInteger exponent)
Constructor RSAKeyValue

param
doc
param
modulus
param
exponent


      super(doc);

      XMLUtils.addReturnToElement(this._constructionElement);
      this.addBigIntegerElement(modulus, Constants._TAG_MODULUS);
      this.addBigIntegerElement(exponent, Constants._TAG_EXPONENT);
   
public RSAKeyValue(Document doc, Key key)
Constructor RSAKeyValue

param
doc
param
key
throws
IllegalArgumentException


      super(doc);

      XMLUtils.addReturnToElement(this._constructionElement);

      if (key instanceof java.security.interfaces.RSAPublicKey ) {
         this.addBigIntegerElement(((RSAPublicKey) key).getModulus(),
                                   Constants._TAG_MODULUS);
         this.addBigIntegerElement(((RSAPublicKey) key).getPublicExponent(),
                                   Constants._TAG_EXPONENT);
      } else {
         Object exArgs[] = { Constants._TAG_RSAKEYVALUE,
                             key.getClass().getName() };

         throw new IllegalArgumentException(I18n
            .translate("KeyValue.IllegalArgument", exArgs));
      }
   
Methods Summary
public java.lang.StringgetBaseLocalName()

inheritDoc

      return Constants._TAG_RSAKEYVALUE;
   
public java.security.PublicKeygetPublicKey()

inheritDoc


      try {
         KeyFactory rsaFactory = KeyFactory.getInstance("RSA");

         // KeyFactory rsaFactory = KeyFactory.getInstance(JCE_RSA);
         RSAPublicKeySpec rsaKeyspec =
            new RSAPublicKeySpec(this
               .getBigIntegerFromChildElement(Constants._TAG_MODULUS, Constants
               .SignatureSpecNS), this
                  .getBigIntegerFromChildElement(Constants
                     ._TAG_EXPONENT, Constants.SignatureSpecNS));
         PublicKey pk = rsaFactory.generatePublic(rsaKeyspec);

         return pk;
      } catch (NoSuchAlgorithmException ex) {
         throw new XMLSecurityException("empty", ex);
      } catch (InvalidKeySpecException ex) {
         throw new XMLSecurityException("empty", ex);
      }