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

DSAKeyValue

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

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

param
element
param
BaseURI
throws
XMLSecurityException


               
       
             
      super(element, BaseURI);
   
public DSAKeyValue(Document doc, BigInteger P, BigInteger Q, BigInteger G, BigInteger Y)
Constructor DSAKeyValue

param
doc
param
P
param
Q
param
G
param
Y


      super(doc);

      XMLUtils.addReturnToElement(this._constructionElement);
      this.addBigIntegerElement(P, Constants._TAG_P);
      this.addBigIntegerElement(Q, Constants._TAG_Q);
      this.addBigIntegerElement(G, Constants._TAG_G);
      this.addBigIntegerElement(Y, Constants._TAG_Y);
   
public DSAKeyValue(Document doc, Key key)
Constructor DSAKeyValue

param
doc
param
key
throws
IllegalArgumentException


      super(doc);

      XMLUtils.addReturnToElement(this._constructionElement);

      if (key instanceof java.security.interfaces.DSAPublicKey) {
         this.addBigIntegerElement(((DSAPublicKey) key).getParams().getP(),
                                   Constants._TAG_P);
         this.addBigIntegerElement(((DSAPublicKey) key).getParams().getQ(),
                                   Constants._TAG_Q);
         this.addBigIntegerElement(((DSAPublicKey) key).getParams().getG(),
                                   Constants._TAG_G);
         this.addBigIntegerElement(((DSAPublicKey) key).getY(),
                                   Constants._TAG_Y);
      } else {
         Object exArgs[] = { Constants._TAG_DSAKEYVALUE,
                             key.getClass().getName() };

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

inheritDoc

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

inheritDoc


      try {
         DSAPublicKeySpec pkspec =
            new DSAPublicKeySpec(this
               .getBigIntegerFromChildElement(Constants._TAG_Y, Constants
               .SignatureSpecNS), this
                  .getBigIntegerFromChildElement(Constants._TAG_P, Constants
                  .SignatureSpecNS), this
                     .getBigIntegerFromChildElement(Constants._TAG_Q, Constants
                     .SignatureSpecNS), this
                        .getBigIntegerFromChildElement(Constants
                           ._TAG_G, Constants.SignatureSpecNS));
         KeyFactory dsaFactory = KeyFactory.getInstance("DSA");
         PublicKey pk = dsaFactory.generatePublic(pkspec);

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