Package net.jini.jeri.kerberos

Examples of net.jini.jeri.kerberos.KerberosTrustVerifier


public class IsTrustedObjectKerberos extends AbstractTrustVerifierTestKerberos{

    //inherit javadoc
    public void run() throws Exception {
        //Obtain an instance of KerberosTrustVerifier
        KerberosTrustVerifier verifier = new KerberosTrustVerifier();
        //Verify that instances of KerberosEndpoint with no socket
        //factory are trusted.
        int port = Integer.parseInt(getStringValue("listenPort"));
        KerberosEndpoint endpoint = KerberosEndpoint.getInstance(
            InetAddress.getLocalHost().getHostAddress(), port,
            new KerberosPrincipal("test@test"));
        TestTrustVerifierCtxSSL ctx = new TestTrustVerifierCtxSSL();
        if (!verifier.isTrustedObject(endpoint,ctx)){
            throw new TestException("KerberosEndpoint instance"
                + " with no socket factory is considered untrusted");
        }
        //Verify that instances of KerberosEndpoint
        //with trusted socket factories are trusted.
        endpoint = KerberosEndpoint.getInstance(
            InetAddress.getLocalHost().getHostAddress(), port,
            new KerberosPrincipal("test@test"),
            new TestSocketFactory(true));
        if (!verifier.isTrustedObject(endpoint,ctx)){
            throw new TestException("KerberosEndpoint instance"
                + " with trusted factory is considered untrusted");
        }
        //Verify that instances of KerberosEndpoint with
        //untrusted socket factories are not trusted.
        endpoint = KerberosEndpoint.getInstance(
            InetAddress.getLocalHost().getHostAddress(), port,
            new KerberosPrincipal("test@test"),
            new TestSocketFactory(false));
        if (verifier.isTrustedObject(endpoint,ctx)){
            throw new TestException("KerberosEndpoint instance"
                + " with untrusted factory is considered trusted");
        }
        //Verify that instances of KerberosPrincipal are trusted.
        KerberosPrincipal kPrincipal = new KerberosPrincipal("bogus@bogus");
        if (!verifier.isTrustedObject(kPrincipal,ctx)){
            throw new TestException(
            "KerberosPrincipal is not considered trusted");
        }
        //Verify that other principals are not trusted
        X500Principal x5Principal = new X500Principal("CN=\"bogus\"");
        if (verifier.isTrustedObject(x5Principal,ctx)){
            throw new TestException("X500Principal is considered trusted");
        }
        //Verify that Remote and Security exceptions from the
        //TrustVerifier.Context are propagated.
        boolean exceptionThrown = false;
        /*ctx = new TestTrustVerifierCtxSSL(new RemoteException());
        try {
            verifier.isTrustedObject(endpoint,ctx);
        } catch (RemoteException e) {
            exceptionThrown = true;
        }
        if (!exceptionThrown) {
            throw new TestException("RemoteException in the"
                + " context was not propagated");
        }*/
        exceptionThrown = false;
        ctx = new TestTrustVerifierCtxSSL(new SecurityException());
        try {
            verifier.isTrustedObject(endpoint,ctx);
        } catch (SecurityException e) {
            exceptionThrown = true;
        }
        if (!exceptionThrown) {
            throw new TestException("SecurityException in the"
                + " context was not propagated");
        }
        //Verify that NullPointerException is thrown if either argument of
        //isTrustedObject is null.
        exceptionThrown = false;
        ctx = new TestTrustVerifierCtxSSL();
        try {
            verifier.isTrustedObject(null, ctx);
        } catch (NullPointerException e) {
            exceptionThrown = true;
        }
        if (!exceptionThrown) {
            throw new TestException("NullPointerException was"
                + " not thrown for a null object");
        }
        exceptionThrown = false;
        try {
            verifier.isTrustedObject(endpoint, null);
        } catch (NullPointerException e) {
            exceptionThrown = true;
        }
        if (!exceptionThrown) {
            throw new TestException("NullPointerException was"
View Full Code Here

TOP

Related Classes of net.jini.jeri.kerberos.KerberosTrustVerifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.