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 java.net.URI;
22  import java.util.ArrayList;
23  import java.util.List;
24  import javax.ws.rs.PathParam;
25  import org.apache.commons.lang3.builder.EqualsBuilder;
26  import org.apache.commons.lang3.builder.HashCodeBuilder;
27  import org.apache.syncope.common.lib.types.SRARouteFilter;
28  import org.apache.syncope.common.lib.types.SRARoutePredicate;
29  import org.apache.syncope.common.lib.types.SRARouteType;
30  
31  public class SRARouteTO implements NamedEntityTO {
32  
33      private static final long serialVersionUID = 4044528284951757870L;
34  
35      private String key;
36  
37      private String name;
38  
39      private URI target;
40  
41      private URI error;
42  
43      private SRARouteType type = SRARouteType.PUBLIC;
44  
45      private boolean logout = false;
46  
47      private URI postLogout;
48  
49      private boolean csrf = true;
50  
51      private int order = 0;
52  
53      private final List<SRARouteFilter> filters = new ArrayList<>();
54  
55      private final List<SRARoutePredicate> predicates = new ArrayList<>();
56  
57      @Override
58      public String getKey() {
59          return key;
60      }
61  
62      @PathParam("key")
63      @Override
64      public void setKey(final String key) {
65          this.key = key;
66      }
67  
68      @Override
69      public String getName() {
70          return name;
71      }
72  
73      @Override
74      public void setName(final String name) {
75          this.name = name;
76      }
77  
78      public URI getTarget() {
79          return target;
80      }
81  
82      public void setTarget(final URI target) {
83          this.target = target;
84      }
85  
86      public URI getError() {
87          return error;
88      }
89  
90      public void setError(final URI error) {
91          this.error = error;
92      }
93  
94      public SRARouteType getType() {
95          return type;
96      }
97  
98      public void setType(final SRARouteType type) {
99          this.type = type;
100     }
101 
102     public boolean isLogout() {
103         return logout;
104     }
105 
106     public void setLogout(final boolean logout) {
107         this.logout = logout;
108     }
109 
110     public URI getPostLogout() {
111         return postLogout;
112     }
113 
114     public void setPostLogout(final URI postLogout) {
115         this.postLogout = postLogout;
116     }
117 
118     public boolean isCsrf() {
119         return csrf;
120     }
121 
122     public void setCsrf(final boolean csrf) {
123         this.csrf = csrf;
124     }
125 
126     public int getOrder() {
127         return order;
128     }
129 
130     public void setOrder(final int order) {
131         this.order = order;
132     }
133 
134     public List<SRARouteFilter> getFilters() {
135         return filters;
136     }
137 
138     public List<SRARoutePredicate> getPredicates() {
139         return predicates;
140     }
141 
142     @Override
143     public int hashCode() {
144         return new HashCodeBuilder().
145                 append(key).
146                 append(name).
147                 append(target).
148                 append(error).
149                 append(type).
150                 append(logout).
151                 append(postLogout).
152                 append(csrf).
153                 append(order).
154                 append(filters).
155                 append(predicates).
156                 build();
157     }
158 
159     @Override
160     public boolean equals(final Object obj) {
161         if (this == obj) {
162             return true;
163         }
164         if (obj == null) {
165             return false;
166         }
167         if (getClass() != obj.getClass()) {
168             return false;
169         }
170         final SRARouteTO other = (SRARouteTO) obj;
171         return new EqualsBuilder().
172                 append(key, other.key).
173                 append(name, other.name).
174                 append(target, other.target).
175                 append(error, other.error).
176                 append(type, other.type).
177                 append(logout, other.logout).
178                 append(postLogout, other.postLogout).
179                 append(csrf, other.csrf).
180                 append(order, other.order).
181                 append(filters, other.filters).
182                 append(predicates, other.predicates).
183                 build();
184     }
185 }