ElementReference.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.message.soap.reference;

  21. import javax.xml.soap.SOAPElement;

  22. /**
  23.  * ElementReference
  24.  *
  25.  *
  26.  * @author Poli Andrea (apoli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */
  30. public class ElementReference extends Reference  {

  31.     private SOAPElement element;
  32.    
  33.     public static final int TYPE_ENCRYPT_CONTENT = 1;
  34.     public static final int TYPE_ENCRYPT_ELEMENT = 2;
  35.     public static final int TYPE_SIGNATURE = 3;
  36.    
  37.     public ElementReference(SOAPElement element, int type, String reference) {
  38.         super(type, reference);
  39.         this.setElement(element);
  40.     }
  41.    
  42.     @Override
  43.     public String toString() {
  44.        
  45.         String referenceType = null;
  46.         if(super.type == ElementReference.TYPE_ENCRYPT_CONTENT || super.type == ElementReference.TYPE_SIGNATURE) {
  47.             referenceType = Reference.REFERENCE_CONTENT;
  48.         } else if(this.type == ElementReference.TYPE_ENCRYPT_ELEMENT) {
  49.             referenceType = Reference.REFERENCE_ELEMENT;
  50.         }
  51.         return "{"+referenceType+"}{"+this.getElement().getNamespaceURI()+"}"+this.getElement().getLocalName();
  52.     }

  53.     public SOAPElement getElement() {
  54.         return this.element;
  55.     }

  56.     public void setElement(SOAPElement element) {
  57.         this.element = element;
  58.     }
  59. }