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  package org.apache.syncope.common.lib.to;
20  
21  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
22  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
23  import java.util.ArrayList;
24  import java.util.HashMap;
25  import java.util.List;
26  import java.util.Map;
27  import javax.ws.rs.PathParam;
28  import org.apache.commons.lang3.builder.EqualsBuilder;
29  import org.apache.commons.lang3.builder.HashCodeBuilder;
30  
31  public class RealmTO implements NamedEntityTO, TemplatableTO {
32  
33      private static final long serialVersionUID = 516330662956254391L;
34  
35      private String key;
36  
37      private String name;
38  
39      private String parent;
40  
41      private String fullPath;
42  
43      private String accountPolicy;
44  
45      private String passwordPolicy;
46  
47      private String authPolicy;
48  
49      private String accessPolicy;
50  
51      private String attrReleasePolicy;
52  
53      private String ticketExpirationPolicy;
54  
55      private final List<String> actions = new ArrayList<>();
56  
57      private final Map<String, AnyTO> templates = new HashMap<>();
58  
59      private final List<String> resources = new ArrayList<>();
60  
61      @Override
62      public String getKey() {
63          return key;
64      }
65  
66      @Override
67      public void setKey(final String key) {
68          this.key = key;
69      }
70  
71      @Override
72      public String getName() {
73          return name;
74      }
75  
76      @Override
77      public void setName(final String name) {
78          this.name = name;
79      }
80  
81      public String getParent() {
82          return parent;
83      }
84  
85      public void setParent(final String parent) {
86          this.parent = parent;
87      }
88  
89      public String getFullPath() {
90          return fullPath;
91      }
92  
93      @PathParam("fullPath")
94      public void setFullPath(final String fullPath) {
95          this.fullPath = fullPath;
96      }
97  
98      public String getAccountPolicy() {
99          return accountPolicy;
100     }
101 
102     public void setAccountPolicy(final String accountPolicy) {
103         this.accountPolicy = accountPolicy;
104     }
105 
106     public String getPasswordPolicy() {
107         return passwordPolicy;
108     }
109 
110     public void setPasswordPolicy(final String passwordPolicy) {
111         this.passwordPolicy = passwordPolicy;
112     }
113 
114     public String getAuthPolicy() {
115         return authPolicy;
116     }
117 
118     public void setAuthPolicy(final String authPolicy) {
119         this.authPolicy = authPolicy;
120     }
121 
122     public String getAccessPolicy() {
123         return accessPolicy;
124     }
125 
126     public void setAccessPolicy(final String accessPolicy) {
127         this.accessPolicy = accessPolicy;
128     }
129 
130     public String getAttrReleasePolicy() {
131         return attrReleasePolicy;
132     }
133 
134     public void setAttrReleasePolicy(final String attrReleasePolicy) {
135         this.attrReleasePolicy = attrReleasePolicy;
136     }
137 
138     public String getTicketExpirationPolicy() {
139         return ticketExpirationPolicy;
140     }
141 
142     public void setTicketExpirationPolicy(final String ticketExpirationPolicy) {
143         this.ticketExpirationPolicy = ticketExpirationPolicy;
144     }
145 
146     @JacksonXmlElementWrapper(localName = "actions")
147     @JacksonXmlProperty(localName = "action")
148     public List<String> getActions() {
149         return actions;
150     }
151 
152     @Override
153     public Map<String, AnyTO> getTemplates() {
154         return templates;
155     }
156 
157     @JacksonXmlElementWrapper(localName = "resources")
158     @JacksonXmlProperty(localName = "resource")
159     public List<String> getResources() {
160         return resources;
161     }
162 
163     @Override
164     public boolean equals(final Object obj) {
165         if (this == obj) {
166             return true;
167         }
168         if (obj == null) {
169             return false;
170         }
171         if (getClass() != obj.getClass()) {
172             return false;
173         }
174         RealmTO other = (RealmTO) obj;
175         return new EqualsBuilder().
176                 append(key, other.key).
177                 append(name, other.name).
178                 append(parent, other.parent).
179                 append(fullPath, other.fullPath).
180                 append(accountPolicy, other.accountPolicy).
181                 append(passwordPolicy, other.passwordPolicy).
182                 append(authPolicy, other.authPolicy).
183                 append(accessPolicy, other.accessPolicy).
184                 append(attrReleasePolicy, other.attrReleasePolicy).
185                 append(ticketExpirationPolicy, other.ticketExpirationPolicy).
186                 append(actions, other.actions).
187                 append(templates, other.templates).
188                 append(resources, other.resources).
189                 build();
190     }
191 
192     @Override
193     public int hashCode() {
194         return new HashCodeBuilder().
195                 append(key).
196                 append(name).
197                 append(parent).
198                 append(fullPath).
199                 append(accountPolicy).
200                 append(passwordPolicy).
201                 append(authPolicy).
202                 append(accessPolicy).
203                 append(attrReleasePolicy).
204                 append(ticketExpirationPolicy).
205                 append(actions).
206                 append(templates).
207                 append(resources).
208                 build();
209     }
210 }