View | Details | Raw Unified | Return to bug 40897
Collapse All | Expand All

(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/algorithms/Algorithm.java (-1 / +1 lines)
Lines 71-77 Link Here
71
    */
71
    */
72
   protected void setAlgorithmURI(String algorithmURI) {
72
   protected void setAlgorithmURI(String algorithmURI) {
73
73
74
      if ((this._state == MODE_CREATE) && (algorithmURI != null)) {
74
      if ( (algorithmURI != null)) {
75
         this._constructionElement.setAttributeNS(null, Constants._ATT_ALGORITHM,
75
         this._constructionElement.setAttributeNS(null, Constants._ATT_ALGORITHM,
76
                                                algorithmURI);
76
                                                algorithmURI);
77
      }
77
      }
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/encryption/XMLCipher.java (-2 / +1 lines)
Lines 3722-3729 Link Here
3722
			      }
3722
			      }
3723
3723
3724
			      this._doc = doc;
3724
			      this._doc = doc;
3725
			      this._state = ElementProxy.MODE_CREATE;
3725
			      this._constructionElement =  createElementForFamilyLocal(this._doc,
3726
				  this._constructionElement =  createElementForFamilyLocal(this._doc,
3727
			    		  this.getBaseNamespace(), this.getBaseLocalName()); 
3726
			    		  this.getBaseNamespace(), this.getBaseLocalName()); 
3728
			}
3727
			}
3729
			/**
3728
			/**
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/keys/content/X509Data.java (-64 / +4 lines)
Lines 68-75 Link Here
68
           throws XMLSecurityException {
68
           throws XMLSecurityException {
69
69
70
      super(element, BaseURI);
70
      super(element, BaseURI);
71
      
72
      boolean noElements=true;
73
      Node sibling=this._constructionElement.getFirstChild();
71
      Node sibling=this._constructionElement.getFirstChild();
74
      while (sibling!=null) {
72
      while (sibling!=null) {
75
      	 if (sibling.getNodeType()!=Node.ELEMENT_NODE) {
73
      	 if (sibling.getNodeType()!=Node.ELEMENT_NODE) {
Lines 76-127 Link Here
76
      	 	sibling=sibling.getNextSibling();
74
      	 	sibling=sibling.getNextSibling();
77
            continue;
75
            continue;
78
         }
76
         }
79
        noElements=false;
77
      	 return;
80
         Element currentElem = (Element) sibling;
81
         sibling=sibling.getNextSibling();
82
         String localname = currentElem.getLocalName();
83
84
         if (currentElem.getNamespaceURI().equals(Constants.SignatureSpecNS)) {
85
            if (localname.equals(Constants._TAG_X509ISSUERSERIAL)) {
86
               XMLX509IssuerSerial is = new XMLX509IssuerSerial(currentElem,
87
                                           BaseURI);
88
89
               this.add(is);
90
            } else if (localname.equals(Constants._TAG_X509SKI)) {
91
               XMLX509SKI ski = new XMLX509SKI(currentElem, BaseURI);
92
93
               this.add(ski);
94
            } else if (localname.equals(Constants._TAG_X509SUBJECTNAME)) {
95
               XMLX509SubjectName sn = new XMLX509SubjectName(currentElem,
96
                                          BaseURI);
97
98
               this.add(sn);
99
            } else if (localname.equals(Constants._TAG_X509CERTIFICATE)) {
100
               XMLX509Certificate cert = new XMLX509Certificate(currentElem,
101
                                            BaseURI);
102
103
               this.add(cert);
104
            } else if (localname.equals(Constants._TAG_X509CRL)) {
105
               XMLX509CRL crl = new XMLX509CRL(currentElem, BaseURI);
106
107
               this.add(crl);
108
            } else {
109
               log.warn("Found a " + currentElem.getTagName() + " element in "
110
                        + Constants._TAG_X509DATA);
111
               this.addUnknownElement(currentElem);
112
            }
113
         } else {
114
            log.warn("Found a " + currentElem.getTagName() + " element in "
115
                     + Constants._TAG_X509DATA);
116
            this.addUnknownElement(currentElem);
117
         }
118
      }
78
      }
119
      if (noElements) {
79
      /* No Elements found */
120
        Object exArgs[] = { "Elements", Constants._TAG_X509DATA };
80
      Object exArgs[] = { "Elements", Constants._TAG_X509DATA };
121
81
      throw new XMLSecurityException("xml.WrongContent", exArgs);
122
        throw new XMLSecurityException("xml.WrongContent", exArgs);
123
     }
124
125
   }
82
   }
126
83
127
   /**
84
   /**
Lines 165-175 Link Here
165
    */
122
    */
166
   public void add(XMLX509IssuerSerial xmlX509IssuerSerial) {
123
   public void add(XMLX509IssuerSerial xmlX509IssuerSerial) {
167
124
168
      if (this._state == MODE_SIGN) {
169
         this._constructionElement
125
         this._constructionElement
170
            .appendChild(xmlX509IssuerSerial.getElement());
126
            .appendChild(xmlX509IssuerSerial.getElement());
171
         XMLUtils.addReturnToElement(this._constructionElement);
127
         XMLUtils.addReturnToElement(this._constructionElement);
172
      }
173
   }
128
   }
174
129
175
   /**
130
   /**
Lines 198-208 Link Here
198
    * @param xmlX509SKI
153
    * @param xmlX509SKI
199
    */
154
    */
200
   public void add(XMLX509SKI xmlX509SKI) {
155
   public void add(XMLX509SKI xmlX509SKI) {
201
202
      if (this._state == MODE_SIGN) {
203
         this._constructionElement.appendChild(xmlX509SKI.getElement());
156
         this._constructionElement.appendChild(xmlX509SKI.getElement());
204
         XMLUtils.addReturnToElement(this._constructionElement);
157
         XMLUtils.addReturnToElement(this._constructionElement);
205
      }
206
   }
158
   }
207
159
208
   /**
160
   /**
Lines 229-239 Link Here
229
    * @param xmlX509SubjectName
181
    * @param xmlX509SubjectName
230
    */
182
    */
231
   public void add(XMLX509SubjectName xmlX509SubjectName) {
183
   public void add(XMLX509SubjectName xmlX509SubjectName) {
232
233
      if (this._state == MODE_SIGN) {
234
         this._constructionElement.appendChild(xmlX509SubjectName.getElement());
184
         this._constructionElement.appendChild(xmlX509SubjectName.getElement());
235
         XMLUtils.addReturnToElement(this._constructionElement);
185
         XMLUtils.addReturnToElement(this._constructionElement);
236
      }
237
   }
186
   }
238
187
239
   /**
188
   /**
Lines 262-272 Link Here
262
    * @param xmlX509Certificate
211
    * @param xmlX509Certificate
263
    */
212
    */
264
   public void add(XMLX509Certificate xmlX509Certificate) {
213
   public void add(XMLX509Certificate xmlX509Certificate) {
265
266
      if (this._state == MODE_SIGN) {
267
         this._constructionElement.appendChild(xmlX509Certificate.getElement());
214
         this._constructionElement.appendChild(xmlX509Certificate.getElement());
268
         XMLUtils.addReturnToElement(this._constructionElement);
215
         XMLUtils.addReturnToElement(this._constructionElement);
269
      }
270
   }
216
   }
271
217
272
   /**
218
   /**
Lines 284-294 Link Here
284
    * @param xmlX509CRL
230
    * @param xmlX509CRL
285
    */
231
    */
286
   public void add(XMLX509CRL xmlX509CRL) {
232
   public void add(XMLX509CRL xmlX509CRL) {
287
288
      if (this._state == MODE_SIGN) {
289
         this._constructionElement.appendChild(xmlX509CRL.getElement());
233
         this._constructionElement.appendChild(xmlX509CRL.getElement());
290
         XMLUtils.addReturnToElement(this._constructionElement);
234
         XMLUtils.addReturnToElement(this._constructionElement);
291
      }
292
   }
235
   }
293
236
294
   /**
237
   /**
Lines 297-307 Link Here
297
    * @param element
240
    * @param element
298
    */
241
    */
299
   public void addUnknownElement(Element element) {
242
   public void addUnknownElement(Element element) {
300
301
      if (this._state == MODE_SIGN) {
302
         this._constructionElement.appendChild(element);
243
         this._constructionElement.appendChild(element);
303
         XMLUtils.addReturnToElement(this._constructionElement);
244
         XMLUtils.addReturnToElement(this._constructionElement);
304
      }
305
   }
245
   }
306
246
307
   /**
247
   /**
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/keys/KeyInfo.java (-28 / +1 lines)
Lines 131-137 Link Here
131
    */
131
    */
132
   public void setId(String Id) {
132
   public void setId(String Id) {
133
133
134
      if ((this._state == MODE_SIGN) && (Id != null)) {
134
      if ((Id != null)) {
135
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
135
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
136
         IdResolver.registerElementById(this._constructionElement, Id);
136
         IdResolver.registerElementById(this._constructionElement, Id);
137
      }
137
      }
Lines 162-171 Link Here
162
    */
162
    */
163
   public void add(KeyName keyname) {
163
   public void add(KeyName keyname) {
164
164
165
      if (this._state == MODE_SIGN) {
166
         this._constructionElement.appendChild(keyname.getElement());
165
         this._constructionElement.appendChild(keyname.getElement());
167
         XMLUtils.addReturnToElement(this._constructionElement);
166
         XMLUtils.addReturnToElement(this._constructionElement);
168
      }
169
   }
167
   }
170
168
171
   /**
169
   /**
Lines 219-229 Link Here
219
    * @param keyvalue
217
    * @param keyvalue
220
    */
218
    */
221
   public void add(KeyValue keyvalue) {
219
   public void add(KeyValue keyvalue) {
222
223
      if (this._state == MODE_SIGN) {
224
         this._constructionElement.appendChild(keyvalue.getElement());
220
         this._constructionElement.appendChild(keyvalue.getElement());
225
         XMLUtils.addReturnToElement(this._constructionElement);
221
         XMLUtils.addReturnToElement(this._constructionElement);
226
      }
227
   }
222
   }
228
223
229
   /**
224
   /**
Lines 241-251 Link Here
241
    * @param mgmtdata
236
    * @param mgmtdata
242
    */
237
    */
243
   public void add(MgmtData mgmtdata) {
238
   public void add(MgmtData mgmtdata) {
244
245
      if (this._state == MODE_SIGN) {
246
         this._constructionElement.appendChild(mgmtdata.getElement());
239
         this._constructionElement.appendChild(mgmtdata.getElement());
247
         XMLUtils.addReturnToElement(this._constructionElement);
240
         XMLUtils.addReturnToElement(this._constructionElement);
248
      }
249
   }
241
   }
250
242
251
   /**
243
   /**
Lines 254-264 Link Here
254
    * @param pgpdata
246
    * @param pgpdata
255
    */
247
    */
256
   public void add(PGPData pgpdata) {
248
   public void add(PGPData pgpdata) {
257
258
      if (this._state == MODE_SIGN) {
259
         this._constructionElement.appendChild(pgpdata.getElement());
249
         this._constructionElement.appendChild(pgpdata.getElement());
260
         XMLUtils.addReturnToElement(this._constructionElement);
250
         XMLUtils.addReturnToElement(this._constructionElement);
261
      }
262
   }
251
   }
263
252
264
   /**
253
   /**
Lines 279-289 Link Here
279
    * @param retrievalmethod
268
    * @param retrievalmethod
280
    */
269
    */
281
   public void add(RetrievalMethod retrievalmethod) {
270
   public void add(RetrievalMethod retrievalmethod) {
282
283
      if (this._state == MODE_SIGN) {
284
         this._constructionElement.appendChild(retrievalmethod.getElement());
271
         this._constructionElement.appendChild(retrievalmethod.getElement());
285
         XMLUtils.addReturnToElement(this._constructionElement);
272
         XMLUtils.addReturnToElement(this._constructionElement);
286
      }
287
   }
273
   }
288
274
289
   /**
275
   /**
Lines 292-302 Link Here
292
    * @param spkidata
278
    * @param spkidata
293
    */
279
    */
294
   public void add(SPKIData spkidata) {
280
   public void add(SPKIData spkidata) {
295
296
      if (this._state == MODE_SIGN) {
297
         this._constructionElement.appendChild(spkidata.getElement());
281
         this._constructionElement.appendChild(spkidata.getElement());
298
         XMLUtils.addReturnToElement(this._constructionElement);
282
         XMLUtils.addReturnToElement(this._constructionElement);
299
      }
300
   }
283
   }
301
284
302
   /**
285
   /**
Lines 305-312 Link Here
305
    * @param x509data
288
    * @param x509data
306
    */
289
    */
307
   public void add(X509Data x509data) {
290
   public void add(X509Data x509data) {
308
309
      if (this._state == MODE_SIGN) {
310
    	  if (x509Datas==null)
291
    	  if (x509Datas==null)
311
    		  x509Datas=new ArrayList();
292
    		  x509Datas=new ArrayList();
312
    	  x509Datas.add(x509data);
293
    	  x509Datas.add(x509data);
Lines 312-318 Link Here
312
    	  x509Datas.add(x509data);
293
    	  x509Datas.add(x509data);
313
         this._constructionElement.appendChild(x509data.getElement());
294
         this._constructionElement.appendChild(x509data.getElement());
314
         XMLUtils.addReturnToElement(this._constructionElement);
295
         XMLUtils.addReturnToElement(this._constructionElement);
315
      }
316
   }
296
   }
317
297
318
	/**
298
	/**
Lines 324-331 Link Here
324
304
325
	public void add(EncryptedKey encryptedKey) 
305
	public void add(EncryptedKey encryptedKey) 
326
		throws XMLEncryptionException {
306
		throws XMLEncryptionException {
327
328
		if (this._state == MODE_SIGN) {
329
			if (encryptedKeys==null)
307
			if (encryptedKeys==null)
330
				encryptedKeys=new ArrayList();
308
				encryptedKeys=new ArrayList();
331
			encryptedKeys.add(encryptedKey);
309
			encryptedKeys.add(encryptedKey);
Lines 331-338 Link Here
331
			encryptedKeys.add(encryptedKey);
309
			encryptedKeys.add(encryptedKey);
332
			XMLCipher cipher = XMLCipher.getInstance();
310
			XMLCipher cipher = XMLCipher.getInstance();
333
			this._constructionElement.appendChild(cipher.martial(encryptedKey));
311
			this._constructionElement.appendChild(cipher.martial(encryptedKey));
334
		}
335
336
	}
312
	}
337
313
338
   /**
314
   /**
Lines 341-351 Link Here
341
    * @param element
317
    * @param element
342
    */
318
    */
343
   public void addUnknownElement(Element element) {
319
   public void addUnknownElement(Element element) {
344
345
      if (this._state == MODE_SIGN) {
346
         this._constructionElement.appendChild(element);
320
         this._constructionElement.appendChild(element);
347
         XMLUtils.addReturnToElement(this._constructionElement);
321
         XMLUtils.addReturnToElement(this._constructionElement);
348
      }
349
   }
322
   }
350
323
351
   /**
324
   /**
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/signature/Manifest.java (-11 / +1 lines)
Lines 137-144 Link Here
137
           String BaseURI, String referenceURI, Transforms transforms, String digestURI, String ReferenceId, String ReferenceType)
137
           String BaseURI, String referenceURI, Transforms transforms, String digestURI, String ReferenceId, String ReferenceType)
138
              throws XMLSignatureException {
138
              throws XMLSignatureException {
139
139
140
      if (this._state == MODE_SIGN) {
141
142
         // the this._doc is handed implicitly by the this.getOwnerDocument()
140
         // the this._doc is handed implicitly by the this.getOwnerDocument()
143
         Reference ref = new Reference(this._doc, BaseURI, referenceURI, this,
141
         Reference ref = new Reference(this._doc, BaseURI, referenceURI, this,
144
                                       transforms, digestURI);
142
                                       transforms, digestURI);
Lines 157-163 Link Here
157
         // add the Element of the Reference object to the Manifest/SignedInfo
155
         // add the Element of the Reference object to the Manifest/SignedInfo
158
         this._constructionElement.appendChild(ref.getElement());
156
         this._constructionElement.appendChild(ref.getElement());
159
         XMLUtils.addReturnToElement(this._constructionElement);
157
         XMLUtils.addReturnToElement(this._constructionElement);
160
      }
161
   }
158
   }
162
159
163
   /**
160
   /**
Lines 171-177 Link Here
171
   public void generateDigestValues()
168
   public void generateDigestValues()
172
           throws XMLSignatureException, ReferenceNotInitializedException {
169
           throws XMLSignatureException, ReferenceNotInitializedException {
173
170
174
      if (this._state == MODE_SIGN) {
175
         for (int i = 0; i < this.getLength(); i++) {
171
         for (int i = 0; i < this.getLength(); i++) {
176
172
177
            // update the cached Reference object, the Element content is automatically updated
173
            // update the cached Reference object, the Element content is automatically updated
Lines 179-185 Link Here
179
175
180
            currentRef.generateDigestValue();
176
            currentRef.generateDigestValue();
181
         }
177
         }
182
      }
183
   }
178
   }
184
179
185
   /**
180
   /**
Lines 201-211 Link Here
201
    */
196
    */
202
   public Reference item(int i) throws XMLSecurityException {
197
   public Reference item(int i) throws XMLSecurityException {
203
198
204
      if (this._state == MODE_SIGN) {
205
206
         // we already have real objects
207
         return (Reference) this._references.get(i);
208
      } 
209
         if (this._references.get(i) == null) {
199
         if (this._references.get(i) == null) {
210
200
211
            // not yet constructed, so _we_ have to            
201
            // not yet constructed, so _we_ have to            
Lines 225-231 Link Here
225
    */
215
    */
226
   public void setId(String Id) {
216
   public void setId(String Id) {
227
217
228
      if ((this._state == MODE_SIGN) && (Id != null)) {
218
      if (Id != null) {
229
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
219
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
230
         IdResolver.registerElementById(this._constructionElement, Id);
220
         IdResolver.registerElementById(this._constructionElement, Id);
231
      }
221
      }
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/signature/ObjectContainer.java (-6 / +4 lines)
Lines 64-70 Link Here
64
    */
64
    */
65
   public void setId(String Id) {
65
   public void setId(String Id) {
66
66
67
      if ((this._state == MODE_SIGN) && (Id != null)) {
67
      if ((Id != null)) {
68
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
68
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
69
         IdResolver.registerElementById(this._constructionElement, Id);
69
         IdResolver.registerElementById(this._constructionElement, Id);
70
      }
70
      }
Lines 86-92 Link Here
86
    */
86
    */
87
   public void setMimeType(String MimeType) {
87
   public void setMimeType(String MimeType) {
88
88
89
      if ((this._state == MODE_SIGN) && (MimeType != null)) {
89
      if ( (MimeType != null)) {
90
         this._constructionElement.setAttributeNS(null, Constants._ATT_MIMETYPE,
90
         this._constructionElement.setAttributeNS(null, Constants._ATT_MIMETYPE,
91
                                                MimeType);
91
                                                MimeType);
92
      }
92
      }
Lines 108-114 Link Here
108
    */
108
    */
109
   public void setEncoding(String Encoding) {
109
   public void setEncoding(String Encoding) {
110
110
111
      if ((this._state == MODE_SIGN) && (Encoding != null)) {
111
      if ((Encoding != null)) {
112
         this._constructionElement.setAttributeNS(null, Constants._ATT_ENCODING,
112
         this._constructionElement.setAttributeNS(null, Constants._ATT_ENCODING,
113
                                                Encoding);
113
                                                Encoding);
114
      }
114
      }
Lines 133-141 Link Here
133
133
134
      Node result = null;
134
      Node result = null;
135
135
136
      if (this._state == MODE_SIGN) {
136
      result = this._constructionElement.appendChild(node);
137
         result = this._constructionElement.appendChild(node);
138
      }
139
137
140
      return result;
138
      return result;
141
   }
139
   }
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/signature/Reference.java (-12 / +4 lines)
Lines 233-239 Link Here
233
    */
233
    */
234
   public void setURI(String URI) {
234
   public void setURI(String URI) {
235
235
236
      if ((this._state == MODE_SIGN) && (URI != null)) {
236
      if ( URI != null) {
237
         this._constructionElement.setAttributeNS(null, Constants._ATT_URI,
237
         this._constructionElement.setAttributeNS(null, Constants._ATT_URI,
238
                                                  URI);
238
                                                  URI);
239
      }
239
      }
Lines 255-261 Link Here
255
    */
255
    */
256
   public void setId(String Id) {
256
   public void setId(String Id) {
257
257
258
      if ((this._state == MODE_SIGN) && (Id != null)) {
258
      if ( Id != null ) {
259
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
259
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
260
         IdResolver.registerElementById(this._constructionElement, Id);
260
         IdResolver.registerElementById(this._constructionElement, Id);
261
      }
261
      }
Lines 277-283 Link Here
277
    */
277
    */
278
   public void setType(String Type) {
278
   public void setType(String Type) {
279
279
280
      if ((this._state == MODE_SIGN) && (Type != null)) {
280
      if (Type != null) {
281
         this._constructionElement.setAttributeNS(null, Constants._ATT_TYPE,
281
         this._constructionElement.setAttributeNS(null, Constants._ATT_TYPE,
282
                                                  Type);
282
                                                  Type);
283
      }
283
      }
Lines 334-342 Link Here
334
    */
334
    */
335
   private void setDigestValueElement(byte[] digestValue)
335
   private void setDigestValueElement(byte[] digestValue)
336
   {
336
   {
337
338
      if (this._state == MODE_SIGN) {
339
340
         Node n=digestValueElement.getFirstChild();
337
         Node n=digestValueElement.getFirstChild();
341
         while (n!=null) {
338
         while (n!=null) {
342
               digestValueElement.removeChild(n);
339
               digestValueElement.removeChild(n);
Lines 347-353 Link Here
347
         Text t = this._doc.createTextNode(base64codedValue);
344
         Text t = this._doc.createTextNode(base64codedValue);
348
345
349
         digestValueElement.appendChild(t);
346
         digestValueElement.appendChild(t);
350
      }
351
   }
347
   }
352
348
353
   /**
349
   /**
Lines 358-368 Link Here
358
    */
354
    */
359
   public void generateDigestValue()
355
   public void generateDigestValue()
360
           throws XMLSignatureException, ReferenceNotInitializedException {
356
           throws XMLSignatureException, ReferenceNotInitializedException {
361
357
      this.setDigestValueElement(this.calculateDigest());
362
      if (this._state == MODE_SIGN) {
363
364
         this.setDigestValueElement(this.calculateDigest());
365
      }
366
   }
358
   }
367
359
368
   /**
360
   /**
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/signature/SignatureProperties.java (-1 / +1 lines)
Lines 105-111 Link Here
105
    */
105
    */
106
   public void setId(String Id) {
106
   public void setId(String Id) {
107
107
108
      if ((this._state == MODE_SIGN) && (Id != null)) {
108
      if ((Id != null)) {
109
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
109
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
110
         IdResolver.registerElementById(this._constructionElement, Id);
110
         IdResolver.registerElementById(this._constructionElement, Id);
111
      }
111
      }
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/signature/SignatureProperty.java (-2 / +2 lines)
Lines 76-82 Link Here
76
    */
76
    */
77
   public void setId(String Id) {
77
   public void setId(String Id) {
78
78
79
      if ((this._state == MODE_SIGN) && (Id != null)) {
79
      if ((Id != null)) {
80
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
80
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
81
         IdResolver.registerElementById(this._constructionElement, Id);
81
         IdResolver.registerElementById(this._constructionElement, Id);
82
      }
82
      }
Lines 98-104 Link Here
98
    */
98
    */
99
   public void setTarget(String Target) {
99
   public void setTarget(String Target) {
100
100
101
      if ((this._state == MODE_SIGN) && (Target != null)) {
101
      if ((Target != null)) {
102
         this._constructionElement.setAttributeNS(null, Constants._ATT_TARGET, Target);
102
         this._constructionElement.setAttributeNS(null, Constants._ATT_TARGET, Target);
103
      }
103
      }
104
   }
104
   }
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/signature/XMLSignature.java (-14 / +12 lines)
Lines 323-329 Link Here
323
    */
323
    */
324
   public void setId(String Id) {
324
   public void setId(String Id) {
325
325
326
      if ((this._state == MODE_SIGN) && (Id != null)) {
326
      if ( (Id != null)) {
327
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
327
         this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
328
         IdResolver.registerElementById(this._constructionElement, Id);
328
         IdResolver.registerElementById(this._constructionElement, Id);
329
      }
329
      }
Lines 374-380 Link Here
374
   private void setSignatureValueElement(byte[] bytes)
374
   private void setSignatureValueElement(byte[] bytes)
375
   {
375
   {
376
376
377
      if (this._state == MODE_SIGN) {
378
    	 while (signatureValueElement.hasChildNodes()) {
377
    	 while (signatureValueElement.hasChildNodes()) {
379
        	 signatureValueElement.removeChild(signatureValueElement.getFirstChild());
378
        	 signatureValueElement.removeChild(signatureValueElement.getFirstChild());
380
         }
379
         }
Lines 392-398 Link Here
392
         if (base64codedValue.length() > 76) {
391
         if (base64codedValue.length() > 76) {
393
	    XMLUtils.addReturnToElement(signatureValueElement);
392
	    XMLUtils.addReturnToElement(signatureValueElement);
394
         }
393
         }
395
      }
396
   }
394
   }
397
395
398
   /**
396
   /**
Lines 406-412 Link Here
406
   public KeyInfo getKeyInfo() {
404
   public KeyInfo getKeyInfo() {
407
405
408
      // check to see if we are signing and if we have to create a keyinfo
406
      // check to see if we are signing and if we have to create a keyinfo
409
      if ((this._state == MODE_SIGN) && (this._keyInfo == null)) {
407
      if ( (this._keyInfo == null)) {
410
408
411
         // create the KeyInfo
409
         // create the KeyInfo
412
         this._keyInfo = new KeyInfo(this._doc);
410
         this._keyInfo = new KeyInfo(this._doc);
Lines 445-461 Link Here
445
   public void appendObject(ObjectContainer object)
443
   public void appendObject(ObjectContainer object)
446
           throws XMLSignatureException {
444
           throws XMLSignatureException {
447
445
448
      try {
446
      //try {
449
         if (this._state != MODE_SIGN) {
447
         //if (this._state != MODE_SIGN) {
450
            throw new XMLSignatureException(
448
           // throw new XMLSignatureException(
451
               "signature.operationOnlyBeforeSign");
449
             //  "signature.operationOnlyBeforeSign");
452
         }
450
         //}
453
451
454
         this._constructionElement.appendChild(object.getElement());
452
         this._constructionElement.appendChild(object.getElement());
455
         XMLUtils.addReturnToElement(this._constructionElement);
453
         XMLUtils.addReturnToElement(this._constructionElement);
456
      } catch (XMLSecurityException ex) {
454
      //} catch (XMLSecurityException ex) {
457
         throw new XMLSignatureException("empty", ex);
455
        // throw new XMLSignatureException("empty", ex);
458
      }
456
      //}
459
   }
457
   }
460
458
461
   /**
459
   /**
Lines 501-507 Link Here
501
      }
499
      }
502
500
503
      try {
501
      try {
504
         if (this._state == MODE_SIGN) {
502
        // if (this._state == MODE_SIGN) {
505
            //Create a SignatureAlgorithm object
503
            //Create a SignatureAlgorithm object
506
        	SignedInfo si = this.getSignedInfo();
504
        	SignedInfo si = this.getSignedInfo();
507
            SignatureAlgorithm sa = si.getSignatureAlgorithm();               
505
            SignatureAlgorithm sa = si.getSignatureAlgorithm();               
Lines 523-529 Link Here
523
521
524
            // set them on the SignateValue element
522
            // set them on the SignateValue element
525
            this.setSignatureValueElement(jcebytes);
523
            this.setSignatureValueElement(jcebytes);
526
         }
524
         //}
527
      } catch (CanonicalizationException ex) {
525
      } catch (CanonicalizationException ex) {
528
         throw new XMLSignatureException("empty", ex);
526
         throw new XMLSignatureException("empty", ex);
529
      } catch (InvalidCanonicalizerException ex) {
527
      } catch (InvalidCanonicalizerException ex) {
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/utils/ElementChecker.java (+14 lines)
Line 0 Link Here
1
package org.apache.xml.security.utils;
2
3
import org.apache.xml.security.exceptions.XMLSecurityException;
4
import org.w3c.dom.Element;
5
6
public interface ElementChecker {
7
	 /**
8
	  * Check that the elemnt is the one expect
9
	  *
10
	  * @throws XMLSecurityException
11
	  */
12
	   void guaranteeThatElementInCorrectSpace(ElementProxy expected, Element actual)
13
	           throws XMLSecurityException;
14
}
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/utils/ElementCheckerImpl.java (+51 lines)
Line 0 Link Here
1
package org.apache.xml.security.utils;
2
3
import org.apache.xml.security.exceptions.XMLSecurityException;
4
import org.w3c.dom.Element;
5
6
public class ElementCheckerImpl {
7
	/** A checker for DOM that interns NS */
8
	public static class InternedNsChecker implements ElementChecker {
9
		public void guaranteeThatElementInCorrectSpace(ElementProxy expected,
10
				Element actual) throws XMLSecurityException {
11
12
		      String localnameSHOULDBE = expected.getBaseLocalName();
13
		      String namespaceSHOULDBE = expected.getBaseNamespace();
14
		      
15
		      String localnameIS = actual.getLocalName();
16
		      String namespaceIS = actual.getNamespaceURI();
17
		      if ((namespaceSHOULDBE!=namespaceIS) ||
18
		       !localnameSHOULDBE.equals(localnameIS) ) {      
19
		         Object exArgs[] = { namespaceIS +":"+ localnameIS, 
20
		           namespaceSHOULDBE +":"+ localnameSHOULDBE};
21
		         throw new XMLSecurityException("xml.WrongElement", exArgs);
22
		      }			
23
		}		
24
	}
25
	
26
	/** A checker for DOM that interns NS */
27
	public static class FullChecker implements ElementChecker {
28
		public void guaranteeThatElementInCorrectSpace(ElementProxy expected,
29
				Element actual) throws XMLSecurityException {
30
31
		      String localnameSHOULDBE = expected.getBaseLocalName();
32
		      String namespaceSHOULDBE = expected.getBaseNamespace();
33
		      
34
		      String localnameIS = actual.getLocalName();
35
		      String namespaceIS = actual.getNamespaceURI();
36
		      if ((!namespaceSHOULDBE.equals(namespaceIS)) ||
37
		       !localnameSHOULDBE.equals(localnameIS) ) {      
38
		         Object exArgs[] = { namespaceIS +":"+ localnameIS, 
39
		           namespaceSHOULDBE +":"+ localnameSHOULDBE};
40
		         throw new XMLSecurityException("xml.WrongElement", exArgs);
41
		      }			
42
		}		
43
	}
44
	
45
	/** An empty checker if schema checking is used */
46
	public static class EmptyChecker implements ElementChecker {
47
		public void guaranteeThatElementInCorrectSpace(ElementProxy expected,
48
				Element actual) throws XMLSecurityException {
49
		}		
50
	}
51
}
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/utils/ElementProxy.java (-36 / +6 lines)
Lines 42-68 Link Here
42
   /** {@link org.apache.commons.logging} logging facility */
42
   /** {@link org.apache.commons.logging} logging facility */
43
    static org.apache.commons.logging.Log log = 
43
    static org.apache.commons.logging.Log log = 
44
        org.apache.commons.logging.LogFactory.getLog(ElementProxy.class.getName());
44
        org.apache.commons.logging.LogFactory.getLog(ElementProxy.class.getName());
45
   //J-
45
   
46
    /** The element has been created by the code **/
47
   public static final int MODE_CREATE  = 0;
48
   /** The element has been readed from a DOM tree by the code **/
49
   public static final int MODE_PROCESS = 1;
50
   /** The element isn't known if it is readen or created **/
51
   public static final int MODE_UNKNOWN = 2;
52
53
   /** The element is going to be signed **/
54
   public static final int MODE_SIGN    = MODE_CREATE;
55
   /** The element is going to be verified **/
56
   public static final int MODE_VERIFY  = MODE_PROCESS;
57
58
   /** The element is going to be encrypted **/
59
   public static final int MODE_ENCRYPT = MODE_CREATE;
60
   /** The element is going to be decrypted **/
61
   public static final int MODE_DECRYPT = MODE_PROCESS;
62
63
   protected int _state = MODE_UNKNOWN;
64
   //J+
65
66
   /**
46
   /**
67
    * Returns the namespace of the Elements of the sub-class.
47
    * Returns the namespace of the Elements of the sub-class.
68
    *
48
    *
Lines 104-110 Link Here
104
      }
84
      }
105
85
106
      this._doc = doc;
86
      this._doc = doc;
107
      this._state = ElementProxy.MODE_CREATE;
108
      this._constructionElement = createElementForFamilyLocal(this._doc,
87
      this._constructionElement = createElementForFamilyLocal(this._doc,
109
    		  this.getBaseNamespace(), this.getBaseLocalName());      
88
    		  this.getBaseNamespace(), this.getBaseLocalName());      
110
   }       
89
   }       
Lines 194-200 Link Here
194
      }
173
      }
195
        
174
        
196
      this._doc = element.getOwnerDocument();
175
      this._doc = element.getOwnerDocument();
197
      this._state = ElementProxy.MODE_PROCESS;
198
      this._constructionElement = element;
176
      this._constructionElement = element;
199
      this._baseURI = BaseURI;
177
      this._baseURI = BaseURI;
200
   }
178
   }
Lines 218-224 Link Here
218
      }
196
      }
219
197
220
      this._doc = element.getOwnerDocument();
198
      this._doc = element.getOwnerDocument();
221
      this._state = ElementProxy.MODE_PROCESS;
222
      this._constructionElement = element;
199
      this._constructionElement = element;
223
      this._baseURI = BaseURI;
200
      this._baseURI = BaseURI;
224
201
Lines 267-272 Link Here
267
   public String getBaseURI() {
244
   public String getBaseURI() {
268
      return this._baseURI;
245
      return this._baseURI;
269
   }
246
   }
247
   
248
   static ElementChecker checker = new ElementCheckerImpl.InternedNsChecker();
270
249
271
   /**
250
   /**
272
    * Method guaranteeThatElementInCorrectSpace
251
    * Method guaranteeThatElementInCorrectSpace
Lines 273-292 Link Here
273
    *
252
    *
274
    * @throws XMLSecurityException
253
    * @throws XMLSecurityException
275
    */
254
    */
276
   public void guaranteeThatElementInCorrectSpace()
255
   void guaranteeThatElementInCorrectSpace()
277
           throws XMLSecurityException {
256
           throws XMLSecurityException {
278
257
	  
279
      String localnameSHOULDBE = this.getBaseLocalName();
258
	  checker.guaranteeThatElementInCorrectSpace(this,this._constructionElement);
280
      String namespaceSHOULDBE = this.getBaseNamespace();
281
      
259
      
282
      String localnameIS = this._constructionElement.getLocalName();
283
      String namespaceIS = this._constructionElement.getNamespaceURI();
284
      if ((namespaceSHOULDBE!=namespaceIS) ||
285
       !localnameSHOULDBE.equals(localnameIS) ) {      
286
         Object exArgs[] = { namespaceIS +":"+ localnameIS, 
287
           namespaceSHOULDBE +":"+ localnameSHOULDBE};
288
         throw new XMLSecurityException("xml.WrongElement", exArgs);
289
      }
290
   }
260
   }
291
261
292
   /**
262
   /**
(-)/Users/raulbenito/Documents/workspace/XML_SECURITY_TRUNK/src/org/apache/xml/security/utils/SignatureElementProxy.java (-4 lines)
Lines 43-54 Link Here
43
	      }
43
	      }
44
44
45
	      this._doc = doc;
45
	      this._doc = doc;
46
	      this._state = ElementProxy.MODE_CREATE;
47
	      this._constructionElement =  XMLUtils.createElementInSignatureSpace(this._doc,
46
	      this._constructionElement =  XMLUtils.createElementInSignatureSpace(this._doc,
48
	    		   this.getBaseLocalName());
47
	    		   this.getBaseLocalName());
49
      //super(doc);
50
      //this._constructionElement.setAttributeNS(Constants.NamespaceSpecNS,"xmlns:ds",
51
        //          Constants.SignatureSpecNS);
52
   }
48
   }
53
49
54
   /**
50
   /**

Return to bug 40897