- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.accumulo.server.security.handler.ZKSecurityTool
类的一些代码示例,展示了ZKSecurityTool
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKSecurityTool
类的具体详情如下:
包路径:org.apache.accumulo.server.security.handler.ZKSecurityTool
类名称:ZKSecurityTool
[英]All the static too methods used for this class, so that we can separate out stuff that isn't using ZooKeeper. That way, we can check the synchronization model more easily, as we only need to check to make sure zooCache is cleared when things are written to ZooKeeper in methods that might use it. These won't, and so don't need to be checked.
[中]这个类使用的所有静态方法,所以我们可以分离出没有使用ZooKeeper的东西。这样,我们可以更容易地检查同步模型,因为我们只需要检查以确保在可能使用ZooKeeper的方法中将内容写入zooCache时,zooCache被清除。这些不会,所以不需要检查。
代码示例来源:origin: apache/accumulo
@Override
public boolean authenticateUser(String principal, AuthenticationToken token)
throws AccumuloSecurityException {
if (!(token instanceof PasswordToken))
throw new AccumuloSecurityException(principal, SecurityErrorCode.INVALID_TOKEN);
PasswordToken pt = (PasswordToken) token;
byte[] pass;
String zpath = ZKUserPath + "/" + principal;
pass = zooCache.get(zpath);
boolean result = ZKSecurityTool.checkPass(pt.getPassword(), pass);
if (!result) {
zooCache.clear(zpath);
pass = zooCache.get(zpath);
result = ZKSecurityTool.checkPass(pt.getPassword(), pass);
}
return result;
}
代码示例来源:origin: apache/accumulo
@Override
public Authorizations getCachedUserAuthorizations(String user) {
byte[] authsBytes = zooCache.get(ZKUserPath + "/" + user + ZKUserAuths);
if (authsBytes != null)
return ZKSecurityTool.convertAuthorizations(authsBytes);
return Authorizations.EMPTY;
}
代码示例来源:origin: apache/accumulo
public static byte[] createPass(byte[] password) throws AccumuloException {
byte[] salt = generateSalt();
try {
return convertPass(password, salt);
} catch (NoSuchAlgorithmException e) {
log.error("Count not create hashed password", e);
throw new AccumuloException("Count not create hashed password", e);
}
}
代码示例来源:origin: apache/accumulo
@Override
public boolean hasCachedTablePermission(String user, String table, TablePermission permission) {
byte[] serializedPerms = zooCache.get(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
if (serializedPerms != null) {
return ZKSecurityTool.convertTablePermissions(serializedPerms).contains(permission);
}
return false;
}
代码示例来源:origin: apache/accumulo
@Override
public boolean hasCachedSystemPermission(String user, SystemPermission permission) {
byte[] perms = zooCache.get(ZKUserPath + "/" + user + ZKUserSysPerms);
if (perms == null)
return false;
return ZKSecurityTool.convertSystemPermissions(perms).contains(permission);
}
代码示例来源:origin: apache/accumulo
@Override
public void initializeSecurity(String principal, byte[] token) {
try {
// remove old settings from zookeeper first, if any
IZooReaderWriter zoo = context.getZooReaderWriter();
synchronized (zooCache) {
zooCache.clear();
if (zoo.exists(ZKUserPath)) {
zoo.recursiveDelete(ZKUserPath, NodeMissingPolicy.SKIP);
log.info("Removed {}/ from zookeeper", ZKUserPath);
}
// prep parent node of users with root username
zoo.putPersistentData(ZKUserPath, principal.getBytes(UTF_8), NodeExistsPolicy.FAIL);
constructUser(principal, ZKSecurityTool.createPass(token));
}
} catch (KeeperException | AccumuloException | InterruptedException e) {
log.error("{}", e.getMessage(), e);
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/accumulo
@Override
public void initialize(ServerContext context, boolean initialize) {
zooCache = new ZooCache(context.getZooReaderWriter(), null);
zoo = context.getZooReaderWriter();
String instanceId = context.getInstanceID();
ZKUserPath = ZKSecurityTool.getInstancePath(instanceId) + "/users";
ZKTablePath = ZKSecurityTool.getInstancePath(instanceId) + "/tables";
ZKNamespacePath = ZKSecurityTool.getInstancePath(instanceId) + "/namespaces";
}
代码示例来源:origin: apache/accumulo
private static byte[] convertPass(byte[] password, byte[] salt) throws NoSuchAlgorithmException {
byte[] plainSalt = new byte[password.length + SALT_LENGTH];
System.arraycopy(password, 0, plainSalt, 0, password.length);
System.arraycopy(salt, 0, plainSalt, password.length, SALT_LENGTH);
byte[] hashed = hash(plainSalt);
byte[] saltedHash = new byte[SALT_LENGTH + hashed.length];
System.arraycopy(salt, 0, saltedHash, 0, SALT_LENGTH);
System.arraycopy(hashed, 0, saltedHash, SALT_LENGTH, hashed.length);
return saltedHash; // contains salt+hash(password+salt)
}
代码示例来源:origin: apache/accumulo
public static boolean checkPass(byte[] password, byte[] zkData) {
if (zkData == null)
return false;
byte[] salt = new byte[SALT_LENGTH];
System.arraycopy(zkData, 0, salt, 0, SALT_LENGTH);
byte[] passwordToCheck;
try {
passwordToCheck = convertPass(password, salt);
} catch (NoSuchAlgorithmException e) {
log.error("Count not create hashed password", e);
return false;
}
return MessageDigest.isEqual(passwordToCheck, zkData);
}
代码示例来源:origin: apache/accumulo
@Override
public boolean hasCachedNamespacePermission(String user, String namespace,
NamespacePermission permission) {
byte[] serializedPerms = zooCache
.get(ZKUserPath + "/" + user + ZKUserNamespacePerms + "/" + namespace);
if (serializedPerms != null) {
return ZKSecurityTool.convertNamespacePermissions(serializedPerms).contains(permission);
}
return false;
}
代码示例来源:origin: apache/accumulo
/**
* Sets up a new table configuration for the provided user/table. No checking for existence is
* done here, it should be done before calling.
*/
private void createTablePerm(String user, Table.ID table, Set<TablePermission> perms)
throws KeeperException, InterruptedException {
synchronized (zooCache) {
zooCache.clear();
zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table,
ZKSecurityTool.convertTablePermissions(perms), NodeExistsPolicy.FAIL);
}
}
代码示例来源:origin: apache/accumulo
@Override
public void revokeSystemPermission(String user, SystemPermission permission)
throws AccumuloSecurityException {
byte[] sysPermBytes = zooCache.get(ZKUserPath + "/" + user + ZKUserSysPerms);
// User had no system permission, nothing to revoke.
if (sysPermBytes == null)
return;
Set<SystemPermission> sysPerms = ZKSecurityTool.convertSystemPermissions(sysPermBytes);
try {
if (sysPerms.remove(permission)) {
synchronized (zooCache) {
zooCache.clear();
zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserSysPerms,
ZKSecurityTool.convertSystemPermissions(sysPerms), NodeExistsPolicy.OVERWRITE);
}
}
} catch (KeeperException e) {
log.error("{}", e.getMessage(), e);
throw new AccumuloSecurityException(user, SecurityErrorCode.CONNECTION_ERROR, e);
} catch (InterruptedException e) {
log.error("{}", e.getMessage(), e);
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/accumulo
@Override
public void createUser(String principal, AuthenticationToken token)
throws AccumuloSecurityException {
try {
if (!(token instanceof PasswordToken))
throw new AccumuloSecurityException(principal, SecurityErrorCode.INVALID_TOKEN);
PasswordToken pt = (PasswordToken) token;
constructUser(principal, ZKSecurityTool.createPass(pt.getPassword()));
} catch (KeeperException e) {
if (e.code().equals(KeeperException.Code.NODEEXISTS))
throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_EXISTS, e);
throw new AccumuloSecurityException(principal, SecurityErrorCode.CONNECTION_ERROR, e);
} catch (InterruptedException e) {
log.error("{}", e.getMessage(), e);
throw new RuntimeException(e);
} catch (AccumuloException e) {
log.error("{}", e.getMessage(), e);
throw new AccumuloSecurityException(principal, SecurityErrorCode.DEFAULT_SECURITY_ERROR, e);
}
}
代码示例来源:origin: apache/accumulo
@Override
public void initialize(ServerContext context, boolean initialize) {
this.context = context;
zooCache = new ZooCache(context.getZooReaderWriter(), null);
ZKUserPath = ZKSecurityTool.getInstancePath(context.getInstanceID()) + "/users";
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
private static byte[] convertPass(byte[] password, byte[] salt) throws NoSuchAlgorithmException {
byte[] plainSalt = new byte[password.length + SALT_LENGTH];
System.arraycopy(password, 0, plainSalt, 0, password.length);
System.arraycopy(salt, 0, plainSalt, password.length, SALT_LENGTH);
byte[] hashed = hash(plainSalt);
byte[] saltedHash = new byte[SALT_LENGTH + hashed.length];
System.arraycopy(salt, 0, saltedHash, 0, SALT_LENGTH);
System.arraycopy(hashed, 0, saltedHash, SALT_LENGTH, hashed.length);
return saltedHash; // contains salt+hash(password+salt)
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
public static boolean checkPass(byte[] password, byte[] zkData) {
if (zkData == null)
return false;
byte[] salt = new byte[SALT_LENGTH];
System.arraycopy(zkData, 0, salt, 0, SALT_LENGTH);
byte[] passwordToCheck;
try {
passwordToCheck = convertPass(password, salt);
} catch (NoSuchAlgorithmException e) {
log.error("Count not create hashed password", e);
return false;
}
return java.util.Arrays.equals(passwordToCheck, zkData);
}
代码示例来源:origin: apache/accumulo
/**
* Sets up a new namespace configuration for the provided user/table. No checking for existence is
* done here, it should be done before calling.
*/
private void createNamespacePerm(String user, Namespace.ID namespace,
Set<NamespacePermission> perms) throws KeeperException, InterruptedException {
synchronized (zooCache) {
zooCache.clear();
zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserNamespacePerms + "/" + namespace,
ZKSecurityTool.convertNamespacePermissions(perms), NodeExistsPolicy.FAIL);
}
}
代码示例来源:origin: apache/accumulo
@Override
public void grantTablePermission(String user, String table, TablePermission permission)
throws AccumuloSecurityException {
Set<TablePermission> tablePerms;
byte[] serializedPerms = zooCache.get(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
if (serializedPerms != null)
tablePerms = ZKSecurityTool.convertTablePermissions(serializedPerms);
else
tablePerms = new TreeSet<>();
try {
if (tablePerms.add(permission)) {
synchronized (zooCache) {
zooCache.clear(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table);
zoo.putPersistentData(ZKUserPath + "/" + user + ZKUserTablePerms + "/" + table,
ZKSecurityTool.convertTablePermissions(tablePerms), NodeExistsPolicy.OVERWRITE);
}
}
} catch (KeeperException e) {
log.error("{}", e.getMessage(), e);
throw new AccumuloSecurityException(user, SecurityErrorCode.CONNECTION_ERROR, e);
} catch (InterruptedException e) {
log.error("{}", e.getMessage(), e);
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/accumulo
@Override
public boolean hasSystemPermission(String user, SystemPermission permission) {
byte[] perms;
try {
String path = ZKUserPath + "/" + user + ZKUserSysPerms;
zoo.sync(path);
perms = zoo.getData(path, null);
} catch (KeeperException e) {
if (e.code() == Code.NONODE) {
return false;
}
log.warn("Unhandled KeeperException, failing closed for table permission check", e);
return false;
} catch (InterruptedException e) {
log.warn("Unhandled InterruptedException, failing closed for table permission check", e);
return false;
}
if (perms == null)
return false;
return ZKSecurityTool.convertSystemPermissions(perms).contains(permission);
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
public static byte[] createPass(byte[] password) throws AccumuloException {
byte[] salt = generateSalt();
try {
return convertPass(password, salt);
} catch (NoSuchAlgorithmException e) {
log.error("Count not create hashed password", e);
throw new AccumuloException("Count not create hashed password", e);
}
}
在我的应用中,我使用 IntentService 发送短信。 @Override protected void onHandleIntent(Intent intent) { Bund
Handler(android.os.Handler.Callback) 已弃用,我应该改用什么? Handler handler = new Handler(new Handler.Callback
机器人Handler类包含此方法: public final boolean postAtTime (Runnable r, Object token, long uptimeMillis) 在给定时
我不明白怎么用这个方法, sensorManager.registerListener(SensorEventListener listener, Sensor sensor, int rate, H
请告诉我 handler.postAtTime 和 handler.postDelayed 在 android 中的区别,也请指导我何时使用 handler.postAtTime 以及何时使用 han
我有以下代码。 function myFun() { alert(5) } $(document).ready(fu
我有this jsfiddle 它使用 toggle event - 不要与 toggle 混淆- jQuery 版本设置为 EDGE 它突然停止工作并删除了我想要作为触发器的单元格,因为它显然恢复为
在我的应用程序中,我定义了一个自定义事件,我希望为其设置默认处理程序。如果任何 Controller /服务想要覆盖默认处理,他们可以通过添加自己的处理程序来实现。 为了实现这个场景,我在 $root
我在我的网页中使用了 jquery .toggle(between two functions) : $( ".cpUpbtnsclass" ).toggle(function() { c
我有this jsfiddle 它使用 toggle event - 不要与 toggle 混淆- jQuery 版本设置为 EDGE 它突然停止工作并删除了我想要作为触发器的单元格,因为它显然恢复为
我浏览了官方文档,但我似乎找不到 new Handler() 之间是否有任何区别和new Handler(Looper.myLooper()) new Handler() Default constr
当我在 faces-config.xml 文件中添加以下行时: " com.sun.facelets.FaceletViewHandler " eclipse 说: " view-handler re
当我使用 Handler.dispatchMessage(msg) 时,handleMessage(Message msg) 将在新线程上运行,但是当我使用 Handler.sendMessage(
如何禁用当前将模态库导航到下一张图像的鼠标滚轮处理程序和键盘箭头键? 这里是演示站点:http://blueimp.github.com/Bootstrap-Image-Gallery/ . 如果您单
我正在尝试关注 this关于 Win32 结构化异常处理的文章。这篇文章很老了,但仍然被认为是对该主题的一个很好的介绍。 我正在尝试从下面转载的文章中编译代码示例 - //==============
我正在尝试使用 HibernateValidator 使用 Spring 和 Hibernate 在 JSP 中验证一个简单的表单. JSP页面Temp.jsp如下(web.xml中的url ptte
问题几乎概括了它。我错误地导入了 java.util.logging 并且没有获得所需的功能。现在我解决了我的问题,但我想知道为什么 android 创建了两个 Handler 。我们可能会错误地导入
我有一个主页,其中有一个链接按钮。在其中一个内容页面中,我需要隐藏链接按钮并替换为图像按钮。图像按钮的单击事件处理程序应该与母版页中链接按钮的单击事件完全相同。那么有没有办法从内容页面中的图像按钮单击
我有一个用 2.5 编写的现有 Spring MVC 应用程序。 我想使用新的注释 Controller 。我在某种程度上发现它非常灵活并且可以满足我的其他需求。 我的问题是,我似乎无法将它们两者混合
使用最新的 XCode,我收到此错误: 'logInWithReadPermissions(_:handler:)' is deprecated: use logInWithReadPermissi
我是一名优秀的程序员,十分优秀!