1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.saml1.core.impl;
18
19 import java.util.ArrayList;
20 import java.util.Collections;
21 import java.util.List;
22
23 import javax.xml.namespace.QName;
24
25 import org.joda.time.DateTime;
26 import org.opensaml.common.SAMLVersion;
27 import org.opensaml.common.impl.AbstractSignableSAMLObject;
28 import org.opensaml.common.xml.SAMLConstants;
29 import org.opensaml.saml1.core.Advice;
30 import org.opensaml.saml1.core.Assertion;
31 import org.opensaml.saml1.core.AttributeStatement;
32 import org.opensaml.saml1.core.AuthenticationStatement;
33 import org.opensaml.saml1.core.AuthorizationDecisionStatement;
34 import org.opensaml.saml1.core.Conditions;
35 import org.opensaml.saml1.core.Statement;
36 import org.opensaml.saml1.core.SubjectStatement;
37 import org.opensaml.xml.XMLObject;
38 import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
39
40
41
42
43 public class AssertionImpl extends AbstractSignableSAMLObject implements Assertion {
44
45
46 private String id;
47
48
49 private SAMLVersion version;
50
51
52 private String issuer;
53
54
55 private DateTime issueInstant;
56
57
58 private Conditions conditions;
59
60
61 private Advice advice;
62
63
64 private final IndexedXMLObjectChildrenList<Statement> statements;
65
66
67
68
69
70
71
72
73 protected AssertionImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
74 super(namespaceURI, elementLocalName, namespacePrefix);
75 statements = new IndexedXMLObjectChildrenList<Statement>(this);
76 version = SAMLVersion.VERSION_11;
77 }
78
79
80 public int getMajorVersion(){
81 return version.getMajorVersion();
82 }
83
84
85 public int getMinorVersion() {
86 return version.getMinorVersion();
87 }
88
89
90 public void setVersion(SAMLVersion newVersion){
91 version = prepareForAssignment(version, newVersion);
92 }
93
94
95 public String getID() {
96 return id;
97 }
98
99
100 public void setID(String id) {
101 String oldID = this.id;
102 this.id = prepareForAssignment(this.id, id);
103 registerOwnID(oldID, this.id);
104 }
105
106
107 public String getIssuer() {
108 return this.issuer;
109 }
110
111
112 public void setIssuer(String issuer) {
113 this.issuer = prepareForAssignment(this.issuer, issuer);
114 }
115
116
117 public DateTime getIssueInstant() {
118 return this.issueInstant;
119 }
120
121
122 public void setIssueInstant(DateTime issueInstant) {
123 this.issueInstant = prepareForAssignment(this.issueInstant, issueInstant);
124 }
125
126
127 public Conditions getConditions() {
128 return conditions;
129 }
130
131
132 public void setConditions(Conditions conditions) throws IllegalArgumentException {
133 this.conditions = prepareForAssignment(this.conditions, conditions);
134 }
135
136
137 public Advice getAdvice() {
138 return advice;
139 }
140
141
142 public void setAdvice(Advice advice) throws IllegalArgumentException {
143 this.advice = prepareForAssignment(this.advice, advice);
144 }
145
146
147 public List<Statement> getStatements() {
148 return statements;
149 }
150
151
152 public List<Statement> getStatements(QName typeOrName) {
153 return (List<Statement>) statements.subList(typeOrName);
154 }
155
156
157 public List<SubjectStatement> getSubjectStatements() {
158 QName statementQName = new QName(SAMLConstants.SAML1_NS, SubjectStatement.DEFAULT_ELEMENT_LOCAL_NAME);
159 return (List<SubjectStatement>) statements.subList(statementQName);
160 }
161
162
163 public List<AuthenticationStatement> getAuthenticationStatements() {
164 QName statementQName = new QName(SAMLConstants.SAML1_NS, AuthenticationStatement.DEFAULT_ELEMENT_LOCAL_NAME);
165 return (List<AuthenticationStatement>) statements.subList(statementQName);
166 }
167
168
169 public List<AuthorizationDecisionStatement> getAuthorizationDecisionStatements() {
170 QName statementQName = new QName(SAMLConstants.SAML1_NS, AuthorizationDecisionStatement.DEFAULT_ELEMENT_LOCAL_NAME);
171 return (List<AuthorizationDecisionStatement>) statements.subList(statementQName);
172 }
173
174
175 public List<AttributeStatement> getAttributeStatements() {
176 QName statementQName = new QName(SAMLConstants.SAML1_NS, AttributeStatement.DEFAULT_ELEMENT_LOCAL_NAME);
177 return (List<AttributeStatement>) statements.subList(statementQName);
178 }
179
180
181 public String getSignatureReferenceID(){
182 return id;
183 }
184
185
186 public List<XMLObject> getOrderedChildren() {
187
188 ArrayList<XMLObject> children = new ArrayList<XMLObject>();
189
190 if (conditions != null) {
191 children.add(conditions);
192 }
193
194 if (advice != null) {
195 children.add(advice);
196 }
197
198 children.addAll(statements);
199
200 if(getSignature() != null){
201 children.add(getSignature());
202 }
203
204 if (children.size() == 0) {
205 return null;
206 }
207 return Collections.unmodifiableList(children);
208 }
209 }