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


Java SaslClientFactory类代码示例

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


SaslClientFactory类属于javax.security.sasl包,在下文中一共展示了SaslClientFactory类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createSaslClient

import javax.security.sasl.SaslClientFactory; //导入依赖的package包/类
@Override
public SaslClient createSaslClient(String[] mechanisms, String authorizationId, String protocol, String serverName,
                                   Map<String, ?> props, CallbackHandler cbh) throws SaslException {
  for (final String mechanism : mechanisms) {
    final List<SaslClientFactory> factories = clientFactories.get(mechanism);
    if (factories != null) {
      for (final SaslClientFactory factory : factories) {
        final SaslClient saslClient = factory.createSaslClient(new String[]{mechanism}, authorizationId, protocol,
            serverName, props, cbh);
        if (saslClient != null) {
          return saslClient;
        }
      }
    }
  }
  return null;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:18,代码来源:FastSaslClientFactory.java

示例3: SaslClientContext

import javax.security.sasl.SaslClientFactory; //导入依赖的package包/类
public SaslClientContext(final SaslClientFactory saslClientFactory, final String mech, final String server_name, final CallbackHandler callback_handler, final Map<String, String> props, final Subject subject) throws SaslException {
    this.subject = subject;
    if (this.subject != null) {
        try {
            client = Subject.doAs(this.subject, new PrivilegedExceptionAction<SaslClient>() {

                @Override
                public SaslClient run() throws Exception {
                    return saslClientFactory.createSaslClient(new String[] { mech }, null, SASL.SASL_PROTOCOL_NAME, server_name, props, callback_handler);
                }
            });
        } catch (PrivilegedActionException e) {
            throw (SaslException)e.getCause(); // The createSaslServer will only throw this type of exception
        }
    } else {
        client = saslClientFactory.createSaslClient(new String[] { mech }, null, SASL.SASL_PROTOCOL_NAME, server_name, props, callback_handler);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:19,代码来源:SaslClientContext.java

示例4: 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

示例5: 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

示例6: JCAProvider

import javax.security.sasl.SaslClientFactory; //导入依赖的package包/类
/**
 * Creates the security provider with a map from SASL mechanisms to implementing factories.
 *
 * @param providerMap The map from SASL mechanims to implementing factory classes.
 */
public JCAProvider(Map<String, Class<? extends SaslClientFactory>> providerMap)
{
    super("AMQSASLProvider", 1.0, "A JCA provider that registers all "
          + "AMQ SASL providers that want to be registered");
    register(providerMap);
}
 
开发者ID:wso2,项目名称:andes,代码行数:12,代码来源:JCAProvider.java

示例7: register

import javax.security.sasl.SaslClientFactory; //导入依赖的package包/类
/**
 * Registers client factory classes for a map of mechanism names to client factory classes.
 *
 * @param providerMap The map from SASL mechanims to implementing factory classes.
 */
private void register(Map<String, Class<? extends SaslClientFactory>> providerMap)
{
    for (Map.Entry<String, Class<? extends SaslClientFactory>> me : providerMap.entrySet())
    {
        put("SaslClientFactory." + me.getKey(), me.getValue().getName());
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:13,代码来源:JCAProvider.java

示例8: JCAProvider

import javax.security.sasl.SaslClientFactory; //导入依赖的package包/类
/**
     * Creates the security provider with a map from SASL mechanisms to implementing factories.
     *
     * @param providerMap The map from SASL mechanims to implementing factory classes.
     */
    public JCAProvider(Map<String, Class<? extends SaslClientFactory>> providerMap)
    {
        super("AMQSASLProvider-Client", 1.0, "A JCA provider that registers all "
            + "AMQ SASL providers that want to be registered");
        register(providerMap);
//        Security.addProvider(this);
    }
 
开发者ID:wso2,项目名称:andes,代码行数:13,代码来源:JCAProvider.java

示例9: register

import javax.security.sasl.SaslClientFactory; //导入依赖的package包/类
/**
 * Registers client factory classes for a map of mechanism names to client factory classes.
 *
 * @param providerMap The map from SASL mechanims to implementing factory classes.
 */
private void register(Map<String, Class<? extends SaslClientFactory>> providerMap)
{
    for (Map.Entry<String, Class<? extends SaslClientFactory>> me : providerMap.entrySet())
    {
        put( "SaslClientFactory."+me.getKey(), me.getValue().getName());
        log.debug("Registered SASL Client factory for " + me.getKey() + " as " + me.getValue().getName());
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:14,代码来源:JCAProvider.java

示例10: parseProperties

import javax.security.sasl.SaslClientFactory; //导入依赖的package包/类
/**
 * Parses the specified properties as a mapping from IANA registered SASL mechanism names to implementing client
 * factories. If the client factories cannot be instantiated or do not implement SaslClientFactory then the
 * properties refering to them are ignored.
 *
 * @param props The properties to scan for Sasl client factory implementations.
 *
 * @return A map from SASL mechanism names to implementing client factory classes.
 *
 * @todo Why tree map here? Do really want mechanisms in alphabetical order? Seems more likely that the declared
 * order of the mechanisms is intended to be preserved, so that they are registered in the declared order of
 * preference. Consider LinkedHashMap instead.
 */
private static Map<String, Class<? extends SaslClientFactory>> parseProperties(Properties props)
{
    Enumeration e = props.propertyNames();

    TreeMap<String, Class<? extends SaslClientFactory>> factoriesToRegister =
        new TreeMap<String, Class<? extends SaslClientFactory>>();

    while (e.hasMoreElements())
    {
        String mechanism = (String) e.nextElement();
        String className = props.getProperty(mechanism);
        try
        {
            Class<?> clazz = Class.forName(className);
            if (!(SaslClientFactory.class.isAssignableFrom(clazz)))
            {
                _logger.error("Class " + clazz + " does not implement " + SaslClientFactory.class + " - skipping");

                continue;
            }

            _logger.debug("Registering class "+ clazz.getName() +" for mechanism "+mechanism);
            factoriesToRegister.put(mechanism, (Class<? extends SaslClientFactory>) clazz);
        }
        catch (Exception ex)
        {
            _logger.error("Error instantiating SaslClientFactory calss " + className + " - skipping");
        }
    }

    return factoriesToRegister;
}
 
开发者ID:wso2,项目名称:andes,代码行数:46,代码来源:DynamicSaslRegistrar.java

示例11: 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

示例12: SaslClientFactoryWrapper

import javax.security.sasl.SaslClientFactory; //导入依赖的package包/类
public SaslClientFactoryWrapper(com.sun.security.sasl.preview.SaslClientFactory factory) {
    this.factory = factory;
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:4,代码来源:SaslClientFactoryWrapper.java

示例13: testGetClient

import javax.security.sasl.SaslClientFactory; //导入依赖的package包/类
/**
 * Test for <code>getSaslClientFactories()</code> method 
 * 
 * Assertion:
 * returns enumeration without any element
 * 
 * All providers are previously removed.
 */
public void testGetClient() {    
    Enumeration<SaslClientFactory> en = Sasl.getSaslClientFactories();
    assertNotNull("List of SaslClientFactories should not be null", en);
    assertFalse("List of SaslClientFactories should not haves elements", en
            .hasMoreElements());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:Sasl1Test.java

示例14: getSaslClientFactories

import javax.security.sasl.SaslClientFactory; //导入依赖的package包/类
/**
 * Returns an iterator of all of the registered {@code SaslClientFactory}s where the order is
 * based on the order of the Provider registration and/or class path order. Class path providers
 * are listed before global providers; in the event of a name conflict, the class path provider
 * is preferred.
 *
 * @param classLoader
 *            the class loader to use
 * @param includeGlobal
 *            {@code true} to include globally registered providers, {@code false} to exclude
 *            them
 * @return the {@code Iterator} of {@code SaslClientFactory}s
 */
public static Iterator<SaslClientFactory> getSaslClientFactories(ClassLoader classLoader, boolean includeGlobal) {
    return getFactories(SaslClientFactory.class, classLoader, includeGlobal);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:17,代码来源:SaslUtils.java


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