View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied. See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.ws.security.saml.ext;
21  
22  import org.apache.ws.security.saml.ext.bean.AttributeStatementBean;
23  import org.apache.ws.security.saml.ext.bean.AuthDecisionStatementBean;
24  import org.apache.ws.security.saml.ext.bean.AuthenticationStatementBean;
25  import org.apache.ws.security.saml.ext.bean.ConditionsBean;
26  import org.apache.ws.security.saml.ext.bean.SubjectBean;
27  import org.opensaml.common.SAMLVersion;
28  import org.w3c.dom.Element;
29  
30  import javax.security.auth.callback.Callback;
31  import java.util.ArrayList;
32  import java.util.List;
33  
34  
35  /**
36   * Class SAMLCallback will be called by the <code>AssertionWrapper</code> during the creation
37   * of SAML statements (authentication, attribute, and authz decision). Alternatively, the
38   * "assertionElement" member of this class can be set instead, for a pre-existing SAML
39   * Assertion.
40   */
41  public class SAMLCallback implements Callback {
42      
43      /**
44       * The SAML Version of the Assertion to create
45       */
46      private SAMLVersion samlVersion;
47      
48      /**
49       * SAML subject representation
50       */
51      private SubjectBean subject;
52      
53      /**
54       * The issuer of the Assertion
55       */
56      private String issuer;
57      
58      /**
59       * SAML Conditions representation
60       */
61      private ConditionsBean conditions;
62  
63      /**
64       * A list of <code>AuthenticationStatementBean</code> values
65       */
66      private List<AuthenticationStatementBean> authenticationStatementData;
67  
68      /**
69       * A list of <code>AttributeStatementBean</code> values
70       */
71      private List<AttributeStatementBean> attributeStatementData;
72  
73      /**
74       * A list of <code>AuthDecisionStatementBean</code> values
75       */
76      private List<AuthDecisionStatementBean> authDecisionStatementData;
77      
78      /**
79       * A DOM Element representation of this SAML Assertion
80       */
81      private Element assertionElement;
82  
83      /**
84       * Constructor SAMLCallback creates a new SAMLCallback instance.
85       */
86      public SAMLCallback() {
87          authenticationStatementData = new ArrayList<AuthenticationStatementBean>();
88          attributeStatementData = new ArrayList<AttributeStatementBean>();
89          authDecisionStatementData = new ArrayList<AuthDecisionStatementBean>();
90      }
91  
92      /**
93       * Method getAuthenticationStatementData returns the authenticationStatementData of this 
94       * SAMLCallback object.
95       *
96       * @return the authenticationStatementData (type List<AuthenticationStatementBean>) of 
97       *         this SAMLCallback object.
98       */
99      public List<AuthenticationStatementBean> getAuthenticationStatementData() {
100         return authenticationStatementData;
101     }
102 
103     /**
104      * Method setAuthenticationStatementData sets the authenticationStatementData of this 
105      * SAMLCallback object.
106      *
107      * @param authenticationStatementData the authenticationStatementData of this 
108      *        SAMLCallback object.
109      */
110     public void setAuthenticationStatementData(
111         List<AuthenticationStatementBean> authenticationStatementData
112     ) {
113         this.authenticationStatementData = authenticationStatementData;
114     }
115 
116     /**
117      * Method getAttributeStatementData returns the attributeStatementData of this 
118      * SAMLCallback object.
119      *
120      * @return the attributeStatementData (type List<AttributeStatementBean>) of this 
121      *         SAMLCallback object.
122      */
123     public List<AttributeStatementBean> getAttributeStatementData() {
124         return attributeStatementData;
125     }
126 
127     /**
128      * Method setAttributeStatementData sets the attributeStatementData of this SAMLCallback object.
129      *
130      * @param attributeStatementData the attributeStatementData of this SAMLCallback object.
131      */
132     public void setAttributeStatementData(List<AttributeStatementBean> attributeStatementData) {
133         this.attributeStatementData = attributeStatementData;
134     }
135 
136     /**
137      * Method getAuthDecisionStatementData returns the authDecisionStatementData of this 
138      * SAMLCallback object.
139      *
140      * @return the authDecisionStatementData (type List<AuthDecisionStatementBean>) of this 
141      *         SAMLCallback object.
142      */
143     public List<AuthDecisionStatementBean> getAuthDecisionStatementData() {
144         return authDecisionStatementData;
145     }
146 
147     /**
148      * Method setAuthDecisionStatementData sets the authDecisionStatementData of this 
149      * SAMLCallback object.
150      *
151      * @param authDecisionStatementData the authDecisionStatementData of this 
152      *        SAMLCallback object.
153      */
154     public void setAuthDecisionStatementData(
155         List<AuthDecisionStatementBean> authDecisionStatementData
156     ) {
157         this.authDecisionStatementData = authDecisionStatementData;
158     }
159 
160     /**
161      * Method getSubject returns the subject of this SAMLCallback object.
162      *
163      * @return the subject (type SubjectBean) of this SAMLCallback object.
164      */
165     public SubjectBean getSubject() {
166         return subject;
167     }
168 
169     /**
170      * Method setSubject sets the subject of this SAMLCallback object.
171      *
172      * @param subject the subject of this SAMLCallback object.
173      */
174     public void setSubject(SubjectBean subject) {
175         this.subject = subject;
176     }
177     
178     /**
179      * Method getIssuer returns the issuer of this SAMLCallback object.
180      *
181      * @return the issuer of this SAMLCallback object.
182      */
183     public String getIssuer() {
184         return issuer;
185     }
186 
187     /**
188      * Method setIssuer sets the issuer of this SAMLCallback object.
189      *
190      * @param issuer the issuer of this SAMLCallback object.
191      */
192     public void setIssuer(String issuer) {
193         this.issuer = issuer;
194     }
195     
196     /**
197      * Method getConditions returns the conditions of this SAMLCallback object.
198      *
199      * @return the conditions (type ConditionsBean) of this SAMLCallback object.
200      */
201     public ConditionsBean getConditions() {
202         return conditions;
203     }
204 
205     /**
206      * Method setConditions sets the conditions of this SAMLCallback object.
207      *
208      * @param conditions the conditions of this SAMLCallback object.
209      */
210     public void setConditions(ConditionsBean conditions) {
211         this.conditions = conditions;
212     }
213     
214     /**
215      * Set the SAMLVersion of the assertion to create
216      * @param samlVersion the SAMLVersion of the assertion to create
217      */
218     public void setSamlVersion(SAMLVersion samlVersion) {
219         this.samlVersion = samlVersion;
220     }
221     
222     /**
223      * Get the SAMLVersion of the assertion to create
224      * @return the SAMLVersion of the assertion to create
225      */
226     public SAMLVersion getSamlVersion() {
227         return samlVersion;
228     }
229     
230     /**
231      * Set the DOM representation of this SAML Assertion
232      * @param assertionElement the DOM representation of this SAML Assertion
233      */
234     public void setAssertionElement(Element assertionElement) {
235         this.assertionElement = assertionElement;
236     }
237     
238     /**
239      * Get the DOM representation of this SAML Assertion
240      * @return the DOM representation of this SAML Assertion
241      */
242     public Element getAssertionElement() {
243         return assertionElement;
244     }
245 }