本文整理汇总了Java中javax.security.sasl.SaslServerFactory.getMechanismNames方法的典型用法代码示例。如果您正苦于以下问题:Java SaslServerFactory.getMechanismNames方法的具体用法?Java SaslServerFactory.getMechanismNames怎么用?Java SaslServerFactory.getMechanismNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.security.sasl.SaslServerFactory
的用法示例。
在下文中一共展示了SaslServerFactory.getMechanismNames方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refresh
import javax.security.sasl.SaslServerFactory; //导入方法依赖的package包/类
private void refresh() {
final Enumeration<SaslServerFactory> factories = Sasl.getSaslServerFactories();
final Map<String, List<SaslServerFactory>> map = Maps.newHashMap();
while (factories.hasMoreElements()) {
final SaslServerFactory factory = factories.nextElement();
// Passing null so factory is populated with all possibilities. Properties passed when
// instantiating a server are what really matter. See createSaslServer.
for (final String mechanismName : factory.getMechanismNames(null)) {
if (!map.containsKey(mechanismName)) {
map.put(mechanismName, new ArrayList<SaslServerFactory>());
}
map.get(mechanismName).add(factory);
}
}
serverFactories = ImmutableMap.copyOf(map);
if (logger.isDebugEnabled()) {
logger.debug("Registered sasl server factories: {}", serverFactories.keySet());
}
}
示例2: testGetServer02
import javax.security.sasl.SaslServerFactory; //导入方法依赖的package包/类
/**
* Test for <code>getSaslServerFactories()</code> method
*
* Assertion: returns enumeration of factories for producing SaslServer.
*
* Enumeration consists of 4 elements.
*
* 4 different providers define different mechanism and refer to the same
* SaslServerFactory class
*/
public void testGetServer02() throws SaslException {
mProv = new Provider[] {
(new SpiEngUtils()).new MyProvider("MySaslServerProvider1",
"Testing provider SaslServerFactory - 1", SRVSSRV
.concat(mech[0]), fServerClass01),
(new SpiEngUtils()).new MyProvider("MySaslServerProvider2",
"Testing provider SaslServerFactory - 2", SRVSSRV
.concat(mech[1]), fServerClass01),
(new SpiEngUtils()).new MyProvider("MySaslServerProvider3",
"Testing provider SaslServerFactory - 3", SRVSSRV
.concat(mech[2]), fServerClass01),
(new SpiEngUtils()).new MyProvider("MySaslServerProvider4",
"Testing provider SaslServerFactory - 4", SRVSSRV
.concat(mech[3]), fServerClass01) };
addProviders();
Enumeration<SaslServerFactory> en = Sasl.getSaslServerFactories();
assertNotNull("List of SaslServerFactories should not be null", en);
assertTrue("List of SaslServerFactories should have elements", en
.hasMoreElements());
myServerFactory01 mm01 = new myServerFactory01();
String[] mech01 = mm01.getMechanismNames(null);
int l = 0;
while (en.hasMoreElements()) {
SaslServerFactory f = en.nextElement();
if (f instanceof myServerFactory01) {
l++;
assertNull("Incorect SaslServer", f.createSaslServer(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);
}
示例3: FastSaslServerFactory
import javax.security.sasl.SaslServerFactory; //导入方法依赖的package包/类
FastSaslServerFactory(Map<String,?> props) {
final Enumeration<SaslServerFactory> factories =
Sasl.getSaslServerFactories();
while (factories.hasMoreElements()) {
SaslServerFactory factory = factories.nextElement();
for (String mech : factory.getMechanismNames(props)) {
if (!factoryCache.containsKey(mech)) {
factoryCache.put(mech, new ArrayList<SaslServerFactory>());
}
factoryCache.get(mech).add(factory);
}
}
}
示例4: getSaslServerFactory
import javax.security.sasl.SaslServerFactory; //导入方法依赖的package包/类
public static SaslServerFactory getSaslServerFactory(String mech, Map<String, ?> props) {
Iterator<SaslServerFactory> saslFactories = SaslUtils.getSaslServerFactories(SaslUtils.class.getClassLoader(), true);
while (saslFactories.hasNext()) {
SaslServerFactory saslFactory = saslFactories.next();
for (String supportedMech : saslFactory.getMechanismNames(props)) {
if (supportedMech.equals(mech)) {
return saslFactory;
}
}
}
throw new IllegalArgumentException("No SASL server factory for mech " + mech);
}
示例5: filterMechanisms
import javax.security.sasl.SaslServerFactory; //导入方法依赖的package包/类
@Override
public Collection<String> filterMechanisms(Enumeration<SaslServerFactory> serverFactories, XMPPResourceConnection session) {
final Map<String, ?> props = new HashMap<String, Object>();
final ArrayList<String> result = new ArrayList<String>();
while (serverFactories.hasMoreElements()) {
SaslServerFactory ss = serverFactories.nextElement();
String[] x = ss.getMechanismNames(props);
for (String name : x) {
if (match(ss, name, session) && isAllowedForDomain(name, session.getDomain()))
result.add(name);
}
}
return result;
}
示例6: CRAMMD5HashedSaslServer
import javax.security.sasl.SaslServerFactory; //导入方法依赖的package包/类
public CRAMMD5HashedSaslServer(String mechanism, String protocol, String serverName, Map<String, ?> props,
CallbackHandler cbh) throws SaslException
{
Enumeration factories = Sasl.getSaslServerFactories();
while (factories.hasMoreElements())
{
SaslServerFactory factory = (SaslServerFactory) factories.nextElement();
if (factory instanceof CRAMMD5HashedServerFactory)
{
continue;
}
String[] mechs = factory.getMechanismNames(props);
for (String mech : mechs)
{
if (mech.equals("CRAM-MD5"))
{
_realServer = factory.createSaslServer("CRAM-MD5", protocol, serverName, props, cbh);
return;
}
}
}
throw new RuntimeException("No default SaslServer found for mechanism:" + "CRAM-MD5");
}
示例7: CRAMMD5HexSaslServer
import javax.security.sasl.SaslServerFactory; //导入方法依赖的package包/类
public CRAMMD5HexSaslServer(String mechanism, String protocol, String serverName, Map<String, ?> props,
CallbackHandler cbh) throws SaslException
{
Enumeration factories = Sasl.getSaslServerFactories();
while (factories.hasMoreElements())
{
SaslServerFactory factory = (SaslServerFactory) factories.nextElement();
if (factory instanceof CRAMMD5HexServerFactory)
{
continue;
}
String[] mechs = factory.getMechanismNames(props);
for (String mech : mechs)
{
if (mech.equals("CRAM-MD5"))
{
_realServer = factory.createSaslServer("CRAM-MD5", protocol, serverName, props, cbh);
return;
}
}
}
throw new RuntimeException("No default SaslServer found for mechanism:" + "CRAM-MD5");
}
示例8: testGetServer01
import javax.security.sasl.SaslServerFactory; //导入方法依赖的package包/类
/**
* Test for <code>getSaslServerFactories()</code> method
*
* Assertion: returns enumeration of factories for producing SaslServer.
*
* Enumeration consists of 8 elements.
*
* 4 different providers define different mechanism and refer to the 2
* different SaslServerFactory classes
*/
public void testGetServer01() throws SaslException {
mProv = new Provider[] {
(new SpiEngUtils()).new MyProvider("MySaslServerProvider1",
"Testing provider SaslServerFactory - 1", SRVSSRV
.concat(mech[0]), fServerClass02),
(new SpiEngUtils()).new MyProvider("MySaslServerProvider2",
"Testing provider SaslServerFactory - 2", SRVSSRV
.concat(mech[0]), fServerClass02),
(new SpiEngUtils()).new MyProvider("MySaslServerProvider3",
"Testing provider SaslServerFactory - 3", SRVSSRV
.concat(mech[0]), fServerClass02),
(new SpiEngUtils()).new MyProvider("MySaslServerProvider4",
"Testing provider SaslServerFactory - 4", SRVSSRV
.concat(mech[0]), fServerClass02) };
for (Provider element : mProv) {
for (int j = 1; j < mech.length; j++) {
element.put(SRVSSRV.concat(mech[j]).concat(mech[j]),
fServerClass02);
element.put(SRVSSRV.concat(mech[j]).concat(mech[j]),
fServerClass01);
}
element.put(SRVSSRV.concat(mech[0]).concat(mech[0]),
fServerClass01);
}
addProviders();
Enumeration<SaslServerFactory> en = Sasl.getSaslServerFactories();
assertNotNull("List of SaslServerFactories should not be null", en);
assertTrue("List of SaslServerFactories should have elements", en
.hasMoreElements());
myServerFactory01 mm01 = new myServerFactory01();
String[] mech01 = mm01.getMechanismNames(null);
int l = 0;
while (en.hasMoreElements()) {
SaslServerFactory f = en.nextElement();
if (f instanceof myServerFactory02) {
l++;
try {
f.createSaslServer(null, null, null, null, null);
fail("SaslException should be thrown");
} catch (SaslException e) {
}
assertNull("Incorect SaslClient", f.createSaslServer(null, "a",
null, null, null));
assertNull("Wrong length", f.getMechanismNames(null));
} else if (f instanceof myServerFactory01) {
l++;
assertNull("Not null SaslServer", f.createSaslServer(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 * 2);
}