Example usage for javax.security.sasl SaslClientFactory getMechanismNames

List of usage examples for javax.security.sasl SaslClientFactory getMechanismNames

Introduction

In this page you can find the example usage for javax.security.sasl SaslClientFactory getMechanismNames.

Prototype

public abstract String[] getMechanismNames(Map<String, ?> props);

Source Link

Document

Returns an array of names of mechanisms that match the specified mechanism selection policies.

Usage

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

@Test
public void testServerAuthDirect_Client() {
    SaslClientFactory factory = obtainSaslClientFactory(EntitySaslClientFactory.class);
    assertNotNull("SaslClientFactory not registered", factory);

    String[] mechanisms;/*w w  w .j  a  v  a2  s . c  om*/
    Map<String, Object> props = new HashMap<String, Object>();

    // No properties set
    mechanisms = factory.getMechanismNames(props);
    assertMechanisms(new String[] { SaslMechanismInformation.Names.IEC_ISO_9798_U_RSA_SHA1_ENC,
            SaslMechanismInformation.Names.IEC_ISO_9798_M_RSA_SHA1_ENC,
            SaslMechanismInformation.Names.IEC_ISO_9798_U_DSA_SHA1,
            SaslMechanismInformation.Names.IEC_ISO_9798_M_DSA_SHA1,
            SaslMechanismInformation.Names.IEC_ISO_9798_U_ECDSA_SHA1,
            SaslMechanismInformation.Names.IEC_ISO_9798_M_ECDSA_SHA1 }, mechanisms);

    // Request server auth
    props.put(Sasl.SERVER_AUTH, Boolean.toString(true));
    mechanisms = factory.getMechanismNames(props);
    assertMechanisms(new String[] { 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 }, mechanisms);
}