本文整理汇总了Java中org.apache.zookeeper.inspector.encryption.DataEncryptionManager类的典型用法代码示例。如果您正苦于以下问题:Java DataEncryptionManager类的具体用法?Java DataEncryptionManager怎么用?Java DataEncryptionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataEncryptionManager类属于org.apache.zookeeper.inspector.encryption包,在下文中一共展示了DataEncryptionManager类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import org.apache.zookeeper.inspector.encryption.DataEncryptionManager; //导入依赖的package包/类
public boolean connect(Properties connectionProps) {
try {
if (this.zooKeeper == null) {
String connectString = connectionProps
.getProperty(CONNECT_STRING);
String sessionTimeout = connectionProps
.getProperty(SESSION_TIMEOUT);
String encryptionManager = connectionProps
.getProperty(DATA_ENCRYPTION_MANAGER);
String authScheme = connectionProps
.getProperty(AUTH_SCHEME_KEY);
String authData = connectionProps
.getProperty(AUTH_DATA_KEY);
if (connectString == null || sessionTimeout == null) {
throw new IllegalArgumentException(
"Both connect string and session timeout are required.");
}
if (encryptionManager == null) {
this.encryptionManager = new BasicDataEncryptionManager();
} else {
Class<?> clazz = Class.forName(encryptionManager);
if (Arrays.asList(clazz.getInterfaces()).contains(
DataEncryptionManager.class)) {
this.encryptionManager = (DataEncryptionManager) Class
.forName(encryptionManager).newInstance();
} else {
throw new IllegalArgumentException(
"Data encryption manager must implement DataEncryptionManager interface");
}
}
this.connectString = connectString;
this.sessionTimeout = Integer.valueOf(sessionTimeout);
this.zooKeeper = new ZooKeeperRetry(connectString, Integer
.valueOf(sessionTimeout), new Watcher() {
public void process(WatchedEvent event) {
if (event.getState() == KeeperState.Expired) {
connected = false;
}
}
});
if (authData != null && authData.length() > 0){
this.zooKeeper.addAuthInfo(authScheme, authData.getBytes());
}
((ZooKeeperRetry) this.zooKeeper).setRetryLimit(10);
connected = ((ZooKeeperRetry) this.zooKeeper).testConnection();
}
} catch (Exception e) {
connected = false;
e.printStackTrace();
}
if (!connected){
disconnect();
}
return connected;
}
示例2: connect
import org.apache.zookeeper.inspector.encryption.DataEncryptionManager; //导入依赖的package包/类
public boolean connect(Properties connectionProps) {
try {
if (this.zooKeeper == null) {
String connectString = connectionProps
.getProperty(CONNECT_STRING);
String sessionTimeout = connectionProps
.getProperty(SESSION_TIMEOUT);
String encryptionManager = connectionProps
.getProperty(DATA_ENCRYPTION_MANAGER);
String authScheme = connectionProps
.getProperty(AUTH_SCHEME_KEY);
String authData = connectionProps
.getProperty(AUTH_DATA_KEY);
if (connectString == null || sessionTimeout == null) {
throw new IllegalArgumentException(
"Both connect string and session timeout are required.");
}
if (encryptionManager == null) {
this.encryptionManager = new BasicDataEncryptionManager();
} else {
Class<?> clazz = Class.forName(encryptionManager);
if (Arrays.asList(clazz.getInterfaces()).contains(
DataEncryptionManager.class)) {
this.encryptionManager = (DataEncryptionManager) Class
.forName(encryptionManager).newInstance();
} else {
throw new IllegalArgumentException(
"Data encryption manager must implement DataEncryptionManager interface");
}
}
this.connectString = connectString;
this.sessionTimeout = Integer.valueOf(sessionTimeout);
this.zooKeeper = new ZooKeeperRetry(connectString, Integer
.valueOf(sessionTimeout), new Watcher() {
public void process(WatchedEvent event) {
if (event.getState() == KeeperState.Expired) {
connected = false;
}
}
});
if (authData != null && authData.length() > 0){
this.zooKeeper.addAuthInfo(authScheme, authData.getBytes());
}
((ZooKeeperRetry) this.zooKeeper).setRetryLimit(10);
connected = ((ZooKeeperRetry) this.zooKeeper).testConnection();
}
} catch (Exception e) {
connected = false;
e.printStackTrace();
}
if (!connected){
disconnect();
} else {
this.nodesCache = new NodesCache(zooKeeper);
}
return connected;
}
示例3: connect
import org.apache.zookeeper.inspector.encryption.DataEncryptionManager; //导入依赖的package包/类
public boolean connect(Properties connectionProps) {
try {
if (this.zooKeeper == null) {
String connectString = connectionProps
.getProperty(CONNECT_STRING);
String sessionTimeout = connectionProps
.getProperty(SESSION_TIMEOUT);
String encryptionManager = connectionProps
.getProperty(DATA_ENCRYPTION_MANAGER);
if (connectString == null || sessionTimeout == null) {
throw new IllegalArgumentException(
"Both connect string and session timeout are required.");
}
if (encryptionManager == null) {
this.encryptionManager = new BasicDataEncryptionManager();
} else {
Class<?> clazz = Class.forName(encryptionManager);
if (Arrays.asList(clazz.getInterfaces()).contains(
DataEncryptionManager.class)) {
this.encryptionManager = (DataEncryptionManager) Class
.forName(encryptionManager).newInstance();
} else {
throw new IllegalArgumentException(
"Data encryption manager must implement DataEncryptionManager interface");
}
}
this.connectString = connectString;
this.sessionTimeout = Integer.valueOf(sessionTimeout);
this.zooKeeper = new ZooKeeperRetry(connectString, Integer
.valueOf(sessionTimeout), new Watcher() {
public void process(WatchedEvent event) {
if (event.getState() == KeeperState.Expired) {
connected = false;
}
}
});
((ZooKeeperRetry) this.zooKeeper).setRetryLimit(10);
connected = ((ZooKeeperRetry) this.zooKeeper).testConnection();
return connected;
}
} catch (Exception e) {
e.printStackTrace();
}
connected = false;
return connected;
}