1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.saml1.binding.artifact;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.opensaml.xml.util.Base64;
23
24
25
26
27 public class SAML1ArtifactBuilderFactory {
28
29
30 private Map<String, SAML1ArtifactBuilder> artifactBuilders;
31
32
33 public SAML1ArtifactBuilderFactory() {
34 artifactBuilders = new HashMap<String, SAML1ArtifactBuilder>(2);
35 artifactBuilders.put(new String(SAML1ArtifactType0001.TYPE_CODE), new SAML1ArtifactType0001Builder());
36 artifactBuilders.put(new String(SAML1ArtifactType0002.TYPE_CODE), new SAML1ArtifactType0002Builder());
37 }
38
39
40
41
42
43
44 public Map<String, SAML1ArtifactBuilder> getArtifactBuilders() {
45 return artifactBuilders;
46 }
47
48
49
50
51
52
53
54
55 public SAML1ArtifactBuilder getArtifactBuilder(byte[] type) {
56 return artifactBuilders.get(new String(type));
57 }
58
59
60
61
62
63
64
65
66 public AbstractSAML1Artifact buildArtifact(String base64Artifact){
67 return buildArtifact(Base64.decode(base64Artifact));
68 }
69
70
71
72
73
74
75
76
77 public AbstractSAML1Artifact buildArtifact(byte[] artifact) {
78 if(artifact == null){
79 return null;
80 }
81
82 byte[] type = new byte[2];
83 type[0] = artifact[0];
84 type[1] = artifact[1];
85
86 SAML1ArtifactBuilder<?> artifactBuilder = getArtifactBuilder(type);
87 return artifactBuilder.buildArtifact(artifact);
88 }
89 }