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 * This class represents a SubjectLocality.
24 */
25 public class SubjectLocalityBean {
26
27 /** The ipAddress. */
28 private String ipAddress;
29
30 /** The DNS Address. */
31 private String dnsAddress;
32
33 /**
34 * Default constructor explicitly provided since other constructors would
35 * prevent its automatic creation.
36 */
37 public SubjectLocalityBean() {
38 //
39 }
40
41 /**
42 * Constructor for creating a SubjectLocalityBean with ip and dns addresses.
43 *
44 * @param ipAddress ip address
45 * @param dnsAddress dns address
46 */
47 public SubjectLocalityBean(final String ipAddress, final String dnsAddress) {
48 this.ipAddress = ipAddress;
49 this.dnsAddress = dnsAddress;
50 }
51
52 /**
53 * Get the ip address.
54 *
55 * @return the ipAddress
56 */
57 public final String getIpAddress() {
58 return ipAddress;
59 }
60
61 /**
62 * Set the ip address.
63 *
64 * @param ipAddress the ipAddress to set
65 */
66 public final void setIpAddress(final String ipAddress) {
67 this.ipAddress = ipAddress;
68 }
69
70 /**
71 * Get the dns address.
72 *
73 * @return the dnsAddress
74 */
75 public final String getDnsAddress() {
76 return dnsAddress;
77 }
78
79 /**
80 * Set the dns address.
81 *
82 * @param dnsAddress the dnsAddress to set
83 */
84 public final void setDnsAddress(final String dnsAddress) {
85 this.dnsAddress = dnsAddress;
86 }
87
88 /*
89 * (non-Javadoc)
90 *
91 * @see java.lang.Object#equals(java.lang.Object)
92 */
93 @Override
94 public boolean equals(final Object o) {
95 if (this == o) {
96 return true;
97 }
98
99 if (!(o instanceof SubjectLocalityBean)) {
100 return false;
101 }
102
103 SubjectLocalityBean that = (SubjectLocalityBean) o;
104
105 if (ipAddress == null && that.ipAddress != null) {
106 return false;
107 } else if (ipAddress != null && !ipAddress.equals(that.ipAddress)) {
108 return false;
109 }
110
111 if (dnsAddress == null && that.dnsAddress != null) {
112 return false;
113 } else if (dnsAddress != null && !dnsAddress.equals(that.dnsAddress)) {
114 return false;
115 }
116
117 return true;
118 }
119
120 /*
121 * (non-Javadoc)
122 *
123 * @see java.lang.Object#hashCode()
124 */
125 @Override
126 public int hashCode() {
127 int result = 0;
128 if (ipAddress != null) {
129 result = 31 * result + ipAddress.hashCode();
130 }
131 if (dnsAddress != null) {
132 result = 31 * result + dnsAddress.hashCode();
133 }
134
135 return result;
136 }
137 }