Example usage for javax.security.sasl SaslClient getClass

List of usage examples for javax.security.sasl SaslClient getClass

Introduction

In this page you can find the example usage for javax.security.sasl SaslClient getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.wildfly.security.sasl.entity.EntityTest.java

@Test
public void testServerAuthIndirect_Client() throws Exception {
    Map<String, Object> props = new HashMap<String, Object>();

    // No properties are set, an appropriate EntitySaslClient should be returned
    SaslClient client = Sasl.createSaslClient(
            new String[] { SaslMechanismInformation.Names.IEC_ISO_9798_U_RSA_SHA1_ENC }, "TestUser",
            "TestProtocol", "TestServer", props, null);
    assertEquals(EntitySaslClient.class, client.getClass());
    assertEquals(SaslMechanismInformation.Names.IEC_ISO_9798_U_RSA_SHA1_ENC, client.getMechanismName());

    // If we set SERVER_AUTH to true even though only unilateral mechanisms are specified, no client should be returned
    props.put(Sasl.SERVER_AUTH, Boolean.toString(true));
    client = Sasl.createSaslClient(
            new String[] { SaslMechanismInformation.Names.IEC_ISO_9798_U_RSA_SHA1_ENC,
                    SaslMechanismInformation.Names.IEC_ISO_9798_U_DSA_SHA1,
                    SaslMechanismInformation.Names.IEC_ISO_9798_U_ECDSA_SHA1 },
            "TestUser", "TestProtocol", "TestServer", props, null);
    assertNull(client);/*from  w ww  . j  ava2s.c  o  m*/

    // If we set SERVER_AUTH to true, an appropriate EntitySaslClient should be returned
    props.put(Sasl.SERVER_AUTH, Boolean.toString(true));
    client = Sasl.createSaslClient(
            new String[] { SaslMechanismInformation.Names.IEC_ISO_9798_U_RSA_SHA1_ENC,
                    SaslMechanismInformation.Names.IEC_ISO_9798_U_DSA_SHA1,
                    SaslMechanismInformation.Names.IEC_ISO_9798_U_ECDSA_SHA1,
                    SaslMechanismInformation.Names.IEC_ISO_9798_M_RSA_SHA1_ENC,
                    SaslMechanismInformation.Names.IEC_ISO_9798_M_DSA_SHA1,
                    SaslMechanismInformation.Names.IEC_ISO_9798_M_ECDSA_SHA1 },
            "TestUser", "TestProtocol", "TestServer", props, null);
    assertEquals(EntitySaslClient.class, client.getClass());
    assertEquals(SaslMechanismInformation.Names.IEC_ISO_9798_M_RSA_SHA1_ENC, client.getMechanismName());
}