本文整理汇总了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());
}
}
示例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);
}
示例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);
}
示例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);
}