1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.saml2.encryption;
18
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import org.opensaml.saml2.core.EncryptedElementType;
23 import org.opensaml.xml.encryption.AbstractEncryptedKeyResolver;
24 import org.opensaml.xml.encryption.EncryptedData;
25 import org.opensaml.xml.encryption.EncryptedKey;
26 import org.opensaml.xml.encryption.EncryptedKeyResolver;
27
28
29
30
31
32
33 public class EncryptedElementTypeEncryptedKeyResolver extends AbstractEncryptedKeyResolver {
34
35
36 public Iterable<EncryptedKey> resolve(EncryptedData encryptedData) {
37 List<EncryptedKey> resolvedEncKeys = new ArrayList<EncryptedKey>();
38
39 if (! (encryptedData.getParent() instanceof EncryptedElementType) ) {
40 return resolvedEncKeys;
41 }
42
43 EncryptedElementType encElementType = (EncryptedElementType) encryptedData.getParent();
44
45 for (EncryptedKey encKey : encElementType.getEncryptedKeys()) {
46 if (matchRecipient(encKey.getRecipient())) {
47 resolvedEncKeys.add(encKey);
48 }
49 }
50
51 return resolvedEncKeys;
52 }
53 }