当前位置: 首页>>代码示例>>Java>>正文


Java AuthDescriptor类代码示例

本文整理汇总了Java中net.spy.memcached.auth.AuthDescriptor的典型用法代码示例。如果您正苦于以下问题:Java AuthDescriptor类的具体用法?Java AuthDescriptor怎么用?Java AuthDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AuthDescriptor类属于net.spy.memcached.auth包,在下文中一共展示了AuthDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildDefaultConnectionFactory

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的package包/类
private DefaultConnectionFactory buildDefaultConnectionFactory() {
    return new DefaultConnectionFactory(getOperationQueueLength(), getReadBufferSize(), getHashAlgorithm()) {
        @Override
        public long getOperationTimeout() {
            return getOperationTimeoutMillis();
        }

        @Override
        public boolean isDaemon() {
            return isDaemonMode();
        }

        @Override
        public AuthDescriptor getAuthDescriptor() {
            return createAuthDescriptor();
        }
    };
}
 
开发者ID:mihaicostin,项目名称:hibernate-l2-memcached,代码行数:19,代码来源:SpyMemcacheClientFactory.java

示例2: buildKetamaConnectionFactory

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的package包/类
private KetamaConnectionFactory buildKetamaConnectionFactory() {
    return new KetamaConnectionFactory() {
        @Override
        public long getOperationTimeout() {
            return getOperationTimeoutMillis();
        }

        @Override
        public boolean isDaemon() {
            return isDaemonMode();
        }

        @Override
        public AuthDescriptor getAuthDescriptor() {
            return createAuthDescriptor();
        }
    };
}
 
开发者ID:mihaicostin,项目名称:hibernate-l2-memcached,代码行数:19,代码来源:SpyMemcacheClientFactory.java

示例3: buildBinaryConnectionFactory

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的package包/类
private BinaryConnectionFactory buildBinaryConnectionFactory() {
    return new BinaryConnectionFactory(getOperationQueueLength(), getReadBufferSize(), getHashAlgorithm()) {
        @Override
        public long getOperationTimeout() {
            return getOperationTimeoutMillis();
        }

        @Override
        public boolean isDaemon() {
            return isDaemonMode();
        }

        @Override
        public AuthDescriptor getAuthDescriptor() {
            return createAuthDescriptor();
        }
    };
}
 
开发者ID:mihaicostin,项目名称:hibernate-l2-memcached,代码行数:19,代码来源:SpyMemcacheClientFactory.java

示例4: createConnectionFactoryBuilder

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的package包/类
@Test
public void createConnectionFactoryBuilder() throws Exception {
    Properties props = new Properties();
    props.setProperty(HASH_ALGORITHM_PROPERTY_KEY, DefaultHashAlgorithm.NATIVE_HASH.name());
    props.setProperty(OPERATION_TIMEOUT_MILLIS_PROPERTY_KEY, String.valueOf(13579));
    props.setProperty(TRANSCODER_PROPERTY_KEY, FakeTranscoder.class.getName());
    props.setProperty(AUTH_GENERATOR_PROPERTY_KEY, FakeAuthDescriptorGenerator.class.getName());

    ConnectionFactoryBuilder builder = spyMemcachedAdapter.createConnectionFactoryBuilder(new OverridableReadOnlyPropertiesImpl(props));

    ConnectionFactory connectionFactory = builder.build();
    assertThat(connectionFactory.getHashAlg()).isEqualTo(DefaultHashAlgorithm.NATIVE_HASH);
    assertThat(connectionFactory.getOperationTimeout()).isEqualTo(13579);

    Transcoder<Object> transcoder = connectionFactory.getDefaultTranscoder();
    assertThat(transcoder).isExactlyInstanceOf(FakeTranscoder.class);
    FakeTranscoder fakeTranscoder = (FakeTranscoder) transcoder;
    assertThat(fakeTranscoder.isInitialized()).isTrue();

    AuthDescriptor authDescriptor = connectionFactory.getAuthDescriptor();
    assertThat(authDescriptor.getMechs()).isEqualTo(FakeAuthDescriptorGenerator.FAKE_MECHS);
}
 
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:23,代码来源:SpyMemcachedAdapterTest.java

示例5: SASLConnectReconnect

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的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

示例6: activateService

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的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

示例7: createAuthDescriptor

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的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

示例8: generate

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的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

示例9: generate

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的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

示例10: ApiMemcached

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的package包/类
public ApiMemcached() {
	AppConstants ac = AppConstants.getInstance();
	String address = ac.getProperty("etag.cache.server", "localhost:11211");
	String username = ac.getProperty("etag.cache.username", "");
	String password = ac.getProperty("etag.cache.password", "");
	int timeout = ac.getInt("etag.cache.timeout", 10);

	List<InetSocketAddress> addresses = AddrUtil.getAddresses(address);

	ConnectionFactoryBuilder connectionFactoryBuilder = new ConnectionFactoryBuilder()
		.setProtocol(Protocol.BINARY)
		.setOpTimeout(timeout)
		.setInitialObservers(Collections.singleton(obs));

	if(addresses.size()  > 1)
		connectionFactoryBuilder.setFailureMode(FailureMode.Redistribute);
	else
		connectionFactoryBuilder.setFailureMode(FailureMode.Retry);

	if(!username.isEmpty())
		connectionFactoryBuilder.setAuthDescriptor(AuthDescriptor.typical(username, password));

	ConnectionFactory cf = connectionFactoryBuilder.build();

	try {
		client = new MemcachedClient(cf, addresses);
		//Fetching a none-existing key to test the connection
		Future<Object> future = client.asyncGet("test-connection");
		future.get(timeout, TimeUnit.MILLISECONDS);
	} catch (Exception e) {
		ConfigurationWarnings.getInstance().add(log, "Unable to connect to one or more memcached servers.", null, true);
	}
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:34,代码来源:ApiMemcached.java

示例11: setAuthDescriptor

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的package包/类
public void setAuthDescriptor(final AuthDescriptor to) {
  connectionFactoryBuilder.setAuthDescriptor(to);
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:4,代码来源:MemcachedClientFactoryBean.java

示例12: getAuthDescriptor

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的package包/类
public AuthDescriptor getAuthDescriptor() {
  return null;
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:4,代码来源:DefaultConnectionFactory.java

示例13: setAuthDescriptor

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的package包/类
/**
 * Set the auth descriptor to enable authentication on new connections.
 */
public ConnectionFactoryBuilder setAuthDescriptor(AuthDescriptor to) {
  authDescriptor = to;
  return this;
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:8,代码来源:ConnectionFactoryBuilder.java

示例14: onActivate

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的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

示例15: generate

import net.spy.memcached.auth.AuthDescriptor; //导入依赖的package包/类
@Override
public AuthDescriptor generate(OverridableReadOnlyProperties properties) {
    return new AuthDescriptor(FAKE_MECHS, null);
}
 
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:5,代码来源:SpyMemcachedAdapterTest.java


注:本文中的net.spy.memcached.auth.AuthDescriptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。