You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by bl...@apache.org on 2004/04/04 06:25:09 UTC

cvs commit: xml-security/src/org/apache/xml/security/signature Reference.java

blautenb    2004/04/03 20:25:09

  Modified:    src/org/apache/xml/security/algorithms
                        MessageDigestAlgorithm.java
               src/org/apache/xml/security/signature Reference.java
  Log:
  Check that DigestAlgorithm URI exists and that DigestValue exists when validating a reference.  See Bugzilla bug #28162
  
  Revision  Changes    Path
  1.13      +6 -0      xml-security/src/org/apache/xml/security/algorithms/MessageDigestAlgorithm.java
  
  Index: MessageDigestAlgorithm.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src/org/apache/xml/security/algorithms/MessageDigestAlgorithm.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MessageDigestAlgorithm.java	8 Feb 2004 06:09:55 -0000	1.12
  +++ MessageDigestAlgorithm.java	4 Apr 2004 04:25:09 -0000	1.13
  @@ -84,6 +84,12 @@
   
         JCEMapper.ProviderIdClass algorithmID =
            JCEMapper.translateURItoJCEID(algorithmURI);
  +
  +	  if (algorithmID == null) {
  +		  Object[] exArgs = { algorithmURI };
  +		  throw new XMLSignatureException("algorithms.NoSuchMap", exArgs);
  +	  }
  +
         MessageDigest md;
   
         try {
  
  
  
  1.32      +14 -1     xml-security/src/org/apache/xml/security/signature/Reference.java
  
  Index: Reference.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src/org/apache/xml/security/signature/Reference.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- Reference.java	8 Feb 2004 06:11:19 -0000	1.31
  +++ Reference.java	4 Apr 2004 04:25:09 -0000	1.32
  @@ -251,6 +251,10 @@
         String uri = digestMethodElem.getAttributeNS(null,
            Constants._ATT_ALGORITHM);
   
  +	  if (uri == null) {
  +		  return null;
  +	  }
  +
         return MessageDigestAlgorithm.getInstance(this._doc, uri);
      }
   
  @@ -767,10 +771,19 @@
       *
       * @return the digest value.
       * @throws Base64DecodingException if Reference contains no proper base64 encoded data.
  +	* @throws XMLSecurityException if the Reference does not contain a DigestValue element
       */
  -   public byte[] getDigestValue() throws Base64DecodingException {
  +   public byte[] getDigestValue() throws Base64DecodingException, XMLSecurityException {
         Element digestValueElem = this.getChildElementLocalName(0,
            Constants.SignatureSpecNS, Constants._TAG_DIGESTVALUE);
  +	  if (digestValueElem == null) {
  +		  // The required element is not in the XML!
  +		  Object[] exArgs ={ Constants._TAG_DIGESTVALUE, 
  +							 Constants.SignatureSpecNS };
  +		  throw new XMLSecurityException(
  +					"signature.Verification.NoSignatureElement", 
  +					exArgs);
  +	  }
         byte[] elemDig = Base64.decode(digestValueElem);
         return elemDig;
      }