git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/authorization-common-library@129125 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fea33de67b
commit
68ceb8f9fd
|
@ -6,13 +6,16 @@ import javax.xml.bind.annotation.XmlAttribute;
|
|||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name="auhtorization-endpoint")
|
||||
@XmlRootElement(name="authorization-endpoint")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public final class AuthorizationEndpoint implements Comparable<AuthorizationEndpoint>{
|
||||
|
||||
@XmlAttribute
|
||||
private int priority = 0;
|
||||
|
||||
@XmlElement
|
||||
private String infrastructure;
|
||||
|
||||
@XmlElement
|
||||
private String host;
|
||||
|
||||
|
@ -21,13 +24,18 @@ public final class AuthorizationEndpoint implements Comparable<AuthorizationEndp
|
|||
|
||||
protected AuthorizationEndpoint() {}
|
||||
|
||||
public AuthorizationEndpoint(int priority, String host, int port) {
|
||||
public AuthorizationEndpoint(String infrastructure, int priority, String host, int port) {
|
||||
super();
|
||||
this.infrastructure = infrastructure;
|
||||
this.host = host;
|
||||
this.priority = priority;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
protected String getInfrastructure() {
|
||||
return infrastructure;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
@ -51,7 +59,7 @@ public final class AuthorizationEndpoint implements Comparable<AuthorizationEndp
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AuthorizationEndpoint [priority=" + priority + ", host=" + host
|
||||
return "AuthorizationEndpoint [infrastructure= "+infrastructure+" priority=" + priority + ", host=" + host
|
||||
+ ", port=" + port + "]";
|
||||
}
|
||||
|
||||
|
@ -60,6 +68,8 @@ public final class AuthorizationEndpoint implements Comparable<AuthorizationEndp
|
|||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((host == null) ? 0 : host.hashCode());
|
||||
result = prime * result
|
||||
+ ((infrastructure == null) ? 0 : infrastructure.hashCode());
|
||||
result = prime * result + port;
|
||||
result = prime * result + priority;
|
||||
return result;
|
||||
|
@ -79,6 +89,11 @@ public final class AuthorizationEndpoint implements Comparable<AuthorizationEndp
|
|||
return false;
|
||||
} else if (!host.equals(other.host))
|
||||
return false;
|
||||
if (infrastructure == null) {
|
||||
if (other.infrastructure != null)
|
||||
return false;
|
||||
} else if (!infrastructure.equals(other.infrastructure))
|
||||
return false;
|
||||
if (port != other.port)
|
||||
return false;
|
||||
if (priority != other.priority)
|
||||
|
@ -86,4 +101,6 @@ public final class AuthorizationEndpoint implements Comparable<AuthorizationEndp
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
<auhtorization-endpoint priority="10"><host>node7.d.d4science.research-infrastructures.eu</host><port>9000</port></auhtorization-endpoint>
|
||||
<authorization-endpoint priority="10"><host>node7.d.d4science.research-infrastructures.eu</host><port>9000</port></authorization-endpoint>
|
|
@ -25,7 +25,7 @@ public class EndpointBinder {
|
|||
public void bind() throws Exception{
|
||||
JAXBContext context = getContext();
|
||||
StringWriter sw = new StringWriter();
|
||||
AuthorizationEndpoint ae1 = new AuthorizationEndpoint(2, "146.48.85.179", 8080);
|
||||
AuthorizationEndpoint ae1 = new AuthorizationEndpoint("/myInfra", 2, "146.48.85.179", 8080);
|
||||
context.createMarshaller().marshal(ae1, sw);
|
||||
AuthorizationEndpoint ae2 = (AuthorizationEndpoint)context.createUnmarshaller().unmarshal(new StringReader(sw.toString()));
|
||||
Assert.assertEquals(ae1, ae2);
|
||||
|
@ -33,17 +33,17 @@ public class EndpointBinder {
|
|||
|
||||
@Test
|
||||
public void compare(){
|
||||
AuthorizationEndpoint ae1 = new AuthorizationEndpoint(2, "146.48.85.179", 8080);
|
||||
AuthorizationEndpoint ae2 = new AuthorizationEndpoint(1, "146.48.85.179", 8080);
|
||||
AuthorizationEndpoint ae1 = new AuthorizationEndpoint("/myInfra", 2, "146.48.85.179", 8080);
|
||||
AuthorizationEndpoint ae2 = new AuthorizationEndpoint("/myInfra", 1, "146.48.85.179", 8080);
|
||||
|
||||
Assert.assertTrue(ae1.compareTo(ae2)>0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void order(){
|
||||
AuthorizationEndpoint ae1 = new AuthorizationEndpoint(2, "146.48.85.179", 8080);
|
||||
AuthorizationEndpoint ae2 = new AuthorizationEndpoint(1, "146.48.85.179", 8080);
|
||||
AuthorizationEndpoint ae3 = new AuthorizationEndpoint(3, "146.48.85.179", 8080);
|
||||
AuthorizationEndpoint ae1 = new AuthorizationEndpoint("/myInfra" ,2, "146.48.85.179", 8080);
|
||||
AuthorizationEndpoint ae2 = new AuthorizationEndpoint("/myInfra" ,1, "146.48.85.179", 8080);
|
||||
AuthorizationEndpoint ae3 = new AuthorizationEndpoint("/myInfra", 3, "146.48.85.179", 8080);
|
||||
|
||||
AuthorizationEndpoint[] arr1 = new AuthorizationEndpoint[]{ae1, ae2, ae3};
|
||||
|
||||
|
|
Loading…
Reference in New Issue