135. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 9/25/2018 2:13:05 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

135.1 Files compared

# Location File Last Modified
1 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\org\apache\xml\internal\security\keys KeyInfo.java Mon Jan 22 14:46:50 2018 UTC
2 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\org\apache\xml\internal\security\keys KeyInfo.java Wed Sep 12 16:37:43 2018 UTC

135.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 10 2554
Changed 9 20
Inserted 0 0
Removed 0 0

135.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

135.4 Active regular expressions

No regular expressions were active.

135.5 Comparison detail

  1   /*
  2    * reserve d comment  block
  3    * DO NOT  REMOVE OR  ALTER!
  4    */
  5   /**
  6    * License d to the A pache Soft ware Found ation (ASF ) under on e
  7    * or more  contribut or license  agreement s. See the  NOTICE fi le
  8    * distrib uted with  this work  for additi onal infor mation
  9    * regardi ng copyrig ht ownersh ip. The AS F licenses  this file
  10    * to you  under the  Apache Lic ense, Vers ion 2.0 (t he
  11    * "Licens e"); you m ay not use  this file  except in  complianc e
  12    * with th e License.  You may o btain a co py of the  License at
  13    *
  14    * http:// www.apache .org/licen ses/LICENS E-2.0
  15    *
  16    * Unless  required b y applicab le law or  agreed to  in writing ,
  17    * softwar e distribu ted under  the Licens e is distr ibuted on  an
  18    * "AS IS"  BASIS, WI THOUT WARR ANTIES OR  CONDITIONS  OF ANY
  19    * KIND, e ither expr ess or imp lied. See  the Licens e for the
  20    * specifi c language  governing  permissio ns and lim itations
  21    * under t he License .
  22    */
  23   package co m.sun.org. apache.xml .internal. security.k eys;
  24  
  25   import jav a.security .PrivateKe y;
  26   import jav a.security .PublicKey ;
  27   import jav a.security .cert.X509 Certificat e;
  28   import jav a.util.Arr ayList;
  29   import jav a.util.Ite rator;
  30   import jav a.util.Lis t;
  31  
  32   import jav ax.crypto. SecretKey;
  33  
  34   import com .sun.org.a pache.xml. internal.s ecurity.en cryption.E ncryptedKe y;
  35   import com .sun.org.a pache.xml. internal.s ecurity.en cryption.X MLCipher;
  36   import com .sun.org.a pache.xml. internal.s ecurity.en cryption.X MLEncrypti onExceptio n;
  37   import com .sun.org.a pache.xml. internal.s ecurity.ex ceptions.X MLSecurity Exception;
  38   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.content .DEREncode dKeyValue;
  39   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.content .KeyInfoRe ference;
  40   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.content .KeyName;
  41   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.content .KeyValue;
  42   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.content .MgmtData;
  43   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.content .PGPData;
  44   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.content .Retrieval Method;
  45   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.content .SPKIData;
  46   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.content .X509Data;
  47   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.content .keyvalues .DSAKeyVal ue;
  48   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.content .keyvalues .RSAKeyVal ue;
  49   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.keyreso lver.KeyRe solver;
  50   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.keyreso lver.KeyRe solverExce ption;
  51   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.keyreso lver.KeyRe solverSpi;
  52   import com .sun.org.a pache.xml. internal.s ecurity.ke ys.storage .StorageRe solver;
  53   import com .sun.org.a pache.xml. internal.s ecurity.tr ansforms.T ransforms;
  54   import com .sun.org.a pache.xml. internal.s ecurity.ut ils.Consta nts;
  55   import com .sun.org.a pache.xml. internal.s ecurity.ut ils.Encryp tionConsta nts;
  56   import com .sun.org.a pache.xml. internal.s ecurity.ut ils.Signat ureElement Proxy;
  57   import com .sun.org.a pache.xml. internal.s ecurity.ut ils.XMLUti ls;
  58   import org .w3c.dom.A ttr;
  59   import org .w3c.dom.D ocument;
  60   import org .w3c.dom.E lement;
  61   import org .w3c.dom.N ode;
  62   import org .w3c.dom.N odeList;
  63  
  64   /**
  65    * This cl ass stand  for KeyInf o Element  that may c ontain key s, names,
  66    * certifi cates and  other publ ic key man agement in formation,
  67    * such as  in-band k ey distrib ution or k ey agreeme nt data.
  68    * <BR />
  69    * KeyInfo  Element h as two bas ic functio ns:
  70    * One is  KeyResolve  for getti ng the pub lic key in  signature  validatio n processi ng.
  71    * the oth er one is  toElement  for gettin g the elem ent in sig nature gen eration pr ocessing.
  72    * <BR />
  73    * The <CO DE>lengthX XX()</CODE > methods  provide ac cess to th e internal  Key
  74    * objects :
  75    * <UL>
  76    * <LI>If  the <CODE> KeyInfo</C ODE> was c onstructed  from an E lement
  77    * (Signat ure verifi cation), t he <CODE>l engthXXX() </CODE> me thods sear ches
  78    * for chi ld element s of <CODE >ds:KeyInf o</CODE> f or known t ypes. </LI >
  79    * <LI>If  the <CODE> KeyInfo</C ODE> was c onstructed  from scra tch (durin g
  80    * Signatu re generat ion), the  <CODE>leng thXXX()</C ODE> metho ds return  the number
  81    * of <COD E>XXXs</CO DE> object s already  passed to  the KeyInf o</LI>
  82    * </UL>
  83    * <BR />
  84    * The <CO DE>addXXX( )</CODE> m ethods are  used for  adding Obj ects of th e
  85    * appropr iate type  to the <CO DE>KeyInfo </CODE>. T his is use d during s ignature
  86    * generat ion.
  87    * <BR />
  88    * The <CO DE>itemXXX (int i)</C ODE> metho ds return  the i'th o bject of t he
  89    * corresp onding typ e.
  90    * <BR />
  91    * The <CO DE>contain sXXX()</CO DE> method s return < I>whether< /I> the Ke yInfo
  92    * contain s the corr esponding  type.
  93    *
  94    */
  95   public cla ss KeyInfo  extends S ignatureEl ementProxy  {
  96  
  97       /** {@ link org.a pache.comm ons.loggin g} logging  facility  */
  98       privat e static j ava.util.l ogging.Log ger log =
  99           ja va.util.lo gging.Logg er.getLogg er(KeyInfo .class.get Name());
  100  
  101       // We  need at le ast one St orageResol ver otherw ise
  102       // the  KeyResolv ers would  not be cal led.
  103       // The  default S torageReso lver is nu ll.
  104  
  105       privat e List<X50 9Data> x50 9Datas = n ull;
  106       privat e List<Enc ryptedKey>  encrypted Keys = nul l;
  107  
  108       privat e static f inal List< StorageRes olver> nul lList;
  109       static  {
  110           Li st<Storage Resolver>  list = new  ArrayList <StorageRe solver>(1) ;
  111           li st.add(nul l);
  112           nu llList = j ava.util.C ollections .unmodifia bleList(li st);
  113       }
  114  
  115       /** Fi eld storag eResolvers  */
  116       privat e List<Sto rageResolv er> storag eResolvers  = nullLis t;
  117  
  118       /**
  119        * Sto res the in dividual ( per-KeyInf o) {@link  KeyResolve rSpi}s
  120        */
  121       privat e List<Key ResolverSp i> interna lKeyResolv ers = new  ArrayList< KeyResolve rSpi>();
  122  
  123       privat e boolean  secureVali dation;
  124  
  125       /**
  126        * Con structor K eyInfo
  127        * @pa ram doc
  128        */
  129       public  KeyInfo(D ocument do c) {
  130           su per(doc);
  131  
  132           XM LUtils.add ReturnToEl ement(this .construct ionElement );
  133       }
  134  
  135       /**
  136        * Con structor K eyInfo
  137        *
  138        * @pa ram elemen t
  139        * @pa ram baseUR I
  140        * @th rows XMLSe curityExce ption
  141        */
  142       public  KeyInfo(E lement ele ment, Stri ng baseURI ) throws X MLSecurity Exception  {
  143           su per(elemen t, baseURI );
  144  
  145           At tr attr =  element.ge tAttribute NodeNS(nul l, "Id");
  146           if  (attr !=  null) {
  147                element. setIdAttri buteNode(a ttr, true) ;
  148           }
  149       }
  150  
  151       /**
  152        * Set  whether s ecure proc essing is  enabled or  not. The  default is  false.
  153        */
  154       public  void setS ecureValid ation(bool ean secure Validation ) {
  155           th is.secureV alidation  = secureVa lidation;
  156       }
  157  
  158       /**
  159        * Set s the <cod e>Id</code > attribut e
  160        *
  161        * @pa ram Id ID
  162        */
  163       public  void setI d(String i d) {
  164           if  (id != nu ll) {
  165                this.con structionE lement.set AttributeN S(null, Co nstants._A TT_ID, id) ;
  166                this.con structionE lement.set IdAttribut eNS(null,  Constants. _ATT_ID, t rue);
  167           }
  168       }
  169  
  170       /**
  171        * Ret urns the < code>Id</c ode> attri bute
  172        *
  173        * @re turn the < code>Id</c ode> attri bute
  174        */
  175       public  String ge tId() {
  176           re turn this. constructi onElement. getAttribu teNS(null,  Constants ._ATT_ID);
  177       }
  178  
  179       /**
  180        * Met hod addKey Name
  181        *
  182        * @pa ram keynam eString
  183        */
  184       public  void addK eyName(Str ing keynam eString) {
  185           th is.add(new  KeyName(t his.doc, k eynameStri ng));
  186       }
  187  
  188       /**
  189        * Met hod add
  190        *
  191        * @pa ram keynam e
  192        */
  193       public  void add( KeyName ke yname) {
  194           th is.constru ctionEleme nt.appendC hild(keyna me.getElem ent());
  195           XM LUtils.add ReturnToEl ement(this .construct ionElement );
  196       }
  197  
  198       /**
  199        * Met hod addKey Value
  200        *
  201        * @pa ram pk
  202        */
  203       public  void addK eyValue(Pu blicKey pk ) {
  204           th is.add(new  KeyValue( this.doc,  pk));
  205       }
  206  
  207       /**
  208        * Met hod addKey Value
  209        *
  210        * @pa ram unknow nKeyValueE lement
  211        */
  212       public  void addK eyValue(El ement unkn ownKeyValu eElement)  {
  213           th is.add(new  KeyValue( this.doc,  unknownKey ValueEleme nt));
  214       }
  215  
  216       /**
  217        * Met hod add
  218        *
  219        * @pa ram dsakey value
  220        */
  221       public  void add( DSAKeyValu e dsakeyva lue) {
  222           th is.add(new  KeyValue( this.doc,  dsakeyvalu e));
  223       }
  224  
  225       /**
  226        * Met hod add
  227        *
  228        * @pa ram rsakey value
  229        */
  230       public  void add( RSAKeyValu e rsakeyva lue) {
  231           th is.add(new  KeyValue( this.doc,  rsakeyvalu e));
  232       }
  233  
  234       /**
  235        * Met hod add
  236        *
  237        * @pa ram pk
  238        */
  239       public  void add( PublicKey  pk) {
  240           th is.add(new  KeyValue( this.doc,  pk));
  241       }
  242  
  243       /**
  244        * Met hod add
  245        *
  246        * @pa ram keyval ue
  247        */
  248       public  void add( KeyValue k eyvalue) {
  249           th is.constru ctionEleme nt.appendC hild(keyva lue.getEle ment());
  250           XM LUtils.add ReturnToEl ement(this .construct ionElement );
  251       }
  252  
  253       /**
  254        * Met hod addMgm tData
  255        *
  256        * @pa ram mgmtda ta
  257        */
  258       public  void addM gmtData(St ring mgmtd ata) {
  259           th is.add(new  MgmtData( this.doc,  mgmtdata)) ;
  260       }
  261  
  262       /**
  263        * Met hod add
  264        *
  265        * @pa ram mgmtda ta
  266        */
  267       public  void add( MgmtData m gmtdata) {
  268           th is.constru ctionEleme nt.appendC hild(mgmtd ata.getEle ment());
  269           XM LUtils.add ReturnToEl ement(this .construct ionElement );
  270       }
  271  
  272       /**
  273        * Met hod addPGP Data
  274        *
  275        * @pa ram pgpdat a
  276        */
  277       public  void add( PGPData pg pdata) {
  278           th is.constru ctionEleme nt.appendC hild(pgpda ta.getElem ent());
  279           XM LUtils.add ReturnToEl ement(this .construct ionElement );
  280       }
  281  
  282       /**
  283        * Met hod addRet rievalMeth od
  284        *
  285        * @pa ram uri
  286        * @pa ram transf orms
  287        * @pa ram Type
  288        */
  289       public  void addR etrievalMe thod(Strin g uri, Tra nsforms tr ansforms,  String Typ e) {
  290           th is.add(new  Retrieval Method(thi s.doc, uri , transfor ms, Type)) ;
  291       }
  292  
  293       /**
  294        * Met hod add
  295        *
  296        * @pa ram retrie valmethod
  297        */
  298       public  void add( RetrievalM ethod retr ievalmetho d) {
  299           th is.constru ctionEleme nt.appendC hild(retri evalmethod .getElemen t());
  300           XM LUtils.add ReturnToEl ement(this .construct ionElement );
  301       }
  302  
  303       /**
  304        * Met hod add
  305        *
  306        * @pa ram spkida ta
  307        */
  308       public  void add( SPKIData s pkidata) {
  309           th is.constru ctionEleme nt.appendC hild(spkid ata.getEle ment());
  310           XM LUtils.add ReturnToEl ement(this .construct ionElement );
  311       }
  312  
  313       /**
  314        * Met hod addX50 9Data
  315        *
  316        * @pa ram x509da ta
  317        */
  318       public  void add( X509Data x 509data) {
  319           if  (x509Data s == null)  {
  320                x509Data s = new Ar rayList<X5 09Data>();
  321           }
  322           x5 09Datas.ad d(x509data );
  323           th is.constru ctionEleme nt.appendC hild(x509d ata.getEle ment());
  324           XM LUtils.add ReturnToEl ement(this .construct ionElement );
  325       }
  326  
  327       /**
  328        * Met hod addEnc ryptedKey
  329        *
  330        * @pa ram encryp tedKey
  331        * @th rows XMLEn cryptionEx ception
  332        */
  333  
  334       public  void add( EncryptedK ey encrypt edKey) thr ows XMLEnc ryptionExc eption {
  335           if  (encrypte dKeys == n ull) {
  336                encrypte dKeys = ne w ArrayLis t<Encrypte dKey>();
  337           }
  338           en cryptedKey s.add(encr yptedKey);
  339           XM LCipher ci pher = XML Cipher.get Instance() ;
  340           th is.constru ctionEleme nt.appendC hild(ciphe r.martial( encryptedK ey));
  341       }
  342  
  343       /**
  344        * Met hod addDER EncodedKey Value
  345        *
  346        * @pa ram pk
  347        * @th rows XMLSe curityExce ption
  348        */
  349       public  void addD EREncodedK eyValue(Pu blicKey pk ) throws X MLSecurity Exception  {
  350           th is.add(new  DEREncode dKeyValue( this.doc,  pk));
  351       }
  352  
  353       /**
  354        * Met hod add
  355        *
  356        * @pa ram derEnc odedKeyVal ue
  357        */
  358       public  void add( DEREncoded KeyValue d erEncodedK eyValue) {
  359           th is.constru ctionEleme nt.appendC hild(derEn codedKeyVa lue.getEle ment());
  360           XM LUtils.add ReturnToEl ement(this .construct ionElement );
  361       }
  362  
  363       /**
  364        * Met hod addKey InfoRefere nce
  365        *
  366        * @pa ram URI
  367        * @th rows XMLSe curityExce ption
  368        */
  369       public  void addK eyInfoRefe rence(Stri ng URI) th rows XMLSe curityExce ption {
  370           th is.add(new  KeyInfoRe ference(th is.doc, UR I));
  371       }
  372  
  373       /**
  374        * Met hod add
  375        *
  376        * @pa ram keyInf oReference
  377        */
  378       public  void add( KeyInfoRef erence key InfoRefere nce) {
  379           th is.constru ctionEleme nt.appendC hild(keyIn foReferenc e.getEleme nt());
  380           XM LUtils.add ReturnToEl ement(this .construct ionElement );
  381       }
  382  
  383       /**
  384        * Met hod addUnk nownElemen t
  385        *
  386        * @pa ram elemen t
  387        */
  388       public  void addU nknownElem ent(Elemen t element)  {
  389           th is.constru ctionEleme nt.appendC hild(eleme nt);
  390           XM LUtils.add ReturnToEl ement(this .construct ionElement );
  391       }
  392  
  393       /**
  394        * Met hod length KeyName
  395        *
  396        * @re turn the n umber of t he KeyName  tags
  397        */
  398       public  int lengt hKeyName()  {
  399           re turn this. length(Con stants.Sig natureSpec NS, Consta nts._TAG_K EYNAME);
  400       }
  401  
  402       /**
  403        * Met hod length KeyValue
  404        *
  405        *@ret urn the nu mber of th e KeyValue  tags
  406        */
  407       public  int lengt hKeyValue( ) {
  408           re turn this. length(Con stants.Sig natureSpec NS, Consta nts._TAG_K EYVALUE);
  409       }
  410  
  411       /**
  412        * Met hod length MgmtData
  413        *
  414        *@ret urn the nu mber of th e MgmtData  tags
  415        */
  416       public  int lengt hMgmtData( ) {
  417           re turn this. length(Con stants.Sig natureSpec NS, Consta nts._TAG_M GMTDATA);
  418       }
  419  
  420       /**
  421        * Met hod length PGPData
  422        *
  423        *@ret urn the nu mber of th e PGPDat.  tags
  424        */
  425       public  int lengt hPGPData()  {
  426           re turn this. length(Con stants.Sig natureSpec NS, Consta nts._TAG_P GPDATA);
  427       }
  428  
  429       /**
  430        * Met hod length RetrievalM ethod
  431        *
  432        *@ret urn the nu mber of th e Retrieva lMethod ta gs
  433        */
  434       public  int lengt hRetrieval Method() {
  435           re turn this. length(Con stants.Sig natureSpec NS, Consta nts._TAG_R ETRIEVALME THOD);
  436       }
  437  
  438       /**
  439        * Met hod length SPKIData
  440        *
  441        *@ret urn the nu mber of th e SPKIData  tags
  442        */
  443       public  int lengt hSPKIData( ) {
  444           re turn this. length(Con stants.Sig natureSpec NS, Consta nts._TAG_S PKIDATA);
  445       }
  446  
  447       /**
  448        * Met hod length X509Data
  449        *
  450        *@ret urn the nu mber of th e X509Data  tags
  451        */
  452       public  int lengt hX509Data( ) {
  453           if  (x509Data s != null)  {
  454                return x 509Datas.s ize();
  455           }
  456           re turn this. length(Con stants.Sig natureSpec NS, Consta nts._TAG_X 509DATA);
  457       }
  458  
  459       /**
  460        * Met hod length DEREncoded KeyValue
  461        *
  462        *@ret urn the nu mber of th e DEREncod edKeyValue  tags
  463        */
  464       public  int lengt hDEREncode dKeyValue( ) {
  465           re turn this. length(Con stants.Sig natureSpec 11NS, Cons tants._TAG _DERENCODE DKEYVALUE) ;
  466       }
  467  
  468       /**
  469        * Met hod length KeyInfoRef erence
  470        *
  471        *@ret urn the nu mber of th e KeyInfoR eference t ags
  472        */
  473       public  int lengt hKeyInfoRe ference()  {
  474           re turn this. length(Con stants.Sig natureSpec 11NS, Cons tants._TAG _KEYINFORE FERENCE);
  475       }
  476  
  477       /**
  478        * Met hod length UnknownEle ment
  479        * NOT E possibly  buggy.
  480        * @re turn the n umber of t he Unknown Element ta gs
  481        */
  482       public  int lengt hUnknownEl ement() {
  483           in t res = 0;
  484           No deList nl  = this.con structionE lement.get ChildNodes ();
  485  
  486           fo r (int i =  0; i < nl .getLength (); i++) {
  487                Node cur rent = nl. item(i);
  488  
  489                /**
  490                 * $todo $ using th is method,  we don't  see unknow n Elements
  491                 *  from  Signature  NS; revis it
  492                 */
  493                if ((cur rent.getNo deType() = = Node.ELE MENT_NODE)
  494                    && c urrent.get NamespaceU RI().equal s(Constant s.Signatur eSpecNS))  {
  495                    res+ +;
  496                }
  497           }
  498  
  499           re turn res;
  500       }
  501  
  502       /**
  503        * Met hod itemKe yName
  504        *
  505        * @pa ram i
  506        * @re turn the a sked KeyNa me element , null if  the index  is too big
  507        * @th rows XMLSe curityExce ption
  508        */
  509       public  KeyName i temKeyName (int i) th rows XMLSe curityExce ption {
  510           El ement e =
  511                XMLUtils .selectDsN ode(
  512                    this .construct ionElement .getFirstC hild(), Co nstants._T AG_KEYNAME , i);
  513  
  514           if  (e != nul l) {
  515                return n ew KeyName (e, this.b aseURI);
  516           }
  517           re turn null;
  518       }
  519  
  520       /**
  521        * Met hod itemKe yValue
  522        *
  523        * @pa ram i
  524        * @re turn the a sked KeyVa lue elemen t, null if  the index  is too bi g
  525        * @th rows XMLSe curityExce ption
  526        */
  527       public  KeyValue  itemKeyVal ue(int i)  throws XML SecurityEx ception {
  528           El ement e =
  529                XMLUtils .selectDsN ode(
  530                    this .construct ionElement .getFirstC hild(), Co nstants._T AG_KEYVALU E, i);
  531  
  532           if  (e != nul l) {
  533                return n ew KeyValu e(e, this. baseURI);
  534           }
  535           re turn null;
  536       }
  537  
  538       /**
  539        * Met hod itemMg mtData
  540        *
  541        * @pa ram i
  542        * @re turn the a sked MgmtD ata elemen t, null if  the index  is too bi g
  543        * @th rows XMLSe curityExce ption
  544        */
  545       public  MgmtData  itemMgmtDa ta(int i)  throws XML SecurityEx ception {
  546           El ement e =
  547                XMLUtils .selectDsN ode(
  548                    this .construct ionElement .getFirstC hild(), Co nstants._T AG_MGMTDAT A, i);
  549  
  550           if  (e != nul l) {
  551                return n ew MgmtDat a(e, this. baseURI);
  552           }
  553           re turn null;
  554       }
  555  
  556       /**
  557        * Met hod itemPG PData
  558        *
  559        * @pa ram i
  560        * @re turn the a sked PGPDa ta element , null if  the index  is too big
  561        * @th rows XMLSe curityExce ption
  562        */
  563       public  PGPData i temPGPData (int i) th rows XMLSe curityExce ption {
  564           El ement e =
  565                XMLUtils .selectDsN ode(
  566                    this .construct ionElement .getFirstC hild(), Co nstants._T AG_PGPDATA , i);
  567  
  568           if  (e != nul l) {
  569                return n ew PGPData (e, this.b aseURI);
  570           }
  571           re turn null;
  572       }
  573  
  574       /**
  575        * Met hod itemRe trievalMet hod
  576        *
  577        * @pa ram i
  578        *@ret urn the as ked Retrie valMethod  element, n ull if the  index is  too big
  579        * @th rows XMLSe curityExce ption
  580        */
  581       public  Retrieval Method ite mRetrieval Method(int  i) throws  XMLSecuri tyExceptio n {
  582           El ement e =
  583                XMLUtils .selectDsN ode(
  584                    this .construct ionElement .getFirstC hild(), Co nstants._T AG_RETRIEV ALMETHOD,  i);
  585  
  586           if  (e != nul l) {
  587                return n ew Retriev alMethod(e , this.bas eURI);
  588           }
  589           re turn null;
  590       }
  591  
  592       /**
  593        * Met hod itemSP KIData
  594        *
  595        * @pa ram i
  596        * @re turn the a sked SPKID ata elemen t, null if  the index  is too bi g
  597        * @th rows XMLSe curityExce ption
  598        */
  599       public  SPKIData  itemSPKIDa ta(int i)  throws XML SecurityEx ception {
  600           El ement e =
  601                XMLUtils .selectDsN ode(
  602                    this .construct ionElement .getFirstC hild(), Co nstants._T AG_SPKIDAT A, i);
  603  
  604           if  (e != nul l) {
  605                return n ew SPKIDat a(e, this. baseURI);
  606           }
  607           re turn null;
  608       }
  609  
  610       /**
  611        * Met hod itemX5 09Data
  612        *
  613        * @pa ram i
  614        * @re turn the a sked X509D ata elemen t, null if  the index  is too bi g
  615        * @th rows XMLSe curityExce ption
  616        */
  617       public  X509Data  itemX509Da ta(int i)  throws XML SecurityEx ception {
  618           if  (x509Data s != null)  {
  619                return x 509Datas.g et(i);
  620           }
  621           El ement e =
  622                XMLUtils .selectDsN ode(
  623                    this .construct ionElement .getFirstC hild(), Co nstants._T AG_X509DAT A, i);
  624  
  625           if  (e != nul l) {
  626                return n ew X509Dat a(e, this. baseURI);
  627           }
  628           re turn null;
  629       }
  630  
  631       /**
  632        * Met hod itemEn cryptedKey
  633        *
  634        * @pa ram i
  635        * @re turn the a sked Encry ptedKey el ement, nul l if the i ndex is to o big
  636        * @th rows XMLSe curityExce ption
  637        */
  638       public  Encrypted Key itemEn cryptedKey (int i) th rows XMLSe curityExce ption {
  639           if  (encrypte dKeys != n ull) {
  640                return e ncryptedKe ys.get(i);
  641           }
  642           El ement e =
  643                XMLUtils .selectXen cNode(
  644                    this .construct ionElement .getFirstC hild(), En cryptionCo nstants._T AG_ENCRYPT EDKEY, i);
  645  
  646           if  (e != nul l) {
  647                XMLCiphe r cipher =  XMLCipher .getInstan ce();
  648                cipher.i nit(XMLCip her.UNWRAP _MODE, nul l);
  649                return c ipher.load EncryptedK ey(e);
  650           }
  651           re turn null;
  652       }
  653  
  654       /**
  655        * Met hod itemDE REncodedKe yValue
  656        *
  657        * @pa ram i
  658        * @re turn the a sked DEREn codedKeyVa lue elemen t, null if  the index  is too bi g
  659        * @th rows XMLSe curityExce ption
  660        */
  661       public  DEREncode dKeyValue  itemDEREnc odedKeyVal ue(int i)  throws XML SecurityEx ception {
  662           El ement e =
  663                XMLUtils .selectDs1 1Node(
  664                    this .construct ionElement .getFirstC hild(), Co nstants._T AG_DERENCO DEDKEYVALU E, i);
  665  
  666           if  (e != nul l) {
  667                return n ew DEREnco dedKeyValu e(e, this. baseURI);
  668           }
  669           re turn null;
  670       }
  671  
  672       /**
  673        * Met hod itemKe yInfoRefer ence
  674        *
  675        * @pa ram i
  676        * @re turn the a sked KeyIn foReferenc e element,  null if t he index i s too big
  677        * @th rows XMLSe curityExce ption
  678        */
  679       public  KeyInfoRe ference it emKeyInfoR eference(i nt i) thro ws XMLSecu rityExcept ion {
  680           El ement e =
  681                XMLUtils .selectDs1 1Node(
  682                    this .construct ionElement .getFirstC hild(), Co nstants._T AG_KEYINFO REFERENCE,  i);
  683  
  684           if  (e != nul l) {
  685                return n ew KeyInfo Reference( e, this.ba seURI);
  686           }
  687           re turn null;
  688       }
  689  
  690       /**
  691        * Met hod itemUn knownEleme nt
  692        *
  693        * @pa ram i inde x
  694        * @re turn the e lement num ber of the  unknown e lements
  695        */
  696       public  Element i temUnknown Element(in t i) {
  697           No deList nl  = this.con structionE lement.get ChildNodes ();
  698           in t res = 0;
  699  
  700           fo r (int j =  0; j < nl .getLength (); j++) {
  701                Node cur rent = nl. item(j);
  702  
  703                /**
  704                 * $todo $ using th is method,  we don't  see unknow n Elements
  705                 *  from  Signature  NS; revis it
  706                 */
  707                if ((cur rent.getNo deType() = = Node.ELE MENT_NODE)
  708                    && c urrent.get NamespaceU RI().equal s(Constant s.Signatur eSpecNS))  {
  709                    res+ +;
  710  
  711                    if ( res == i)  {
  712                         return (El ement) cur rent;
  713                    }
  714                }
  715           }
  716  
  717           re turn null;
  718       }
  719  
  720       /**
  721        * Met hod isEmpt y
  722        *
  723        * @re turn true  if the ele ment has n o descenda nts.
  724        */
  725       public  boolean i sEmpty() {
  726           re turn this. constructi onElement. getFirstCh ild() == n ull;
  727       }
  728  
  729       /**
  730        * Met hod contai nsKeyName
  731        *
  732        * @re turn If th e KeyInfo  contains a  KeyName n ode
  733        */
  734       public  boolean c ontainsKey Name() {
  735           re turn this. lengthKeyN ame() > 0;
  736       }
  737  
  738       /**
  739        * Met hod contai nsKeyValue
  740        *
  741        * @re turn If th e KeyInfo  contains a  KeyValue  node
  742        */
  743       public  boolean c ontainsKey Value() {
  744           re turn this. lengthKeyV alue() > 0 ;
  745       }
  746  
  747       /**
  748        * Met hod contai nsMgmtData
  749        *
  750        * @re turn If th e KeyInfo  contains a  MgmtData  node
  751        */
  752       public  boolean c ontainsMgm tData() {
  753           re turn this. lengthMgmt Data() > 0 ;
  754       }
  755  
  756       /**
  757        * Met hod contai nsPGPData
  758        *
  759        * @re turn If th e KeyInfo  contains a  PGPData n ode
  760        */
  761       public  boolean c ontainsPGP Data() {
  762           re turn this. lengthPGPD ata() > 0;
  763       }
  764  
  765       /**
  766        * Met hod contai nsRetrieva lMethod
  767        *
  768        * @re turn If th e KeyInfo  contains a  Retrieval Method nod e
  769        */
  770       public  boolean c ontainsRet rievalMeth od() {
  771           re turn this. lengthRetr ievalMetho d() > 0;
  772       }
  773  
  774       /**
  775        * Met hod contai nsSPKIData
  776        *
  777        * @re turn If th e KeyInfo  contains a  SPKIData  node
  778        */
  779       public  boolean c ontainsSPK IData() {
  780           re turn this. lengthSPKI Data() > 0 ;
  781       }
  782  
  783       /**
  784        * Met hod contai nsUnknownE lement
  785        *
  786        * @re turn If th e KeyInfo  contains a  UnknownEl ement node
  787        */
  788       public  boolean c ontainsUnk nownElemen t() {
  789           re turn this. lengthUnkn ownElement () > 0;
  790       }
  791  
  792       /**
  793        * Met hod contai nsX509Data
  794        *
  795        * @re turn If th e KeyInfo  contains a  X509Data  node
  796        */
  797       public  boolean c ontainsX50 9Data() {
  798           re turn this. lengthX509 Data() > 0 ;
  799       }
  800  
  801       /**
  802        * Met hod contai nsDEREncod edKeyValue
  803        *
  804        * @re turn If th e KeyInfo  contains a  DEREncode dKeyValue  node
  805        */
  806       public  boolean c ontainsDER EncodedKey Value() {
  807           re turn this. lengthDERE ncodedKeyV alue() > 0 ;
  808       }
  809  
  810       /**
  811        * Met hod contai nsKeyInfoR eference
  812        *
  813        * @re turn If th e KeyInfo  contains a  KeyInfoRe ference no de
  814        */
  815       public  boolean c ontainsKey InfoRefere nce() {
  816           re turn this. lengthKeyI nfoReferen ce() > 0;
  817       }
  818  
  819       /**
  820        * Thi s method r eturns the  public ke y.
  821        *
  822        * @re turn If th e KeyInfo  contains a  PublicKey  node
  823        * @th rows KeyRe solverExce ption
  824        */
  825       public  PublicKey  getPublic Key() thro ws KeyReso lverExcept ion {
  826           Pu blicKey pk  = this.ge tPublicKey FromIntern alResolver s();
  827  
  828           if  (pk != nu ll) {
  829                if (log. isLoggable (java.util .logging.L evel.FINE) ) {
  830                    log. log(java.u til.loggin g.Level.FI NE, "I cou ld find a  key using  the per-Ke yInfo key  resolvers" );
  831                }
  832  
  833                return p k;
  834           }
  835           if  (log.isLo ggable(jav a.util.log ging.Level .FINE)) {
  836                log.log( java.util. logging.Le vel.FINE,  "I couldn' t find a k ey using t he per-Key Info key r esolvers") ;
  837           }
  838  
  839           pk  = this.ge tPublicKey FromStatic Resolvers( );
  840  
  841           if  (pk != nu ll) {
  842                if (log. isLoggable (java.util .logging.L evel.FINE) ) {
  843                    log. log(java.u til.loggin g.Level.FI NE, "I cou ld find a  key using  the system -wide key  resolvers" );
  844                }
  845  
  846                return p k;
  847           }
  848           if  (log.isLo ggable(jav a.util.log ging.Level .FINE)) {
  849                log.log( java.util. logging.Le vel.FINE,  "I couldn' t find a k ey using t he system- wide key r esolvers") ;
  850           }
  851  
  852           re turn null;
  853       }
  854  
  855       /**
  856        * Sea rches the  library wi de KeyReso lvers for  public key s
  857        *
  858        * @re turn The p ublic key  contained  in this No de.
  859        * @th rows KeyRe solverExce ption
  860        */
  861       Public Key getPub licKeyFrom StaticReso lvers() th rows KeyRe solverExce ption {
  862           It erator<Key ResolverSp i> it = Ke yResolver. iterator() ;
  863           wh ile (it.ha sNext()) {
  864                KeyResol verSpi key Resolver =  it.next() ;
  865                keyResol ver.setSec ureValidat ion(secure Validation );
  866                Node cur rentChild  = this.con structionE lement.get FirstChild ();
  867                String u ri = this. getBaseURI ();
  868                while (c urrentChil d != null)  {
  869                    if ( currentChi ld.getNode Type() ==  Node.ELEME NT_NODE) {
  870                         for (Stora geResolver  storage :  storageRe solvers) {
  871                             Public Key pk =
  872                                 ke yResolver. engineLook upAndResol vePublicKe y(
  873                                      (Element ) currentC hild, uri,  storage
  874                                 );
  875  
  876                             if (pk  != null)  {
  877                                 re turn pk;
  878                             }
  879                         }
  880                    }
  881                    curr entChild =  currentCh ild.getNex tSibling() ;
  882                }
  883           }
  884           re turn null;
  885       }
  886  
  887       /**
  888        * Sea rches the  per-KeyInf o KeyResol vers for p ublic keys
  889        *
  890        * @re turn The p ublic key  contained  in this No de.
  891        * @th rows KeyRe solverExce ption
  892        */
  893       Public Key getPub licKeyFrom InternalRe solvers()  throws Key ResolverEx ception {
  894           fo r (KeyReso lverSpi ke yResolver  : internal KeyResolve rs) {
  895                if (log. isLoggable (java.util .logging.L evel.FINE) ) {
  896                    log. log(java.u til.loggin g.Level.FI NE, "Try "  + keyReso lver.getCl ass().getN ame());
  897                }
  898                keyResol ver.setSec ureValidat ion(secure Validation );
  899                Node cur rentChild  = this.con structionE lement.get FirstChild ();
  900                String u ri = this. getBaseURI ();
  901                while (c urrentChil d != null)       {
  902                    if ( currentChi ld.getNode Type() ==  Node.ELEME NT_NODE) {
  903                         for (Stora geResolver  storage :  storageRe solvers) {
  904                             Public Key pk =
  905                                 ke yResolver. engineLook upAndResol vePublicKe y(
  906                                      (Element ) currentC hild, uri,  storage
  907                                 );
  908  
  909                             if (pk  != null)  {
  910                                 re turn pk;
  911                             }
  912                         }
  913                    }
  914                    curr entChild =  currentCh ild.getNex tSibling() ;
  915                }
  916           }
  917  
  918           re turn null;
  919       }
  920  
  921       /**
  922        * Met hod getX50 9Certifica te
  923        *
  924        * @re turn The c ertificate  contained  in this K eyInfo
  925        * @th rows KeyRe solverExce ption
  926        */
  927       public  X509Certi ficate get X509Certif icate() th rows KeyRe solverExce ption {
  928           //  First sea rch using  the indivi dual resol vers from  the user
  929           X5 09Certific ate cert =  this.getX 509Certifi cateFromIn ternalReso lvers();
  930  
  931           if  (cert !=  null) {
  932                if (log. isLoggable (java.util .logging.L evel.FINE) ) {
  933                    log. log(java.u til.loggin g.Level.FI NE, "I cou ld find a  X509Certif icate usin g the per- KeyInfo ke y resolver s");
  934                }
  935  
  936                return c ert;
  937           }
  938           if  (log.isLo ggable(jav a.util.log ging.Level .FINE)) {
  939                log.log( java.util. logging.Le vel.FINE,  "I couldn' t find a X 509Certifi cate using  the per-K eyInfo key  resolvers ");
  940           }
  941  
  942           //  Then use  the system -wide Reso lvers
  943           ce rt = this. getX509Cer tificateFr omStaticRe solvers();
  944  
  945           if  (cert !=  null) {
  946                if (log. isLoggable (java.util .logging.L evel.FINE) ) {
  947                    log. log(java.u til.loggin g.Level.FI NE, "I cou ld find a  X509Certif icate usin g the syst em-wide ke y resolver s");
  948                }
  949  
  950                return c ert;
  951           }
  952           if  (log.isLo ggable(jav a.util.log ging.Level .FINE)) {
  953                log.log( java.util. logging.Le vel.FINE,  "I couldn' t find a X 509Certifi cate using  the syste m-wide key  resolvers ");
  954           }
  955  
  956           re turn null;
  957       }
  958  
  959       /**
  960        * Thi s method u ses each S ystem-wide  {@link Ke yResolver}  to search  the
  961        * chi ld element s. Each co mbination  of {@link  KeyResolve r} and chi ld element
  962        * is  checked ag ainst all  {@link Sto rageResolv er}s.
  963        *
  964        * @re turn The c ertificate  contained  in this K eyInfo
  965        * @th rows KeyRe solverExce ption
  966        */
  967       X509Ce rtificate  getX509Cer tificateFr omStaticRe solvers()
  968           th rows KeyRe solverExce ption {
  969           if  (log.isLo ggable(jav a.util.log ging.Level .FINE)) {
  970                log.log( java.util. logging.Le vel.FINE,
  971                    "Sta rt getX509 Certificat eFromStati cResolvers () with "  + KeyResol ver.length ()
  972                    + "  resolvers"
  973                );
  974           }
  975           St ring uri =  this.getB aseURI();
  976           It erator<Key ResolverSp i> it = Ke yResolver. iterator() ;
  977           wh ile (it.ha sNext()) {
  978                KeyResol verSpi key Resolver =  it.next() ;
  979                keyResol ver.setSec ureValidat ion(secure Validation );
  980                X509Cert ificate ce rt = apply CurrentRes olver(uri,  keyResolv er);
  981                if (cert  != null)  {
  982                    retu rn cert;
  983                }
  984           }
  985           re turn null;
  986       }
  987  
  988       privat e X509Cert ificate ap plyCurrent Resolver(
  989           St ring uri,  KeyResolve rSpi keyRe solver
  990       ) thro ws KeyReso lverExcept ion {
  991           No de current Child = th is.constru ctionEleme nt.getFirs tChild();
  992           wh ile (curre ntChild !=  null)       {
  993                if (curr entChild.g etNodeType () == Node .ELEMENT_N ODE) {
  994                    for  (StorageRe solver sto rage : sto rageResolv ers) {
  995                         X509Certif icate cert  =
  996                             keyRes olver.engi neLookupRe solveX509C ertificate (
  997                                 (E lement) cu rrentChild , uri, sto rage
  998                             );
  999  
  1000                         if (cert ! = null) {
  1001                             return  cert;
  1002                         }
  1003                    }
  1004                }
  1005                currentC hild = cur rentChild. getNextSib ling();
  1006           }
  1007           re turn null;
  1008       }
  1009  
  1010       /**
  1011        * Met hod getX50 9Certifica teFromInte rnalResolv ers
  1012        *
  1013        * @re turn The c ertificate  contained  in this K eyInfo
  1014        * @th rows KeyRe solverExce ption
  1015        */
  1016       X509Ce rtificate  getX509Cer tificateFr omInternal Resolvers( )
  1017           th rows KeyRe solverExce ption {
  1018           if  (log.isLo ggable(jav a.util.log ging.Level .FINE)) {
  1019                log.log( java.util. logging.Le vel.FINE,
  1020                    "Sta rt getX509 Certificat eFromInter nalResolve rs() with  "
  1021                    + th is.lengthI nternalKey Resolver()  + " resol vers"
  1022                );
  1023           }
  1024           St ring uri =  this.getB aseURI();
  1025           fo r (KeyReso lverSpi ke yResolver  : internal KeyResolve rs) {
  1026                if (log. isLoggable (java.util .logging.L evel.FINE) ) {
  1027                    log. log(java.u til.loggin g.Level.FI NE, "Try "  + keyReso lver.getCl ass().getN ame());
  1028                }
  1029                keyResol ver.setSec ureValidat ion(secure Validation );
  1030                X509Cert ificate ce rt = apply CurrentRes olver(uri,  keyResolv er);
  1031                if (cert  != null)  {
  1032                    retu rn cert;
  1033                }
  1034           }
  1035  
  1036           re turn null;
  1037       }
  1038  
  1039       /**
  1040          * This met hod return s a  PW        (symmetric ) key. Thi s is for X ML Encrypt ion.
  1041          * @return  the  PW        key contai ned in thi s KeyInfo
  1042        * @th rows KeyRe solverExce ption
  1043        */
  1044       public  SecretKey  getSecret Key() thro ws KeyReso lverExcept ion {
  1045           Se cretKey sk  = this.ge tSecretKey FromIntern alResolver s();
  1046  
  1047           if  (sk != nu ll) {
  1048                if (log. isLoggable (java.util .logging.L evel.FINE) ) {
  1049                      log.log(ja va.util.lo gging.Leve l.FINE, "I  could fin d a  PW        key using  the per-Ke yInfo key  resolvers" );
  1050                }
  1051  
  1052                return s k;
  1053           }
  1054           if  (log.isLo ggable(jav a.util.log ging.Level .FINE)) {
  1055                  log.log(ja va.util.lo gging.Leve l.FINE, "I  couldn't  find a  PW        key using  the per-Ke yInfo key  resolvers" );
  1056           }
  1057  
  1058           sk  = this.ge tSecretKey FromStatic Resolvers( );
  1059  
  1060           if  (sk != nu ll) {
  1061                if (log. isLoggable (java.util .logging.L evel.FINE) ) {
  1062                      log.log(ja va.util.lo gging.Leve l.FINE, "I  could fin d a  PW        key using  the system -wide key  resolvers" );
  1063                }
  1064  
  1065                return s k;
  1066           }
  1067           if  (log.isLo ggable(jav a.util.log ging.Level .FINE)) {
  1068                  log.log(ja va.util.lo gging.Leve l.FINE, "I  couldn't  find a  PW        key using  the system -wide key  resolvers" );
  1069           }
  1070  
  1071           re turn null;
  1072       }
  1073  
  1074       /**
  1075        * Sea rches the  library wi de KeyReso lvers for  Secret key s
  1076        *
  1077          * @return  the  PW        key contai ned in thi s KeyInfo
  1078        * @th rows KeyRe solverExce ption
  1079        */
  1080       Secret Key getSec retKeyFrom StaticReso lvers() th rows KeyRe solverExce ption {
  1081           It erator<Key ResolverSp i> it = Ke yResolver. iterator() ;
  1082           wh ile (it.ha sNext()) {
  1083                KeyResol verSpi key Resolver =  it.next() ;
  1084                keyResol ver.setSec ureValidat ion(secure Validation );
  1085  
  1086                Node cur rentChild  = this.con structionE lement.get FirstChild ();
  1087                String u ri = this. getBaseURI ();
  1088                while (c urrentChil d != null)       {
  1089                    if ( currentChi ld.getNode Type() ==  Node.ELEME NT_NODE) {
  1090                         for (Stora geResolver  storage :  storageRe solvers) {
  1091                             Secret Key sk =
  1092                                 ke yResolver. engineLook upAndResol veSecretKe y(
  1093                                      (Element ) currentC hild, uri,  storage
  1094                                 );
  1095  
  1096                             if (sk  != null)  {
  1097                                 re turn sk;
  1098                             }
  1099                         }
  1100                    }
  1101                    curr entChild =  currentCh ild.getNex tSibling() ;
  1102                }
  1103           }
  1104           re turn null;
  1105       }
  1106  
  1107       /**
  1108          * Searches  the per-K eyInfo Key Resolvers  for  PW        keys
  1109        *
  1110          * @return  the  PW        key contai ned in thi s KeyInfo
  1111        * @th rows KeyRe solverExce ption
  1112        */
  1113  
  1114       Secret Key getSec retKeyFrom InternalRe solvers()  throws Key ResolverEx ception {
  1115           fo r (KeyReso lverSpi ke yResolver  : internal KeyResolve rs) {
  1116                if (log. isLoggable (java.util .logging.L evel.FINE) ) {
  1117                    log. log(java.u til.loggin g.Level.FI NE, "Try "  + keyReso lver.getCl ass().getN ame());
  1118                }
  1119                keyResol ver.setSec ureValidat ion(secure Validation );
  1120                Node cur rentChild  = this.con structionE lement.get FirstChild ();
  1121                String u ri = this. getBaseURI ();
  1122                while (c urrentChil d != null)       {
  1123                    if ( currentChi ld.getNode Type() ==  Node.ELEME NT_NODE) {
  1124                         for (Stora geResolver  storage :  storageRe solvers) {
  1125                             Secret Key sk =
  1126                                 ke yResolver. engineLook upAndResol veSecretKe y(
  1127                                      (Element ) currentC hild, uri,  storage
  1128                                 );
  1129  
  1130                             if (sk  != null)  {
  1131                                 re turn sk;
  1132                             }
  1133                         }
  1134                    }
  1135                    curr entChild =  currentCh ild.getNex tSibling() ;
  1136                }
  1137           }
  1138  
  1139           re turn null;
  1140       }
  1141  
  1142       /**
  1143        * Thi s method r eturns a p rivate key . This is  for Key Tr ansport in  XML Encry ption.
  1144        * @re turn the p rivate key  contained  in this K eyInfo
  1145        * @th rows KeyRe solverExce ption
  1146        */
  1147       public  PrivateKe y getPriva teKey() th rows KeyRe solverExce ption {
  1148           Pr ivateKey p k = this.g etPrivateK eyFromInte rnalResolv ers();
  1149  
  1150           if  (pk != nu ll) {
  1151                if (log. isLoggable (java.util .logging.L evel.FINE) ) {
  1152                    log. log(java.u til.loggin g.Level.FI NE, "I cou ld find a  private ke y using th e per-KeyI nfo key re solvers");
  1153                }
  1154                return p k;
  1155           }
  1156           if  (log.isLo ggable(jav a.util.log ging.Level .FINE)) {
  1157                  log.log(ja va.util.lo gging.Leve l.FINE, "I  couldn't  find a  PW        key using  the per-Ke yInfo key  resolvers" );
  1158           }
  1159  
  1160           pk  = this.ge tPrivateKe yFromStati cResolvers ();
  1161           if  (pk != nu ll) {
  1162                if (log. isLoggable (java.util .logging.L evel.FINE) ) {
  1163                    log. log(java.u til.loggin g.Level.FI NE, "I cou ld find a  private ke y using th e system-w ide key re solvers");
  1164                }
  1165                return p k;
  1166           }
  1167           if  (log.isLo ggable(jav a.util.log ging.Level .FINE)) {
  1168                log.log( java.util. logging.Le vel.FINE,  "I couldn' t find a p rivate key  using the  system-wi de key res olvers");
  1169           }
  1170  
  1171           re turn null;
  1172       }
  1173  
  1174       /**
  1175        * Sea rches the  library wi de KeyReso lvers for  Private ke ys
  1176        *
  1177        * @re turn the p rivate key  contained  in this K eyInfo
  1178        * @th rows KeyRe solverExce ption
  1179        */
  1180       Privat eKey getPr ivateKeyFr omStaticRe solvers()  throws Key ResolverEx ception {
  1181           It erator<Key ResolverSp i> it = Ke yResolver. iterator() ;
  1182           wh ile (it.ha sNext()) {
  1183                KeyResol verSpi key Resolver =  it.next() ;
  1184                keyResol ver.setSec ureValidat ion(secure Validation );
  1185  
  1186                Node cur rentChild  = this.con structionE lement.get FirstChild ();
  1187                String u ri = this. getBaseURI ();
  1188                while (c urrentChil d != null)       {
  1189                    if ( currentChi ld.getNode Type() ==  Node.ELEME NT_NODE) {
  1190                         // not usi ng Storage Resolvers  at the mom ent
  1191                         // since t hey cannot  return pr ivate keys
  1192                         PrivateKey  pk =
  1193                             keyRes olver.engi neLookupAn dResolvePr ivateKey(
  1194                                 (E lement) cu rrentChild , uri, nul l
  1195                             );
  1196  
  1197                         if (pk !=  null) {
  1198                             return  pk;
  1199                         }
  1200                    }
  1201                    curr entChild =  currentCh ild.getNex tSibling() ;
  1202                }
  1203           }
  1204           re turn null;
  1205       }
  1206  
  1207       /**
  1208        * Sea rches the  per-KeyInf o KeyResol vers for p rivate key s
  1209        *
  1210        * @re turn the p rivate key  contained  in this K eyInfo
  1211        * @th rows KeyRe solverExce ption
  1212        */
  1213       Privat eKey getPr ivateKeyFr omInternal Resolvers( ) throws K eyResolver Exception  {
  1214           fo r (KeyReso lverSpi ke yResolver  : internal KeyResolve rs) {
  1215                if (log. isLoggable (java.util .logging.L evel.FINE) ) {
  1216                    log. log(java.u til.loggin g.Level.FI NE, "Try "  + keyReso lver.getCl ass().getN ame());
  1217                }
  1218                keyResol ver.setSec ureValidat ion(secure Validation );
  1219                Node cur rentChild  = this.con structionE lement.get FirstChild ();
  1220                String u ri = this. getBaseURI ();
  1221                while (c urrentChil d != null)  {
  1222                    if ( currentChi ld.getNode Type() ==  Node.ELEME NT_NODE) {
  1223                         // not usi ng Storage Resolvers  at the mom ent
  1224                         // since t hey cannot  return pr ivate keys
  1225                         PrivateKey  pk =
  1226                             keyRes olver.engi neLookupAn dResolvePr ivateKey(
  1227                                 (E lement) cu rrentChild , uri, nul l
  1228                             );
  1229  
  1230                         if (pk !=  null) {
  1231                             return  pk;
  1232                         }
  1233                    }
  1234                    curr entChild =  currentCh ild.getNex tSibling() ;
  1235                }
  1236           }
  1237  
  1238           re turn null;
  1239       }
  1240  
  1241       /**
  1242        * Thi s method i s used to  add a cust om {@link  KeyResolve rSpi} to a  KeyInfo
  1243        * obj ect.
  1244        *
  1245        * @pa ram realKe yResolver
  1246        */
  1247       public  void regi sterIntern alKeyResol ver(KeyRes olverSpi r ealKeyReso lver) {
  1248           th is.interna lKeyResolv ers.add(re alKeyResol ver);
  1249       }
  1250  
  1251       /**
  1252        * Met hod length InternalKe yResolver
  1253        * @re turn the l ength of t he key
  1254        */
  1255       int le ngthIntern alKeyResol ver() {
  1256           re turn this. internalKe yResolvers .size();
  1257       }
  1258  
  1259       /**
  1260        * Met hod itemIn ternalKeyR esolver
  1261        *
  1262        * @pa ram i the  index
  1263        * @re turn the K eyResolver Spi for th e index.
  1264        */
  1265       KeyRes olverSpi i temInterna lKeyResolv er(int i)  {
  1266           re turn this. internalKe yResolvers .get(i);
  1267       }
  1268  
  1269       /**
  1270        * Met hod addSto rageResolv er
  1271        *
  1272        * @pa ram storag eResolver
  1273        */
  1274       public  void addS torageReso lver(Stora geResolver  storageRe solver) {
  1275           if  (storageR esolvers = = nullList ) {
  1276                // Repla ce the def ault null  StorageRes olver
  1277                storageR esolvers =  new Array List<Stora geResolver >();
  1278           }
  1279           th is.storage Resolvers. add(storag eResolver) ;
  1280       }
  1281  
  1282  
  1283       /** @i nheritDoc  */
  1284       public  String ge tBaseLocal Name() {
  1285           re turn Const ants._TAG_ KEYINFO;
  1286       }
  1287   }