本文整理汇总了Java中org.h2.engine.Database.findRole方法的典型用法代码示例。如果您正苦于以下问题:Java Database.findRole方法的具体用法?Java Database.findRole怎么用?Java Database.findRole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.engine.Database
的用法示例。
在下文中一共展示了Database.findRole方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
session.getUser().checkAdmin();
session.commit(true);
Database db = session.getDatabase();
if (db.findUser(roleName) != null) {
throw DbException.get(ErrorCode.USER_ALREADY_EXISTS_1, roleName);
}
if (db.findRole(roleName) != null) {
if (ifNotExists) {
return 0;
}
throw DbException.get(ErrorCode.ROLE_ALREADY_EXISTS_1, roleName);
}
int id = getObjectId();
Role role = new Role(db, id, roleName, false);
db.addDatabaseObject(session, role);
return 0;
}
示例2: update
import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
session.getUser().checkAdmin();
session.commit(true);
Database db = session.getDatabase();
if (roleName.equals(Constants.PUBLIC_ROLE_NAME)) {
throw DbException.get(ErrorCode.ROLE_CAN_NOT_BE_DROPPED_1, roleName);
}
Role role = db.findRole(roleName);
if (role == null) {
if (!ifExists) {
throw DbException.get(ErrorCode.ROLE_NOT_FOUND_1, roleName);
}
} else {
db.removeDatabaseObject(session, role);
}
return 0;
}
示例3: update
import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
session.getUser().checkAdmin();
session.commit(true);
Database db = session.getDatabase();
if (db.findRole(userName) != null) {
throw DbException.get(ErrorCode.ROLE_ALREADY_EXISTS_1, userName);
}
if (db.findUser(userName) != null) {
if (ifNotExists) {
return 0;
}
throw DbException.get(ErrorCode.USER_ALREADY_EXISTS_1, userName);
}
int id = getObjectId();
User user = new User(db, id, userName, false);
user.setAdmin(admin);
user.setComment(comment);
if (hash != null && salt != null) {
user.setSaltAndHash(getByteArray(salt), getByteArray(hash));
} else if (password != null) {
char[] passwordChars = getCharArray(password);
byte[] userPasswordHash;
if (userName.length() == 0 && passwordChars.length == 0) {
userPasswordHash = new byte[0];
} else {
userPasswordHash = SHA256.getKeyPasswordHash(userName, passwordChars);
}
user.setUserPasswordHash(userPasswordHash);
} else {
throw DbException.throwInternalError();
}
db.addDatabaseObject(session, user);
return 0;
}
示例4: setGranteeName
import org.h2.engine.Database; //导入方法依赖的package包/类
public void setGranteeName(String granteeName) {
Database db = session.getDatabase();
grantee = db.findUser(granteeName);
if (grantee == null) {
grantee = db.findRole(granteeName);
if (grantee == null) {
throw DbException.get(ErrorCode.USER_OR_ROLE_NOT_FOUND_1, granteeName);
}
}
}
示例5: update
import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
session.getUser().checkAdmin();
session.commit(true);
Database db = session.getDatabase();
if (roleNames != null) {
for (String name : roleNames) {
Role grantedRole = db.findRole(name);
if (grantedRole == null) {
throw DbException.get(ErrorCode.ROLE_NOT_FOUND_1, name);
}
if (operationType == CommandInterface.GRANT) {
grantRole(grantedRole);
} else if (operationType == CommandInterface.REVOKE) {
revokeRole(grantedRole);
} else {
DbException.throwInternalError("type=" + operationType);
}
}
} else {
if (operationType == CommandInterface.GRANT) {
grantRight();
} else if (operationType == CommandInterface.REVOKE) {
revokeRight();
} else {
DbException.throwInternalError("type=" + operationType);
}
}
return 0;
}