本文整理汇总了Java中org.apache.curator.framework.AuthInfo类的典型用法代码示例。如果您正苦于以下问题:Java AuthInfo类的具体用法?Java AuthInfo怎么用?Java AuthInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthInfo类属于org.apache.curator.framework包,在下文中一共展示了AuthInfo类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createConnection
import org.apache.curator.framework.AuthInfo; //导入依赖的package包/类
private void createConnection() throws Exception {
// Curator connection
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder();
builder = builder.connectString(zkHostPort)
.connectionTimeoutMs(zkSessionTimeout)
.retryPolicy(new RetryNTimes(numRetries, zkRetryInterval));
// Set up authorization based on fencing scheme
List<AuthInfo> authInfos = new ArrayList<>();
for (ZKUtil.ZKAuthInfo zkAuth : zkAuths) {
authInfos.add(new AuthInfo(zkAuth.getScheme(), zkAuth.getAuth()));
}
if (useDefaultFencingScheme) {
byte[] defaultFencingAuth =
(zkRootNodeUsername + ":" + zkRootNodePassword).getBytes(
Charset.forName("UTF-8"));
authInfos.add(new AuthInfo(zkRootNodeAuthScheme, defaultFencingAuth));
}
builder = builder.authorization(authInfos);
// Connect to ZK
curatorFramework = builder.build();
curatorFramework.start();
}
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:25,代码来源:ZKRMStateStore.java
示例2: enhanceBuilderWithSecurityParameters
import org.apache.curator.framework.AuthInfo; //导入依赖的package包/类
@VisibleForTesting
void enhanceBuilderWithSecurityParameters(HAConfiguration.ZookeeperProperties zookeeperProperties,
CuratorFrameworkFactory.Builder builder) {
ACLProvider aclProvider = getAclProvider(zookeeperProperties);
AuthInfo authInfo = null;
if (zookeeperProperties.hasAuth()) {
authInfo = AtlasZookeeperSecurityProperties.parseAuth(zookeeperProperties.getAuth());
}
if (aclProvider != null) {
LOG.info("Setting up acl provider.");
builder.aclProvider(aclProvider);
if (authInfo != null) {
byte[] auth = authInfo.getAuth();
LOG.info("Setting up auth provider with scheme: {} and id: {}", authInfo.getScheme(),
getIdForLogging(authInfo.getScheme(), new String(auth, Charsets.UTF_8)));
builder.authorization(authInfo.getScheme(), auth);
}
}
}
开发者ID:apache,项目名称:incubator-atlas,代码行数:23,代码来源:CuratorFactory.java
示例3: makeZookeeperFactory
import org.apache.curator.framework.AuthInfo; //导入依赖的package包/类
private ZookeeperFactory makeZookeeperFactory(final ZookeeperFactory actualZookeeperFactory)
{
return new ZookeeperFactory()
{
@Override
public ZooKeeper newZooKeeper(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly) throws Exception
{
ZooKeeper zooKeeper = actualZookeeperFactory.newZooKeeper(connectString, sessionTimeout, watcher, canBeReadOnly);
for ( AuthInfo auth : authInfos )
{
zooKeeper.addAuthInfo(auth.getScheme(), auth.getAuth());
}
return zooKeeper;
}
};
}
开发者ID:apache,项目名称:curator,代码行数:18,代码来源:CuratorFrameworkImpl.java
示例4: authInfo
import org.apache.curator.framework.AuthInfo; //导入依赖的package包/类
public List<AuthInfo> authInfo() {
String username = env.getProperty("rpc.client.zookeeper.username");
String password = env.getProperty("rpc.client.zookeeper.password");
List<AuthInfo> info = new ArrayList<AuthInfo>();
info.add(new DigestAuthInfo(username, password));
return info;
}
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:8,代码来源:HelloClientConfig.java
示例5: authInfo
import org.apache.curator.framework.AuthInfo; //导入依赖的package包/类
public List<AuthInfo> authInfo() {
String username = env.getProperty("rpc.server.zookeeper.username");
String password = env.getProperty("rpc.server.zookeeper.password");
List<AuthInfo> info = new ArrayList<AuthInfo>();
info.add(new DigestAuthInfo(username, password));
return info;
}
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:8,代码来源:HelloServerConfig.java
示例6: authInfo
import org.apache.curator.framework.AuthInfo; //导入依赖的package包/类
@Bean
public List<AuthInfo> authInfo() {
String username = env.getProperty("rpc.client.zookeeper.username");
String password = env.getProperty("rpc.client.zookeeper.password");
List<AuthInfo> info = new ArrayList<AuthInfo>();
info.add(new DigestAuthInfo(username, password));
return info;
}
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:9,代码来源:HelloClientConfig.java
示例7: createInstance
import org.apache.curator.framework.AuthInfo; //导入依赖的package包/类
@Override
protected CuratorFramework createInstance() throws Exception {
String connectionString = resolveConnectionString();
if(connectionString==null) {
throw new IllegalArgumentException("Cannot resolve zookeeper connection string");
}
RetryPolicy retryPolicy = new ExponentialBackoffRetry(baseSleepTime, maxRetries);
Builder curatorFrameworkBuilder = CuratorFrameworkFactory.builder()
.connectString(connectionString)
.retryPolicy(retryPolicy)
.canBeReadOnly(canReadOnly);
String credentialString = resolveCredentialString();
if(credentialString!=null) {
String[] credentials = StringUtils.tokenizeToStringArray(credentialString, STRING_ARRAY_SEPARATOR);
List<AuthInfo> authList = new ArrayList<AuthInfo>();
for(String cred : credentials){
String[] aclId = cred.split(":");
String passwd = new String(Base64.decodeBase64(aclId[1].trim()),"UTF-8");
authList.add(new AuthInfo(
SCHEME_DIGEST,
String.format("%s:%s", aclId[0].trim(), passwd).getBytes()));
}
if(!authList.isEmpty()) {
curatorFrameworkBuilder.authorization(authList);
}
}
CuratorFramework client = curatorFrameworkBuilder.build();
client.start();
return client;
}
开发者ID:hekailiang,项目名称:cloud-config,代码行数:37,代码来源:ZkClientFactoryBean.java
示例8: buildAuths
import org.apache.curator.framework.AuthInfo; //导入依赖的package包/类
private List<AuthInfo> buildAuths(CuratorFrameworkFactory.Builder builder)
{
ImmutableList.Builder<AuthInfo> builder1 = ImmutableList.builder();
if ( builder.getAuthInfos() != null )
{
builder1.addAll(builder.getAuthInfos());
}
return builder1.build();
}
开发者ID:apache,项目名称:curator,代码行数:10,代码来源:CuratorFrameworkImpl.java
示例9: authInfo
import org.apache.curator.framework.AuthInfo; //导入依赖的package包/类
private List<AuthInfo> authInfo() {
List<AuthInfo> info = new ArrayList<AuthInfo>();
info.add(new DigestAuthInfo(this.zkUsername, this.zkPassword));
return info;
}
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:6,代码来源:RpcServerConfiguration.java
示例10: shouldGetAuth
import org.apache.curator.framework.AuthInfo; //导入依赖的package包/类
@Test
public void shouldGetAuth() {
AuthInfo authInfo = AtlasZookeeperSecurityProperties.parseAuth("digest:user:password");
assertEquals(authInfo.getScheme(), "digest");
assertEquals(authInfo.getAuth(), "user:password".getBytes(Charsets.UTF_8));
}
开发者ID:apache,项目名称:incubator-atlas,代码行数:7,代码来源:AtlasZookeeperSecurityPropertiesTest.java
示例11: createAndStartCurator
import org.apache.curator.framework.AuthInfo; //导入依赖的package包/类
public CuratorFramework createAndStartCurator(Configuration conf)
throws Exception {
String zkHostPort = conf.get(YarnConfiguration.RM_ZK_ADDRESS);
if (zkHostPort == null) {
throw new YarnRuntimeException(
YarnConfiguration.RM_ZK_ADDRESS + " is not configured.");
}
int numRetries = conf.getInt(YarnConfiguration.RM_ZK_NUM_RETRIES,
YarnConfiguration.DEFAULT_ZK_RM_NUM_RETRIES);
int zkSessionTimeout = conf.getInt(YarnConfiguration.RM_ZK_TIMEOUT_MS,
YarnConfiguration.DEFAULT_RM_ZK_TIMEOUT_MS);
int zkRetryInterval = conf.getInt(YarnConfiguration.RM_ZK_RETRY_INTERVAL_MS,
YarnConfiguration.DEFAULT_RM_ZK_RETRY_INTERVAL_MS);
// set up zk auths
List<ZKUtil.ZKAuthInfo> zkAuths = RMZKUtils.getZKAuths(conf);
List<AuthInfo> authInfos = new ArrayList<>();
for (ZKUtil.ZKAuthInfo zkAuth : zkAuths) {
authInfos.add(new AuthInfo(zkAuth.getScheme(), zkAuth.getAuth()));
}
if (HAUtil.isHAEnabled(conf) && HAUtil.getConfValueForRMInstance(
YarnConfiguration.ZK_RM_STATE_STORE_ROOT_NODE_ACL, conf) == null) {
String zkRootNodeUsername = HAUtil
.getConfValueForRMInstance(YarnConfiguration.RM_ADDRESS,
YarnConfiguration.DEFAULT_RM_ADDRESS, conf);
byte[] defaultFencingAuth =
(zkRootNodeUsername + ":" + zkRootNodePassword)
.getBytes(Charset.forName("UTF-8"));
authInfos.add(new AuthInfo(new DigestAuthenticationProvider().getScheme(),
defaultFencingAuth));
}
CuratorFramework client = CuratorFrameworkFactory.builder()
.connectString(zkHostPort)
.sessionTimeoutMs(zkSessionTimeout)
.retryPolicy(new RetryNTimes(numRetries, zkRetryInterval))
.authorization(authInfos).build();
client.start();
return client;
}
开发者ID:hopshadoop,项目名称:hops,代码行数:42,代码来源:ResourceManager.java
示例12: parseAuth
import org.apache.curator.framework.AuthInfo; //导入依赖的package包/类
/**
* Get an {@link AuthInfo} by parsing input string.
* @param authString A string of the form scheme:authString
* @return {@link AuthInfo} with the scheme and auth taken from configuration values.
*/
public static AuthInfo parseAuth(String authString) {
String[] authComponents = getComponents(authString, "authString", "scheme:authString");
return new AuthInfo(authComponents[0], authComponents[1].getBytes(Charsets.UTF_8));
}
开发者ID:apache,项目名称:incubator-atlas,代码行数:10,代码来源:AtlasZookeeperSecurityProperties.java
注:本文中的org.apache.curator.framework.AuthInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论