本文整理汇总了Java中azkaban.user.Permission类的典型用法代码示例。如果您正苦于以下问题:Java Permission类的具体用法?Java Permission怎么用?Java Permission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Permission类属于azkaban.user包,在下文中一共展示了Permission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasPermission
import azkaban.user.Permission; //导入依赖的package包/类
public static boolean hasPermission(Project project, User user,
Permission.Type type) {
UserManager userManager = AzkabanWebServer.getInstance().getUserManager();
if (project.hasPermission(user, type)) {
return true;
}
for (String roleName : user.getRoles()) {
Role role = userManager.getRole(roleName);
if (role.getPermission().isPermissionSet(type)
|| role.getPermission().isPermissionSet(Permission.Type.ADMIN)) {
return true;
}
}
return false;
}
示例2: getProjectAjaxByPermission
import azkaban.user.Permission; //导入依赖的package包/类
protected Project getProjectAjaxByPermission(Map<String, Object> ret,
int projectId, User user, Permission.Type type) {
Project project = projectManager.getProject(projectId);
if (project == null) {
ret.put("error", "Project '" + project + "' not found.");
} else if (!hasPermission(project, user, type)) {
ret.put("error",
"User '" + user.getUserId() + "' doesn't have " + type.name()
+ " permissions on " + project.getName());
} else {
return project;
}
return null;
}
示例3: handleReloadProjectWhitelist
import azkaban.user.Permission; //导入依赖的package包/类
private void handleReloadProjectWhitelist(HttpServletRequest req,
HttpServletResponse resp, Session session) throws IOException {
HashMap<String, Object> ret = new HashMap<String, Object>();
if (hasPermission(session.getUser(), Permission.Type.ADMIN)) {
try {
if (projectManager.loadProjectWhiteList()) {
ret.put("success", "Project whitelist re-loaded!");
} else {
ret.put("error", "azkaban.properties doesn't contain property "
+ ProjectWhitelist.XML_FILE_PARAM);
}
} catch (Exception e) {
ret.put("error",
"Exception occurred while trying to re-load project whitelist: "
+ e);
}
} else {
ret.put("error", "Provided session doesn't have admin privilege.");
}
this.writeJSON(resp, ret);
}
示例4: getProjectPageByPermission
import azkaban.user.Permission; //导入依赖的package包/类
protected Project getProjectPageByPermission(Page page, int projectId,
User user, Permission.Type type) {
Project project = projectManager.getProject(projectId);
if (project == null) {
page.add("errorMsg", "Project " + project + " not found.");
} else if (!hasPermission(project, user, type)) {
page.add("errorMsg",
"User " + user.getUserId() + " doesn't have " + type.name()
+ " permissions on " + project.getName());
} else {
return project;
}
return null;
}
示例5: getProjectAjaxByPermission
import azkaban.user.Permission; //导入依赖的package包/类
protected Project getProjectAjaxByPermission(Map<String, Object> ret,
String projectName, User user, Permission.Type type) {
Project project = projectManager.getProject(projectName);
if (project == null) {
ret.put("error", "Project '" + project + "' not found.");
} else if (!hasPermission(project, user, type)) {
ret.put("error",
"User '" + user.getUserId() + "' doesn't have " + type.name()
+ " permissions on " + project.getName());
} else {
return project;
}
return null;
}
示例6: getUserProjectsByRegex
import azkaban.user.Permission; //导入依赖的package包/类
public List<Project> getUserProjectsByRegex(User user, String regexPattern) {
List<Project> array = new ArrayList<Project>();
Pattern pattern;
try {
pattern = Pattern.compile(regexPattern, Pattern.CASE_INSENSITIVE);
} catch (PatternSyntaxException e) {
logger.error("Bad regex pattern " + regexPattern);
return array;
}
for (Project project : projectsById.values()) {
Permission perm = project.getUserPermission(user);
if (perm != null
&& (perm.isPermissionSet(Type.ADMIN) || perm
.isPermissionSet(Type.READ))) {
if (pattern.matcher(project.getName()).find()) {
array.add(project);
}
}
}
return array;
}
示例7: updateProjectPermission
import azkaban.user.Permission; //导入依赖的package包/类
public void updateProjectPermission(Project project, String name,
Permission perm, boolean group, User modifier)
throws ProjectManagerException {
logger.info("User " + modifier.getUserId()
+ " updating permissions for project " + project.getName() + " for "
+ name + " " + perm.toString());
projectLoader.updatePermission(project, name, perm, group);
if (group) {
projectLoader.postEvent(project, EventType.GROUP_PERMISSION,
modifier.getUserId(), "Permission for group " + name + " set to "
+ perm.toString());
} else {
projectLoader.postEvent(project, EventType.USER_PERMISSION,
modifier.getUserId(), "Permission for user " + name + " set to "
+ perm.toString());
}
}
示例8: getCollectivePermission
import azkaban.user.Permission; //导入依赖的package包/类
public Permission getCollectivePermission(User user) {
Permission permissions = new Permission();
Permission perm = userPermissionMap.get(user.getUserId());
if (perm != null) {
permissions.addPermissions(perm);
}
for (String group : user.getGroups()) {
perm = groupPermissionMap.get(group);
if (perm != null) {
permissions.addPermissions(perm);
}
}
return permissions;
}
示例9: fetchPermissionsForProject
import azkaban.user.Permission; //导入依赖的package包/类
private List<Triple<String, Boolean, Permission>> fetchPermissionsForProject(
Connection connection, Project project) throws ProjectManagerException {
ProjectPermissionsResultHandler permHander =
new ProjectPermissionsResultHandler();
QueryRunner runner = new QueryRunner();
List<Triple<String, Boolean, Permission>> permissions = null;
try {
permissions =
runner.query(connection,
ProjectPermissionsResultHandler.SELECT_PROJECT_PERMISSION,
permHander, project.getId());
} catch (SQLException e) {
throw new ProjectManagerException("Query for permissions for "
+ project.getName() + " failed.", e);
}
return permissions;
}
示例10: getProjectPermissions
import azkaban.user.Permission; //导入依赖的package包/类
@Override
public List<Triple<String, Boolean, Permission>> getProjectPermissions(
int projectId) throws ProjectManagerException {
ProjectPermissionsResultHandler permHander =
new ProjectPermissionsResultHandler();
QueryRunner runner = createQueryRunner();
List<Triple<String, Boolean, Permission>> permissions = null;
try {
permissions =
runner.query(
ProjectPermissionsResultHandler.SELECT_PROJECT_PERMISSION,
permHander, projectId);
} catch (SQLException e) {
throw new ProjectManagerException("Query for permissions for "
+ projectId + " failed.", e);
}
return permissions;
}
示例11: handle
import azkaban.user.Permission; //导入依赖的package包/类
@Override
public List<Triple<String, Boolean, Permission>> handle(ResultSet rs)
throws SQLException {
if (!rs.next()) {
return Collections.<Triple<String, Boolean, Permission>> emptyList();
}
ArrayList<Triple<String, Boolean, Permission>> permissions =
new ArrayList<Triple<String, Boolean, Permission>>();
do {
String username = rs.getString(3);
int permissionFlag = rs.getInt(4);
boolean val = rs.getBoolean(5);
Permission perm = new Permission(permissionFlag);
permissions.add(new Triple<String, Boolean, Permission>(username, val,
perm));
} while (rs.next());
return permissions;
}
示例12: testToAndFromObject
import azkaban.user.Permission; //导入依赖的package包/类
@Test
public void testToAndFromObject() throws Exception {
Project project = new Project(1, "tesTing");
project.setCreateTimestamp(1L);
project.setLastModifiedTimestamp(2L);
project.setDescription("I am a test");
project.setUserPermission("user1", new Permission(new Type[] { Type.ADMIN,
Type.EXECUTE }));
Object obj = project.toObject();
String json = JSONUtils.toJSON(obj);
Object jsonObj = JSONUtils.parseJSONFromString(json);
Project parsedProject = Project.projectFromObject(jsonObj);
assertTrue(project.equals(parsedProject));
}
示例13: testToAndFromObject
import azkaban.user.Permission; //导入依赖的package包/类
@Test
public void testToAndFromObject() throws Exception {
Project project = new Project(1, "tesTing");
project.setCreateTimestamp(1l);
project.setLastModifiedTimestamp(2l);
project.setDescription("I am a test");
project.setUserPermission("user1", new Permission(new Type[]{Type.ADMIN, Type.EXECUTE}));
Object obj = project.toObject();
String json = JSONUtils.toJSON(obj);
Object jsonObj = JSONUtils.parseJSONFromString(json);
Project parsedProject = Project.projectFromObject(jsonObj);
assertTrue(project.equals(parsedProject));
}
示例14: getUserProjectsByRegex
import azkaban.user.Permission; //导入依赖的package包/类
public List<Project> getUserProjectsByRegex(User user, String regexPattern) {
List<Project> array = new ArrayList<Project>();
Pattern pattern;
try {
pattern = Pattern.compile(regexPattern, Pattern.CASE_INSENSITIVE);
} catch (PatternSyntaxException e) {
logger.error("Bad regex pattern " + regexPattern);
return array;
}
for (Project project : projectsById.values()) {
Permission perm = project.getUserPermission(user);
if (perm != null && (perm.isPermissionSet(Type.ADMIN) || perm.isPermissionSet(Type.READ))) {
if(pattern.matcher(project.getName()).find() ) {
array.add(project);
}
}
}
return array;
}
示例15: getCollectivePermission
import azkaban.user.Permission; //导入依赖的package包/类
public Permission getCollectivePermission(User user) {
Permission permissions = new Permission();
Permission perm = userPermissionMap.get(user.getUserId());
if (perm != null) {
permissions.addPermissions(perm);
}
for(String group: user.getGroups()) {
perm = groupPermissionMap.get(group);
if (perm != null) {
permissions.addPermissions(perm);
}
}
return permissions;
}