private void runTest(Subject subject) throws Exception {
KerberosPrincipal principal = (KerberosPrincipal)subject
.getPrincipals().iterator().next();
//Create an endpoint instance passing in a host and port.
KerberosEndpoint kEndpoint = KerberosEndpoint
.getInstance(host,port,principal);
if (!(kEndpoint instanceof TrustEquivalence)) {
throw new TestException(
kEndpoint + " does not implement TrustEquivalence");
}
TrustEquivalence endpoint1 = (TrustEquivalence) kEndpoint;
//Create a second endpoint instance passing in the same host and
//port.
KerberosEndpoint kEndpoint2 = KerberosEndpoint
.getInstance(host,port,principal);
if (!(kEndpoint2 instanceof TrustEquivalence)) {
throw new TestException(
kEndpoint2 + " does not implement TrustEquivalence");
}
TrustEquivalence endpoint2 = (TrustEquivalence) kEndpoint2;
//Verify TrustEquivalence
if (!endpoint1.checkTrustEquivalence(endpoint2) ||
!endpoint2.checkTrustEquivalence(endpoint1)) {
throw new TestException("TrustEquivalence not"
+ " established on equivalent endpoints.");
}
//Create an endpoint instance with the same host and a
//different port
KerberosEndpoint kEndpoint3 = KerberosEndpoint
.getInstance(host,port2,principal);
if (!(kEndpoint3 instanceof TrustEquivalence)) {
throw new TestException(
kEndpoint3 + " does not implement TrustEquivalence");
}
TrustEquivalence endpoint3 = (TrustEquivalence) kEndpoint3;
//Verify TrustEquivalence
if (endpoint1.checkTrustEquivalence(endpoint3) ||
endpoint3.checkTrustEquivalence(endpoint1)) {
throw new TestException("TrustEquivalence"
+ " established on non-equivalent endpoints.");
}
//Create an endpoint instance with the same port and a
//different host
KerberosEndpoint kEndpoint4 = KerberosEndpoint
.getInstance(host2,port,principal);
if (!(kEndpoint4 instanceof TrustEquivalence)) {
throw new TestException(
kEndpoint4 + " does not implement TrustEquivalence");
}