当前位置: 首页>>代码示例>>Java>>正文


Java SaslClientFactory.getMechanismNames方法代码示例

本文整理汇总了Java中javax.security.sasl.SaslClientFactory.getMechanismNames方法的典型用法代码示例。如果您正苦于以下问题:Java SaslClientFactory.getMechanismNames方法的具体用法?Java SaslClientFactory.getMechanismNames怎么用?Java SaslClientFactory.getMechanismNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.security.sasl.SaslClientFactory的用法示例。


在下文中一共展示了SaslClientFactory.getMechanismNames方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: refresh

import javax.security.sasl.SaslClientFactory; //导入方法依赖的package包/类
private void refresh() {
  final Enumeration<SaslClientFactory> factories = Sasl.getSaslClientFactories();
  final Map<String, List<SaslClientFactory>> map = Maps.newHashMap();

  while (factories.hasMoreElements()) {
    final SaslClientFactory factory = factories.nextElement();
    // Passing null so factory is populated with all possibilities.  Properties passed when
    // instantiating a client are what really matter. See createSaslClient.
    for (final String mechanismName : factory.getMechanismNames(null)) {
      if (!map.containsKey(mechanismName)) {
        map.put(mechanismName, new ArrayList<SaslClientFactory>());
      }
      map.get(mechanismName).add(factory);
    }
  }

  clientFactories = ImmutableMap.copyOf(map);
  if (logger.isDebugEnabled()) {
    logger.debug("Registered sasl client factories: {}", clientFactories.keySet());
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:22,代码来源:FastSaslClientFactory.java

示例2: getSaslClientFactory

import javax.security.sasl.SaslClientFactory; //导入方法依赖的package包/类
public static SaslClientFactory getSaslClientFactory(String mech, Map<String, ?> props) {
    Iterator<SaslClientFactory> saslFactories = SaslUtils.getSaslClientFactories(SaslUtils.class.getClassLoader(), true);
    while (saslFactories.hasNext()) {
        SaslClientFactory saslFactory = saslFactories.next();
        for (String supportedMech : saslFactory.getMechanismNames(props)) {
            if (mech.equals(supportedMech)) {
                return saslFactory;
            }
        }
    }
    throw new IllegalArgumentException("No SASL client factory for mech " + mech);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:13,代码来源:SaslUtils.java

示例3: testGetClient02

import javax.security.sasl.SaslClientFactory; //导入方法依赖的package包/类
/**
 * Test for <code>getSaslClientFactories()</code> method 
 * 
 * Assertion: returns enumeration of factories for producing SaslClient.
 * 
 * Enumeration consists of 4 elements.
 * 
 * 4 different providers define different mechanism and refer to the same
 * SaslClientFactory class
 */
public void testGetClient02() throws SaslException {
    mProv = new Provider[] {
            (new SpiEngUtils()).new MyProvider("MySaslClientProvider1",
                    "Testing provider SaslClientFactory - 1", CLNTSRV
                            .concat(mech[0]), fClientClass01),
            (new SpiEngUtils()).new MyProvider("MySaslClientProvider2",
                    "Testing provider SaslClientFactory - 2", CLNTSRV
                            .concat(mech[1]), fClientClass01),
            (new SpiEngUtils()).new MyProvider("MySaslClientProvider3",
                    "Testing provider SaslClientFactory - 3", CLNTSRV
                            .concat(mech[2]), fClientClass01),
            (new SpiEngUtils()).new MyProvider("MySaslClientProvider4",
                    "Testing provider SaslClientFactory - 4", CLNTSRV
                            .concat(mech[3]), fClientClass01) };
    addProviders();

    Enumeration<SaslClientFactory> en = Sasl.getSaslClientFactories();
    assertNotNull("List of SaslClientFactories should not be null", en);
    assertTrue("List of SaslClientFactories should have elements", en
            .hasMoreElements());
    myClientFactory01 mm = new myClientFactory01();
    String[] mech01 = mm.getMechanismNames(null);
    int l = 0;
    while (en.hasMoreElements()) {
        SaslClientFactory f = en.nextElement();
        if (f instanceof myClientFactory01) {
            l++;
            assertNull("Incorect SaslClient", f.createSaslClient(null,
                    null, null, null, null, null));
            String[] mech00 = f.getMechanismNames(null);
            assertEquals("Wrong length", mech00.length, mech01.length);
            for (int i = 0; i < mech00.length; i++) {
                assertEquals("Wrong mechanism name", mech00[i], mech01[i]);
            }
        }
    }
    assertEquals("Incorrect number of enumeration elements", l,
            mProv.length);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:50,代码来源:Sasl2Test.java

示例4: testGetClient01

import javax.security.sasl.SaslClientFactory; //导入方法依赖的package包/类
/**
 * Test for <code>getSaslClientFactories()</code> method 
 * 
 * Assertion: returns enumeration of factories for producing SaslClient.
 * 
 * Enumeration consists of 4 elements.
 * 
 * 4 different providers define the same mechanism and refer to the same
 * SaslClientFactory class
 */
public void testGetClient01() throws SaslException {
    mProv = new Provider[] {
            (new SpiEngUtils()).new MyProvider("MySaslClientProvider1",
                    "Testing provider SaslClientFactory - 1", CLNTSRV
                            .concat(mech[0]), fClientClass01),
            (new SpiEngUtils()).new MyProvider("MySaslClientProvider2",
                    "Testing provider SaslClientFactory - 2", CLNTSRV
                            .concat(mech[0]), fClientClass01),
            (new SpiEngUtils()).new MyProvider("MySaslClientProvider3",
                    "Testing provider SaslClientFactory - 3", CLNTSRV
                            .concat(mech[0]), fClientClass01),
            (new SpiEngUtils()).new MyProvider("MySaslClientProvider4",
                    "Testing provider SaslClientFactory - 4", CLNTSRV
                            .concat(mech[0]), fClientClass01) };

    addProviders();

    Enumeration<SaslClientFactory> en = Sasl.getSaslClientFactories();
    assertNotNull("List of SaslClientFactories should not be null", en);
    assertTrue("List of SaslClientFactories should have elements", en
            .hasMoreElements());
    myClientFactory01 mm = new myClientFactory01();
    String[] mech01 = mm.getMechanismNames(null);
    int l = 0;
    while (en.hasMoreElements()) {
        SaslClientFactory f = en.nextElement();
        if (f instanceof myClientFactory01) {
            l++;
            assertNull("Incorect SaslClient", f.createSaslClient(null,
                    null, null, null, null, null));
            String[] mech00 = f.getMechanismNames(null);
            assertEquals("Wrong length", mech00.length, mech01.length);
            for (int i = 0; i < mech00.length; i++) {
                assertEquals("Wrong mechanism name", mech00[i], mech01[i]);
            }
        }
    }
    assertEquals("Incorrect number of enumeration elements", l,
            mProv.length);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:51,代码来源:Sasl2Test.java


注:本文中的javax.security.sasl.SaslClientFactory.getMechanismNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。