本文整理汇总了Java中javax.security.sasl.SaslServerFactory类的典型用法代码示例。如果您正苦于以下问题:Java SaslServerFactory类的具体用法?Java SaslServerFactory怎么用?Java SaslServerFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SaslServerFactory类属于javax.security.sasl包,在下文中一共展示了SaslServerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performRuntime
import javax.security.sasl.SaslServerFactory; //导入依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
throws OperationFailedException {
RuntimeCapability<Void> runtimeCapability = SASL_SERVER_FACTORY_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue());
ServiceName saslServerFactoryName = runtimeCapability.getCapabilityServiceName(SaslServerFactory.class);
commonDependencies(installService(context, saslServerFactoryName, model))
.setInitialMode(Mode.ACTIVE)
.install();
}
示例2: getServerFactoryClassForJCARegistration
import javax.security.sasl.SaslServerFactory; //导入依赖的package包/类
public Class<? extends SaslServerFactory> getServerFactoryClassForJCARegistration()
{
// since the CRAM-MD5 provider is registered as part of the JDK, we do not
// return the factory class here since we do not need to register it ourselves.
if (_hashDirection == HashDirection.PASSWORD_FILE)
{
return null;
}
else
{
//fixme we need a server that will correctly has the incomming plain text for comparison to file.
_logger.warn("we need a server that will correctly convert the incomming plain text for comparison to file.");
return null;
}
}
示例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 {
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;
}
示例4: 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());
}
}
示例5: 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);
}
}
示例6: initialise
import javax.security.sasl.SaslServerFactory; //导入依赖的package包/类
public void initialise()
{
final Map<String, Class<? extends SaslServerFactory>> providerMap = new TreeMap<String, Class<? extends SaslServerFactory>>();
initialiseAuthenticationMechanisms(providerMap, _principalDatabase);
if (providerMap.size() > 0)
{
// Ensure we are used before the defaults
if (Security.insertProviderAt(new JCAProvider(PROVIDER_NAME, providerMap), 1) == -1)
{
_logger.error("Unable to load custom SASL providers. Qpid custom SASL authenticators unavailable.");
}
else
{
_logger.info("Additional SASL providers successfully registered.");
}
}
else
{
_logger.warn("No additional SASL providers registered.");
}
registerManagement();
}
示例7: initialiseAuthenticationMechanism
import javax.security.sasl.SaslServerFactory; //导入依赖的package包/类
private void initialiseAuthenticationMechanism(String mechanism, AuthenticationProviderInitialiser initialiser,
Map<String, Class<? extends SaslServerFactory>> providerMap)
{
if (_mechanisms == null)
{
_mechanisms = mechanism;
}
else
{
// simple append should be fine since the number of mechanisms is small and this is a one time initialisation
_mechanisms = _mechanisms + " " + mechanism;
}
_callbackHandlerMap.put(mechanism, initialiser.getCallbackHandler());
_serverCreationProperties.put(mechanism, initialiser.getProperties());
Class<? extends SaslServerFactory> factory = initialiser.getServerFactoryClassForJCARegistration();
if (factory != null)
{
providerMap.put(mechanism, factory);
}
_logger.info("Initialised " + mechanism + " SASL provider successfully");
}
示例8: 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);
}
示例9: 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);
}
}
}
示例10: 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;
}
示例11: 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);
}
示例12: getImplementedMechanisms
import javax.security.sasl.SaslServerFactory; //导入依赖的package包/类
/**
* Returns a collection of mechanism names for which the JVM has an implementation available.
* <p/>
* Note that this need not (and likely will not) correspond with the list of mechanisms that is offered to XMPP
* peer entities, which is provided by #getSupportedMechanisms.
*
* @return a collection of SASL mechanism names (never null, possibly empty)
*/
public static Set<String> getImplementedMechanisms()
{
final Set<String> result = new HashSet<>();
final Enumeration<SaslServerFactory> saslServerFactories = Sasl.getSaslServerFactories();
while ( saslServerFactories.hasMoreElements() )
{
final SaslServerFactory saslServerFactory = saslServerFactories.nextElement();
Collections.addAll( result, saslServerFactory.getMechanismNames( null ) );
}
return result;
}
示例13: 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);
}
示例14: getProviderSaslServerFactoryDefinition
import javax.security.sasl.SaslServerFactory; //导入依赖的package包/类
static ResourceDefinition getProviderSaslServerFactoryDefinition() {
AbstractAddStepHandler add = new SaslServerAddHandler(PROVIDERS) {
@Override
protected ServiceBuilder<SaslServerFactory> installService(OperationContext context,
ServiceName saslServerFactoryName, ModelNode model) throws OperationFailedException {
String providers = PROVIDERS.resolveModelAttribute(context, model).asStringOrNull();
final InjectedValue<Provider[]> providerInjector = new InjectedValue<Provider[]>();
final Supplier<Provider[]> providerSupplier = providers != null ? (providerInjector::getValue) : (Security::getProviders);
TrivialService<SaslServerFactory> saslServiceFactoryService = new TrivialService<SaslServerFactory>(() -> new SecurityProviderSaslServerFactory(providerSupplier));
ServiceTarget serviceTarget = context.getServiceTarget();
ServiceBuilder<SaslServerFactory> serviceBuilder = serviceTarget.addService(saslServerFactoryName, saslServiceFactoryService);
if (providers != null) {
serviceBuilder.addDependency(context.getCapabilityServiceName(RuntimeCapability.buildDynamicCapabilityName(PROVIDERS_CAPABILITY, providers),
Provider[].class), Provider[].class, providerInjector);
}
return serviceBuilder;
}
};
return wrap(new SaslServerResourceDefinition(ElytronDescriptionConstants.PROVIDER_SASL_SERVER_FACTORY, add, PROVIDERS), SaslServerDefinitions::getSaslServerAvailableMechanisms);
}
示例15: getSaslServerAvailableMechanisms
import javax.security.sasl.SaslServerFactory; //导入依赖的package包/类
private static String[] getSaslServerAvailableMechanisms(OperationContext context) {
RuntimeCapability<Void> runtimeCapability = SASL_SERVER_FACTORY_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue());
ServiceName saslServerFactoryName = runtimeCapability.getCapabilityServiceName(SaslServerFactory.class);
ServiceController<SaslServerFactory> serviceContainer = getRequiredService(context.getServiceRegistry(false), saslServerFactoryName, SaslServerFactory.class);
if (serviceContainer.getState() != State.UP) {
return null;
}
return serviceContainer.getValue().getMechanismNames(Collections.emptyMap());
}