Skip to content

Commit dad4249

Browse files
Antonio FornieDaan Hoogland
authored andcommitted
SecurityProfile and ACL for NiciraNvpApi, including Unit and Integration tests
Signed-off-by: Daan Hoogland <dhoogland@schubergphilis.com>
1 parent a160b46 commit dad4249

11 files changed

Lines changed: 1261 additions & 91 deletions

File tree

plugins/network-elements/nicira-nvp/pom.xml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,16 @@
2626
<version>4.4.0-SNAPSHOT</version>
2727
<relativePath>../../pom.xml</relativePath>
2828
</parent>
29-
<!--
29+
3030
<build>
31+
<testResources>
32+
<testResource>
33+
<directory>test/resources</directory>
34+
<filtering>true</filtering>
35+
</testResource>
36+
</testResources>
37+
38+
<!--
3139
<plugins>
3240
<plugin>
3341
<groupId>org.apache.maven.plugins</groupId>
@@ -59,6 +67,29 @@
5967
</configuration>
6068
</plugin>
6169
</plugins>
62-
</build>
6370
-->
71+
</build>
72+
73+
<profiles>
74+
<profile>
75+
<id>integration</id>
76+
<build>
77+
<plugins>
78+
<plugin>
79+
<groupId>org.apache.maven.plugins</groupId>
80+
<artifactId>maven-failsafe-plugin</artifactId>
81+
<executions>
82+
<execution>
83+
<goals>
84+
<goal>integration-test</goal>
85+
<goal>verify</goal>
86+
</goals>
87+
</execution>
88+
</executions>
89+
</plugin>
90+
</plugins>
91+
</build>
92+
</profile>
93+
</profiles>
94+
6495
</project>
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.network.nicira;
18+
19+
import java.io.Serializable;
20+
import java.util.List;
21+
22+
import org.apache.commons.lang.builder.EqualsBuilder;
23+
import org.apache.commons.lang.builder.HashCodeBuilder;
24+
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
25+
import org.apache.commons.lang.builder.ToStringStyle;
26+
27+
@SuppressWarnings("serial")
28+
public abstract class AccessConfiguration<T extends AccessRule> implements Serializable {
29+
30+
protected String displayName;
31+
protected List<T> logicalPortEgressRules;
32+
protected List<T> logicalPortIngressRules;
33+
protected List<NiciraNvpTag> tags;
34+
protected String uuid;
35+
protected String href;
36+
protected String schema;
37+
38+
public String getDisplayName() {
39+
return displayName;
40+
}
41+
42+
public void setDisplayName(final String displayName) {
43+
this.displayName = displayName;
44+
}
45+
46+
public List<T> getLogicalPortEgressRules() {
47+
return logicalPortEgressRules;
48+
}
49+
50+
public void setLogicalPortEgressRules(final List<T> logicalPortEgressRules) {
51+
this.logicalPortEgressRules = logicalPortEgressRules;
52+
}
53+
54+
public List<T> getLogicalPortIngressRules() {
55+
return logicalPortIngressRules;
56+
}
57+
58+
public void setLogicalPortIngressRules(final List<T> logicalPortIngressRules) {
59+
this.logicalPortIngressRules = logicalPortIngressRules;
60+
}
61+
62+
public String getUuid() {
63+
return uuid;
64+
}
65+
66+
public void setUuid(final String uuid) {
67+
this.uuid = uuid;
68+
}
69+
70+
public String getHref() {
71+
return href;
72+
}
73+
74+
public void setHref(final String href) {
75+
this.href = href;
76+
}
77+
78+
public String getSchema() {
79+
return schema;
80+
}
81+
82+
public void setSchema(final String schema) {
83+
this.schema = schema;
84+
}
85+
86+
public List<NiciraNvpTag> getTags() {
87+
return tags;
88+
}
89+
90+
public void setTags(final List<NiciraNvpTag> tags) {
91+
this.tags = tags;
92+
}
93+
94+
@Override
95+
public String toString() {
96+
return ReflectionToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE, false);
97+
}
98+
99+
@Override
100+
public int hashCode() {
101+
return new HashCodeBuilder(17, 31)
102+
.append(displayName).append(logicalPortEgressRules)
103+
.append(logicalPortIngressRules).append(tags)
104+
.append(uuid).append(href).append(schema)
105+
.toHashCode();
106+
}
107+
108+
@Override
109+
@SuppressWarnings("unchecked")
110+
public boolean equals(final Object obj) {
111+
if (obj == null) {
112+
return false;
113+
}
114+
if (obj == this) {
115+
return true;
116+
}
117+
if (!(this.getClass().isInstance(obj))) {
118+
return false;
119+
}
120+
final AccessConfiguration<? extends AccessRule> another =
121+
(AccessConfiguration<? extends AccessRule>) obj;
122+
return new EqualsBuilder()
123+
.append(displayName, another.displayName)
124+
.append(uuid, another.uuid)
125+
.append(href, another.href)
126+
.append(schema, another.schema)
127+
.isEquals();
128+
}
129+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.network.nicira;
18+
19+
import java.io.Serializable;
20+
21+
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
22+
import org.apache.commons.lang.builder.ToStringStyle;
23+
24+
@SuppressWarnings("serial")
25+
public abstract class AccessRule implements Serializable {
26+
27+
public static final String ETHERTYPE_IPV4 = "IPv4";
28+
public static final String ETHERTYPE_IPV6 = "IPv6";
29+
30+
protected String ethertype = ETHERTYPE_IPV4;
31+
32+
protected int protocol;
33+
34+
35+
public String getEthertype() {
36+
return ethertype;
37+
}
38+
39+
public void setEthertype(String ethertype) {
40+
this.ethertype = ethertype;
41+
}
42+
43+
public int getProtocol() {
44+
return protocol;
45+
}
46+
47+
public void setProtocol(int protocol) {
48+
this.protocol = protocol;
49+
}
50+
51+
@Override
52+
public String toString() {
53+
return ReflectionToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE, false);
54+
}
55+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.network.nicira;
18+
19+
@SuppressWarnings("serial")
20+
public class Acl extends AccessConfiguration<AclRule> {
21+
}

0 commit comments

Comments
 (0)