@Test
  public void testServerAuthDirect_Server() {
    SaslServerFactory factory = obtainSaslServerFactory(EntitySaslServerFactory.class);
    assertNotNull("SaslServerFactory not registered", factory);

    String[] mechanisms;
    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);
  }
Example #2
0
  public void initiateSASL() {
    SaslMechanisms mechanisms = new SaslMechanisms();
    final Enumeration<SaslServerFactory> saslServerFactories = Sasl.getSaslServerFactories();

    SaslServerFactory f;
    ArrayList<Symbol> mechanismsList = new ArrayList<Symbol>();
    while (saslServerFactories.hasMoreElements()) {
      f = saslServerFactories.nextElement();
      final String[] mechanismNames = f.getMechanismNames(null);
      for (String name : mechanismNames) {
        mechanismsList.add(Symbol.valueOf(name));
      }
    }
    mechanisms.setSaslServerMechanisms(mechanismsList.toArray(new Symbol[mechanismsList.size()]));
    _saslFrameOutput.send(new SASLFrame(mechanisms), null);
  }