/** * Method isEmpty * * @return true if the element has no descendants. */ public boolean isEmpty() { return getFirstChild() == null; }
private X509Certificate applyCurrentResolver( String uri, KeyResolverSpi keyResolver ) throws KeyResolverException { Node currentChild = getFirstChild(); while (currentChild != null) { if (currentChild.getNodeType() == Node.ELEMENT_NODE) { for (StorageResolver storage : storageResolvers) { X509Certificate cert = keyResolver.engineLookupResolveX509Certificate( (Element) currentChild, uri, storage ); if (cert != null) { return cert; } } } currentChild = currentChild.getNextSibling(); } return null; }
/** * Method itemKeyName * * @param i * @return the asked KeyName element, null if the index is too big * @throws XMLSecurityException */ public KeyName itemKeyName(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( getFirstChild(), Constants._TAG_KEYNAME, i); if (e != null) { return new KeyName(e, this.baseURI); } return null; }
/** * Method itemDEREncodedKeyValue * * @param i * @return the asked DEREncodedKeyValue element, null if the index is too big * @throws XMLSecurityException */ public DEREncodedKeyValue itemDEREncodedKeyValue(int i) throws XMLSecurityException { Element e = XMLUtils.selectDs11Node( getFirstChild(), Constants._TAG_DERENCODEDKEYVALUE, i); if (e != null) { return new DEREncodedKeyValue(e, this.baseURI); } return null; }
/** * Method itemX509Data * * @param i * @return the asked X509Data element, null if the index is too big * @throws XMLSecurityException */ public X509Data itemX509Data(int i) throws XMLSecurityException { if (x509Datas != null) { return x509Datas.get(i); } Element e = XMLUtils.selectDsNode( getFirstChild(), Constants._TAG_X509DATA, i); if (e != null) { return new X509Data(e, this.baseURI); } return null; }
/** * Method itemMgmtData * * @param i * @return the asked MgmtData element, null if the index is too big * @throws XMLSecurityException */ public MgmtData itemMgmtData(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( getFirstChild(), Constants._TAG_MGMTDATA, i); if (e != null) { return new MgmtData(e, this.baseURI); } return null; }
/** * Method itemRetrievalMethod * * @param i *@return the asked RetrievalMethod element, null if the index is too big * @throws XMLSecurityException */ public RetrievalMethod itemRetrievalMethod(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( getFirstChild(), Constants._TAG_RETRIEVALMETHOD, i); if (e != null) { return new RetrievalMethod(e, this.baseURI); } return null; }
/** * Method itemKeyValue * * @param i * @return the asked KeyValue element, null if the index is too big * @throws XMLSecurityException */ public KeyValue itemKeyValue(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( getFirstChild(), Constants._TAG_KEYVALUE, i); if (e != null) { return new KeyValue(e, this.baseURI); } return null; }
/** * Method itemSPKIData * * @param i * @return the asked SPKIData element, null if the index is too big * @throws XMLSecurityException */ public SPKIData itemSPKIData(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( getFirstChild(), Constants._TAG_SPKIDATA, i); if (e != null) { return new SPKIData(e, this.baseURI); } return null; }
/** * Method itemKeyInfoReference * * @param i * @return the asked KeyInfoReference element, null if the index is too big * @throws XMLSecurityException */ public KeyInfoReference itemKeyInfoReference(int i) throws XMLSecurityException { Element e = XMLUtils.selectDs11Node( getFirstChild(), Constants._TAG_KEYINFOREFERENCE, i); if (e != null) { return new KeyInfoReference(e, this.baseURI); } return null; }
/** * Method itemPGPData * * @param i * @return the asked PGPData element, null if the index is too big * @throws XMLSecurityException */ public PGPData itemPGPData(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( getFirstChild(), Constants._TAG_PGPDATA, i); if (e != null) { return new PGPData(e, this.baseURI); } return null; }
/** * Searches the per-KeyInfo KeyResolvers for private keys * * @return the private key contained in this KeyInfo * @throws KeyResolverException */ PrivateKey getPrivateKeyFromInternalResolvers() throws KeyResolverException { for (KeyResolverSpi keyResolver : internalKeyResolvers) { LOG.debug("Try {}", keyResolver.getClass().getName()); keyResolver.setSecureValidation(secureValidation); Node currentChild = getFirstChild(); String uri = this.getBaseURI(); while (currentChild != null) { if (currentChild.getNodeType() == Node.ELEMENT_NODE) { // not using StorageResolvers at the moment // since they cannot return private keys PrivateKey pk = keyResolver.engineLookupAndResolvePrivateKey( (Element) currentChild, uri, null ); if (pk != null) { return pk; } } currentChild = currentChild.getNextSibling(); } } return null; }
/** * Searches the per-KeyInfo KeyResolvers for public keys * * @return The public key contained in this Node. * @throws KeyResolverException */ PublicKey getPublicKeyFromInternalResolvers() throws KeyResolverException { for (KeyResolverSpi keyResolver : internalKeyResolvers) { LOG.debug("Try {}", keyResolver.getClass().getName()); keyResolver.setSecureValidation(secureValidation); Node currentChild = getFirstChild(); String uri = this.getBaseURI(); while (currentChild != null) { if (currentChild.getNodeType() == Node.ELEMENT_NODE) { for (StorageResolver storage : storageResolvers) { PublicKey pk = keyResolver.engineLookupAndResolvePublicKey( (Element) currentChild, uri, storage ); if (pk != null) { return pk; } } } currentChild = currentChild.getNextSibling(); } } return null; }
/** * Searches the per-KeyInfo KeyResolvers for secret keys * * @return the secret key contained in this KeyInfo * @throws KeyResolverException */ SecretKey getSecretKeyFromInternalResolvers() throws KeyResolverException { for (KeyResolverSpi keyResolver : internalKeyResolvers) { LOG.debug("Try {}", keyResolver.getClass().getName()); keyResolver.setSecureValidation(secureValidation); Node currentChild = getFirstChild(); String uri = this.getBaseURI(); while (currentChild != null) { if (currentChild.getNodeType() == Node.ELEMENT_NODE) { for (StorageResolver storage : storageResolvers) { SecretKey sk = keyResolver.engineLookupAndResolveSecretKey( (Element) currentChild, uri, storage ); if (sk != null) { return sk; } } } currentChild = currentChild.getNextSibling(); } } return null; }
/** * Searches the library wide KeyResolvers for Secret keys * * @return the secret key contained in this KeyInfo * @throws KeyResolverException */ SecretKey getSecretKeyFromStaticResolvers() throws KeyResolverException { Iterator<KeyResolverSpi> it = KeyResolver.iterator(); while (it.hasNext()) { KeyResolverSpi keyResolver = it.next(); keyResolver.setSecureValidation(secureValidation); Node currentChild = getFirstChild(); String uri = this.getBaseURI(); while (currentChild != null) { if (currentChild.getNodeType() == Node.ELEMENT_NODE) { for (StorageResolver storage : storageResolvers) { SecretKey sk = keyResolver.engineLookupAndResolveSecretKey( (Element) currentChild, uri, storage ); if (sk != null) { return sk; } } } currentChild = currentChild.getNextSibling(); } } return null; }
/** * Searches the library wide KeyResolvers for Private keys * * @return the private key contained in this KeyInfo * @throws KeyResolverException */ PrivateKey getPrivateKeyFromStaticResolvers() throws KeyResolverException { Iterator<KeyResolverSpi> it = KeyResolver.iterator(); while (it.hasNext()) { KeyResolverSpi keyResolver = it.next(); keyResolver.setSecureValidation(secureValidation); Node currentChild = getFirstChild(); String uri = this.getBaseURI(); while (currentChild != null) { if (currentChild.getNodeType() == Node.ELEMENT_NODE) { // not using StorageResolvers at the moment // since they cannot return private keys PrivateKey pk = keyResolver.engineLookupAndResolvePrivateKey( (Element) currentChild, uri, null ); if (pk != null) { return pk; } } currentChild = currentChild.getNextSibling(); } } return null; }
/** * Searches the library wide KeyResolvers for public keys * * @return The public key contained in this Node. * @throws KeyResolverException */ PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException { Iterator<KeyResolverSpi> it = KeyResolver.iterator(); while (it.hasNext()) { KeyResolverSpi keyResolver = it.next(); keyResolver.setSecureValidation(secureValidation); Node currentChild = getFirstChild(); String uri = this.getBaseURI(); while (currentChild != null) { if (currentChild.getNodeType() == Node.ELEMENT_NODE) { for (StorageResolver storage : storageResolvers) { PublicKey pk = keyResolver.engineLookupAndResolvePublicKey( (Element) currentChild, uri, storage ); if (pk != null) { return pk; } } } currentChild = currentChild.getNextSibling(); } } return null; }
/** * Method itemEncryptedKey * * @param i * @return the asked EncryptedKey element, null if the index is too big * @throws XMLSecurityException */ public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException { if (encryptedKeys != null) { return encryptedKeys.get(i); } Element e = XMLUtils.selectXencNode( getFirstChild(), EncryptionConstants._TAG_ENCRYPTEDKEY, i); if (e != null) { XMLCipher cipher = XMLCipher.getInstance(); cipher.init(XMLCipher.UNWRAP_MODE, null); return cipher.loadEncryptedKey(e); } return null; }