Search in sources :

Example 1 with SimpleToken

use of org.jgroups.auth.SimpleToken in project JGroups by belaban.

the class AUTHTest method testAuthHeaderDifferent.

/**
 * Test to create an AuthHeader object and set and get the Token object
 * <p/>
 * Fails if an exception is thrown or the set and get equal the same object
 */
public void testAuthHeaderDifferent() {
    SimpleToken token1 = new SimpleToken();
    token1.setAuthValue("chris");
    SimpleToken token2 = new SimpleToken();
    token2.setAuthValue("chris");
    AuthHeader header = new AuthHeader();
    header.setToken(token1);
    assert !(token2 == header.getToken());
}
Also used : SimpleToken(org.jgroups.auth.SimpleToken)

Example 2 with SimpleToken

use of org.jgroups.auth.SimpleToken in project JGroups by belaban.

the class AUTHTest method testSimpleTokenMismatch.

/**
 * Creates two SimpleToken objects with different auth_values and authenticates one against the other
 * <p/>
 * Test fails if an exception is thrown or authentication passes
 */
public static void testSimpleTokenMismatch() {
    SimpleToken token1 = new SimpleToken();
    token1.setAuthValue("chris");
    SimpleToken token2 = new SimpleToken();
    token2.setAuthValue("chrismills");
    assert !token1.authenticate(token2, null);
}
Also used : SimpleToken(org.jgroups.auth.SimpleToken)

Example 3 with SimpleToken

use of org.jgroups.auth.SimpleToken in project JGroups by belaban.

the class AUTHTest method testAuthHeader.

/**
 * Test to create an AuthHeader object and set and get the Token object
 * <p/>
 * Fails if an exception is thrown or the set and get don't equal the same object
 */
public static void testAuthHeader() {
    SimpleToken token1 = new SimpleToken();
    token1.setAuthValue("chris");
    AuthHeader header = new AuthHeader();
    header.setToken(token1);
    assert token1 == header.getToken();
}
Also used : SimpleToken(org.jgroups.auth.SimpleToken)

Example 4 with SimpleToken

use of org.jgroups.auth.SimpleToken in project JGroups by belaban.

the class AUTHTest method testSimpleToken.

/**
 * Creates two SimpleToken objects with identical auth_values and authenticates one against the other
 * Test fails if an exception is thrown or authentication fails
 */
public static void testSimpleToken() {
    SimpleToken token1 = new SimpleToken();
    token1.setAuthValue("chris");
    SimpleToken token2 = new SimpleToken();
    token2.setAuthValue("chris");
    assert token1.authenticate(token2, null);
}
Also used : SimpleToken(org.jgroups.auth.SimpleToken)

Example 5 with SimpleToken

use of org.jgroups.auth.SimpleToken in project JGroups by belaban.

the class AUTHTest method create.

protected JChannel create(String name, boolean create_auth_prot) throws Exception {
    JChannel ch = new JChannel(Util.getTestStack()).name(name);
    if (create_auth_prot) {
        // .setAuthCoord(false)
        AUTH auth = new AUTH().setAuthToken(new SimpleToken("foo"));
        ch.getProtocolStack().insertProtocol(auth, ProtocolStack.Position.BELOW, GMS.class);
    }
    return ch;
}
Also used : JChannel(org.jgroups.JChannel) SimpleToken(org.jgroups.auth.SimpleToken)

Aggregations

SimpleToken (org.jgroups.auth.SimpleToken)5 JChannel (org.jgroups.JChannel)1