1 package io.oasp.module.security.common.api.accesscontrol;
2
3 import java.util.ArrayList;
4 import java.util.List;
5 import java.util.Objects;
6
7 import javax.xml.bind.annotation.XmlAttribute;
8 import javax.xml.bind.annotation.XmlElement;
9 import javax.xml.bind.annotation.XmlElementWrapper;
10 import javax.xml.bind.annotation.XmlIDREF;
11 import javax.xml.bind.annotation.XmlRootElement;
12 import javax.xml.bind.annotation.XmlSchemaType;
13
14
15
16
17
18
19
20
21
22
23
24
25 @XmlRootElement(name = "group")
26 public class AccessControlGroup extends AccessControl {
27
28
29 private static final long serialVersionUID = 1L;
30
31
32 @XmlIDREF
33 @XmlElementWrapper(name = "inherits")
34 @XmlElement(name = "group-ref")
35 private List<AccessControlGroup> inherits;
36
37
38 @XmlElementWrapper(name = "permissions")
39 @XmlElement(name = "permission")
40 private List<AccessControlPermission> permissions;
41
42
43 @XmlAttribute(name = "type", required = false)
44 @XmlSchemaType(name = "string")
45 private String type;
46
47
48
49
50 public AccessControlGroup() {
51
52 super();
53 }
54
55
56
57
58
59
60 public AccessControlGroup(String id) {
61
62 super(id);
63 }
64
65
66
67
68
69 public String getType() {
70
71 if (this.type == null) {
72 return "";
73 }
74 return this.type;
75 }
76
77
78
79
80 public void setType(String type) {
81
82 this.type = type;
83 }
84
85
86
87
88 public List<AccessControlGroup> getInherits() {
89
90 if (this.inherits == null) {
91 this.inherits = new ArrayList<>();
92 }
93 return this.inherits;
94 }
95
96
97
98
99 public void setInherits(List<AccessControlGroup> inherits) {
100
101 this.inherits = inherits;
102 }
103
104
105
106
107 public List<AccessControlPermission> getPermissions() {
108
109 if (this.permissions == null) {
110 this.permissions = new ArrayList<>();
111 }
112 return this.permissions;
113 }
114
115
116
117
118 public void setPermissions(List<AccessControlPermission> permissions) {
119
120 this.permissions = permissions;
121 }
122
123 @Override
124 public int hashCode() {
125
126 final int prime = 31;
127 int result = super.hashCode();
128
129
130 result = prime * result + ((this.permissions == null) ? 0 : this.permissions.hashCode());
131 result = prime * result + ((this.type == null) ? 0 : this.type.hashCode());
132 return result;
133 }
134
135 @Override
136 public boolean equals(Object obj) {
137
138 if (this == obj) {
139 return true;
140 }
141 if (!super.equals(obj)) {
142 return false;
143 }
144 if (getClass() != obj.getClass()) {
145 return false;
146 }
147 AccessControlGroup other = (AccessControlGroup) obj;
148
149
150
151
152 if (!Objects.equals(this.permissions, other.permissions)) {
153 return false;
154 }
155 if (!Objects.equals(this.type, other.type)) {
156 return false;
157 }
158 return true;
159 }
160
161 }