本文整理汇总了Java中javax.security.sasl.SaslServerFactory.createSaslServer方法的典型用法代码示例。如果您正苦于以下问题:Java SaslServerFactory.createSaslServer方法的具体用法?Java SaslServerFactory.createSaslServer怎么用?Java SaslServerFactory.createSaslServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.security.sasl.SaslServerFactory
的用法示例。
在下文中一共展示了SaslServerFactory.createSaslServer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSaslServer
import javax.security.sasl.SaslServerFactory; //导入方法依赖的package包/类
@Override
public SaslServer createSaslServer(String mechanism, String protocol,
String serverName, Map<String,?> props, CallbackHandler cbh)
throws SaslException {
SaslServer saslServer = null;
List<SaslServerFactory> factories = factoryCache.get(mechanism);
if (factories != null) {
for (SaslServerFactory factory : factories) {
saslServer = factory.createSaslServer(
mechanism, protocol, serverName, props, cbh);
if (saslServer != null) {
break;
}
}
}
return saslServer;
}
示例2: SaslServerContext
import javax.security.sasl.SaslServerFactory; //导入方法依赖的package包/类
public SaslServerContext(final SaslServerFactory saslServerFactory, final String mech, final String serverName, final CallbackHandler callback_handler, final Map<String, String> props, final Subject subject) throws SaslException {
this.subject = subject;
if (this.subject != null) {
try {
server = Subject.doAs(this.subject, new PrivilegedExceptionAction<SaslServer>() {
@Override
public SaslServer run() throws Exception {
return saslServerFactory.createSaslServer(mech, SASL.SASL_PROTOCOL_NAME, serverName, props, callback_handler);
}
});
} catch (PrivilegedActionException e) {
throw (SaslException)e.getCause(); // The createSaslServer will only throw this type of exception
}
} else {
server = saslServerFactory.createSaslServer(mech, SASL.SASL_PROTOCOL_NAME, serverName, props, callback_handler);
}
}
示例3: createSaslServer
import javax.security.sasl.SaslServerFactory; //导入方法依赖的package包/类
@Override
public SaslServer createSaslServer(String mechanism, String protocol, String serverName, Map<String, ?> props,
CallbackHandler cbh) throws SaslException {
final List<SaslServerFactory> factories = serverFactories.get(mechanism);
if (factories != null) {
for (final SaslServerFactory factory : factories) {
final SaslServer saslServer = factory.createSaslServer(mechanism, protocol, serverName, props, cbh);
if (saslServer != null) {
return saslServer;
}
}
}
return null;
}
示例4: testGetServer04
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.
*
* 1 provider defines different mechanism and refer to the same
* SaslServerFactory classes
*/
public void testGetServer04() throws SaslException {
mProv = new Provider[] { (new SpiEngUtils()).new MyProvider(
"MySaslServerProvider1",
"Testing provider SaslServerFactory - 1", SRVSSRV
.concat(mech[0]), fServerClass02) };
mProv[0].put(SRVSSRV.concat(mech[1]), fServerClass02);
mProv[0].put(SRVSSRV.concat(mech[2]), fServerClass02);
mProv[0].put(SRVSSRV.concat(mech[3]), fServerClass02);
addProviders();
Enumeration<SaslServerFactory> en = Sasl.getSaslServerFactories();
assertNotNull("List of SaslServerFactories should not be null", en);
assertTrue("List of SaslServerFactories should have elements", en
.hasMoreElements());
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 SaslServer", f.createSaslServer(null, "",
null, null, null));
assertNull("Wrong length", f.getMechanismNames(null));
}
}
assertEquals("Incorrect number of enumeration elements", l,
mProv.length);
}
示例5: testSaslServerDigest
import javax.security.sasl.SaslServerFactory; //导入方法依赖的package包/类
@Test
public void testSaslServerDigest() throws Exception {
init();
ServiceName serviceNameServer = Capabilities.SASL_SERVER_FACTORY_RUNTIME_CAPABILITY.getCapabilityServiceName("MySaslServer");
SaslServerFactory serverFactory = (SaslServerFactory) services.getContainer().getService(serviceNameServer).getValue();
Map<String, Object> serverClientProps = new HashMap<String, Object>();
serverClientProps.put("javax.security.sasl.qop", "auth-conf");
SaslServer server = serverFactory.createSaslServer(SaslMechanismInformation.Names.DIGEST_MD5,
"protocol", "TestingRealm1", serverClientProps, serverCallbackHandler("user1", "TestingRealm1", "password1"));
SaslClient client = Sasl.createSaslClient(new String[]{SaslMechanismInformation.Names.DIGEST_MD5},
"user1", "protocol", "TestingRealm1", serverClientProps, clientCallbackHandler("user1", "TestingRealm1", "password1"));
testSaslServerClient(server, client);
}
示例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);
}