本文整理汇总了Java中net.spy.memcached.auth.PlainCallbackHandler类的典型用法代码示例。如果您正苦于以下问题:Java PlainCallbackHandler类的具体用法?Java PlainCallbackHandler怎么用?Java PlainCallbackHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlainCallbackHandler类属于net.spy.memcached.auth包,在下文中一共展示了PlainCallbackHandler类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: SASLConnectReconnect
import net.spy.memcached.auth.PlainCallbackHandler; //导入依赖的package包/类
SASLConnectReconnect(String username, String password, String host) {
AuthDescriptor ad = new AuthDescriptor(new String[] { "PLAIN" },
new PlainCallbackHandler(username, password));
try {
List<InetSocketAddress> addresses = AddrUtil.getAddresses(host);
mc = new MemcachedClient(
new ConnectionFactoryBuilder().setProtocol(Protocol.BINARY)
.setAuthDescriptor(ad).build(), addresses);
} catch (IOException ex) {
System.err
.println("Couldn't create a connection, bailing out: \nIOException "
+ ex.getMessage());
if (mc != null) {
mc.shutdown();
}
}
}
开发者ID:naver,项目名称:arcus-java-client,代码行数:20,代码来源:SASLConnectReconnect.java
示例2: activateService
import net.spy.memcached.auth.PlainCallbackHandler; //导入依赖的package包/类
@Override
public void activateService()
throws Exception
{
MemcacheConfiguration config = configuration.get();
expiration = ( config.expiration().get() == null )
? 3600
: config.expiration().get();
String addresses = ( config.addresses().get() == null )
? "localhost:11211"
: config.addresses().get();
Protocol protocol = ( config.protocol().get() == null )
? Protocol.TEXT
: Protocol.valueOf( config.protocol().get().toUpperCase() );
String username = config.username().get();
String password = config.password().get();
String authMech = config.authMechanism().get() == null
? "PLAIN"
: config.authMechanism().get();
ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder();
builder.setProtocol( protocol );
if( username != null && !username.isEmpty() )
{
String[] authType = { authMech };
AuthDescriptor to = new AuthDescriptor( authType, new PlainCallbackHandler( username, password ) );
builder.setAuthDescriptor( to );
}
client = new MemcachedClient( builder.build(), AddrUtil.getAddresses( addresses ) );
}
开发者ID:apache,项目名称:polygene-java,代码行数:32,代码来源:MemcachePoolMixin.java
示例3: createAuthDescriptor
import net.spy.memcached.auth.PlainCallbackHandler; //导入依赖的package包/类
protected AuthDescriptor createAuthDescriptor() {
String username = properties.get(PROP_USERNAME);
String password = properties.get(PROP_PASSWORD);
if (username == null || password == null) {
return null;
}
return new AuthDescriptor(new String[]{"PLAIN"}, new PlainCallbackHandler(username, password));
}
开发者ID:mihaicostin,项目名称:hibernate-l2-memcached,代码行数:9,代码来源:SpyMemcacheClientFactory.java
示例4: generate
import net.spy.memcached.auth.PlainCallbackHandler; //导入依赖的package包/类
@Override
public AuthDescriptor generate(OverridableReadOnlyProperties properties) {
String username = properties.getRequiredProperty(USERNAME_PROPERTY_KEY);
String password = properties.getRequiredProperty(PASSWORD_PROPERTY_KEY);
AuthDescriptor authDescriptor = new AuthDescriptor(new String[]{"PLAIN"}, new PlainCallbackHandler(username, password));
return authDescriptor;
}
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:9,代码来源:PlainAuthDescriptorGenerator.java
示例5: generate
import net.spy.memcached.auth.PlainCallbackHandler; //导入依赖的package包/类
@Test
public void generate() throws Exception {
Properties props = new Properties();
props.setProperty(PlainAuthDescriptorGenerator.USERNAME_PROPERTY_KEY, "username");
props.setProperty(PlainAuthDescriptorGenerator.PASSWORD_PROPERTY_KEY, "password");
AuthDescriptor authDescriptor = generator.generate(new OverridableReadOnlyPropertiesImpl(props));
assertThat(authDescriptor).isNotNull();
assertThat(authDescriptor.getMechs()).isEqualTo(new String[]{"PLAIN"});
assertThat(authDescriptor.getCallback()).isExactlyInstanceOf(PlainCallbackHandler.class);
}
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:13,代码来源:PlainAuthDescriptorGeneratorTest.java
示例6: onActivate
import net.spy.memcached.auth.PlainCallbackHandler; //导入依赖的package包/类
@Override
public void onActivate( Application application )
throws ActivationException
{
// Gather Configuration
Config config = application.config().atKey( "memcache" );
Protocol protocol = Protocol.valueOf( config.string( "protocol" ).toUpperCase( Locale.US ) );
String addresses = config.string( "addresses" );
String username = config.has( "username" ) ? config.string( "username" ) : null;
String password = config.has( "password" ) ? config.string( "password" ) : null;
String authMech = config.string( "authMechanism" );
// Create Client
try
{
ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder();
builder.setProtocol( protocol );
if( !Strings.isEmpty( username ) )
{
builder.setAuthDescriptor(
new AuthDescriptor(
new String[]
{
authMech
},
new PlainCallbackHandler( username, password )
)
);
}
client = new MemcachedClient( builder.build(), AddrUtil.getAddresses( addresses ) );
}
catch( IOException ex )
{
throw new ActivationException( "Unable to Activate MemcachePlugin: " + ex.getMessage(), ex );
}
// Create Cache Instance
backingCache = config.bool( "metrics" )
? new MemcacheCache( application.plugin( Metrics.class ), client )
: new MemcacheCache( client );
}
开发者ID:werval,项目名称:werval,代码行数:42,代码来源:MemcachePlugin.java
注:本文中的net.spy.memcached.auth.PlainCallbackHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论