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.wss4j.common.saml.bean;
21  
22  
23  /**
24   * Class SamlAction represents the raw data required by the <code>SamlAssertionWrapper</code> when
25   * creating the <code>Action</code> element of the SAML Authorization Decision Statement.
26   */
27  public class ActionBean {
28  
29      /**
30       * A URI reference representing the namespace in which the name of the specified action is to be
31       * interpreted. If this element is absent, the namespace
32       * urn:oasis:names:tc:SAML:1.0:action:rwedcnegation specified in Section 7.2.2 is in effect.
33       */
34      private String actionNamespace;
35  
36      /**
37       * An action sought to be performed on the specified resource (i.e. Read, Write, Update, Delete)
38       */
39      private String contents;
40  
41      /**
42       * Constructor SamlAction creates a new SamlAction instance.
43       */
44      public ActionBean() {
45      }
46  
47      /**
48       * Constructor SamlAction creates a new SamlAction instance.
49       *
50       * @param actionNamespace of type String
51       * @param contents of type String
52       */
53      public ActionBean(String actionNamespace, String contents) {
54          this.actionNamespace = actionNamespace;
55          this.contents = contents;
56      }
57  
58      /**
59       * Method getActionNamespace returns the actionNamespace of this SamlAction object.
60       *
61       * @return the actionNamespace (type String) of this SamlAction object.
62       */
63      public String getActionNamespace() {
64          return actionNamespace;
65      }
66  
67      /**
68       * Method setActionNamespace sets the actionNamespace of this SamlAction object.
69       *
70       * @param actionNamespace the actionNamespace of this SamlAction object.
71       */
72      public void setActionNamespace(String actionNamespace) {
73          this.actionNamespace = actionNamespace;
74      }
75  
76      /**
77       * Method getContents returns the contents of this SamlAction object.
78       *
79       * @return the contents (type String) of this SamlAction object.
80       */
81      public String getContents() {
82          return contents;
83      }
84  
85      /**
86       * Method setContents sets the contents of this SamlAction object.
87       *
88       * @param contents the contents of this SamlAction object.
89       */
90      public void setContents(String contents) {
91          this.contents = contents;
92      }
93  
94      @Override
95      public boolean equals(Object o) {
96          if (this == o) {
97              return true;
98          }
99          if (!(o instanceof ActionBean)) {
100             return false;
101         }
102 
103         ActionBean that = (ActionBean) o;
104 
105         if (contents == null && that.contents != null) {
106             return false;
107         } else if (contents != null && !contents.equals(that.contents)) {
108             return false;
109         }
110 
111         if (actionNamespace == null && that.actionNamespace != null) {
112             return false;
113         } else if (actionNamespace != null && !actionNamespace.equals(that.actionNamespace)) {
114             return false;
115         }
116 
117         return true;
118     }
119 
120     @Override
121     public int hashCode() {
122         int result = 0;
123         if (contents != null) {
124             result = 31 * result + contents.hashCode();
125         }
126         if (actionNamespace != null) {
127             result = 31 * result + actionNamespace.hashCode();
128         }
129         return result;
130     }
131 }