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.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
@XmlRootElement(name="auhtorization-endpoint")
|
@XmlRootElement(name="authorization-endpoint")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public final class AuthorizationEndpoint implements Comparable<AuthorizationEndpoint>{
|
public final class AuthorizationEndpoint implements Comparable<AuthorizationEndpoint>{
|
||||||
|
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
private int priority = 0;
|
private int priority = 0;
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
private String infrastructure;
|
||||||
|
|
||||||
@XmlElement
|
@XmlElement
|
||||||
private String host;
|
private String host;
|
||||||
|
|
||||||
|
@ -21,13 +24,18 @@ public final class AuthorizationEndpoint implements Comparable<AuthorizationEndp
|
||||||
|
|
||||||
protected AuthorizationEndpoint() {}
|
protected AuthorizationEndpoint() {}
|
||||||
|
|
||||||
public AuthorizationEndpoint(int priority, String host, int port) {
|
public AuthorizationEndpoint(String infrastructure, int priority, String host, int port) {
|
||||||
super();
|
super();
|
||||||
|
this.infrastructure = infrastructure;
|
||||||
this.host = host;
|
this.host = host;
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getInfrastructure() {
|
||||||
|
return infrastructure;
|
||||||
|
}
|
||||||
|
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +59,7 @@ public final class AuthorizationEndpoint implements Comparable<AuthorizationEndp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "AuthorizationEndpoint [priority=" + priority + ", host=" + host
|
return "AuthorizationEndpoint [infrastructure= "+infrastructure+" priority=" + priority + ", host=" + host
|
||||||
+ ", port=" + port + "]";
|
+ ", port=" + port + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +68,8 @@ public final class AuthorizationEndpoint implements Comparable<AuthorizationEndp
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((host == null) ? 0 : host.hashCode());
|
result = prime * result + ((host == null) ? 0 : host.hashCode());
|
||||||
|
result = prime * result
|
||||||
|
+ ((infrastructure == null) ? 0 : infrastructure.hashCode());
|
||||||
result = prime * result + port;
|
result = prime * result + port;
|
||||||
result = prime * result + priority;
|
result = prime * result + priority;
|
||||||
return result;
|
return result;
|
||||||
|
@ -79,6 +89,11 @@ public final class AuthorizationEndpoint implements Comparable<AuthorizationEndp
|
||||||
return false;
|
return false;
|
||||||
} else if (!host.equals(other.host))
|
} else if (!host.equals(other.host))
|
||||||
return false;
|
return false;
|
||||||
|
if (infrastructure == null) {
|
||||||
|
if (other.infrastructure != null)
|
||||||
|
return false;
|
||||||
|
} else if (!infrastructure.equals(other.infrastructure))
|
||||||
|
return false;
|
||||||
if (port != other.port)
|
if (port != other.port)
|
||||||
return false;
|
return false;
|
||||||
if (priority != other.priority)
|
if (priority != other.priority)
|
||||||
|
@ -86,4 +101,6 @@ public final class AuthorizationEndpoint implements Comparable<AuthorizationEndp
|
||||||
return true;
|
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{
|
public void bind() throws Exception{
|
||||||
JAXBContext context = getContext();
|
JAXBContext context = getContext();
|
||||||
StringWriter sw = new StringWriter();
|
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);
|
context.createMarshaller().marshal(ae1, sw);
|
||||||
AuthorizationEndpoint ae2 = (AuthorizationEndpoint)context.createUnmarshaller().unmarshal(new StringReader(sw.toString()));
|
AuthorizationEndpoint ae2 = (AuthorizationEndpoint)context.createUnmarshaller().unmarshal(new StringReader(sw.toString()));
|
||||||
Assert.assertEquals(ae1, ae2);
|
Assert.assertEquals(ae1, ae2);
|
||||||
|
@ -33,17 +33,17 @@ public class EndpointBinder {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void compare(){
|
public void compare(){
|
||||||
AuthorizationEndpoint ae1 = new AuthorizationEndpoint(2, "146.48.85.179", 8080);
|
AuthorizationEndpoint ae1 = new AuthorizationEndpoint("/myInfra", 2, "146.48.85.179", 8080);
|
||||||
AuthorizationEndpoint ae2 = new AuthorizationEndpoint(1, "146.48.85.179", 8080);
|
AuthorizationEndpoint ae2 = new AuthorizationEndpoint("/myInfra", 1, "146.48.85.179", 8080);
|
||||||
|
|
||||||
Assert.assertTrue(ae1.compareTo(ae2)>0);
|
Assert.assertTrue(ae1.compareTo(ae2)>0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void order(){
|
public void order(){
|
||||||
AuthorizationEndpoint ae1 = new AuthorizationEndpoint(2, "146.48.85.179", 8080);
|
AuthorizationEndpoint ae1 = new AuthorizationEndpoint("/myInfra" ,2, "146.48.85.179", 8080);
|
||||||
AuthorizationEndpoint ae2 = new AuthorizationEndpoint(1, "146.48.85.179", 8080);
|
AuthorizationEndpoint ae2 = new AuthorizationEndpoint("/myInfra" ,1, "146.48.85.179", 8080);
|
||||||
AuthorizationEndpoint ae3 = new AuthorizationEndpoint(3, "146.48.85.179", 8080);
|
AuthorizationEndpoint ae3 = new AuthorizationEndpoint("/myInfra", 3, "146.48.85.179", 8080);
|
||||||
|
|
||||||
AuthorizationEndpoint[] arr1 = new AuthorizationEndpoint[]{ae1, ae2, ae3};
|
AuthorizationEndpoint[] arr1 = new AuthorizationEndpoint[]{ae1, ae2, ae3};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue