当前位置: 首页>>代码示例>>Java>>正文


Java Permission类代码示例

本文整理汇总了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;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:18,代码来源:ResourceUtils.java

示例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;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:17,代码来源:ScheduleServlet.java

示例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);
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:24,代码来源:ProjectManagerServlet.java

示例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;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:17,代码来源:ExecutorServlet.java

示例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;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:17,代码来源:ExecutorServlet.java

示例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;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:24,代码来源:ProjectManager.java

示例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());
  }
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:18,代码来源:ProjectManager.java

示例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;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:17,代码来源:Project.java

示例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;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:20,代码来源:JdbcProjectLoader.java

示例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;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:20,代码来源:JdbcProjectLoader.java

示例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;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:22,代码来源:JdbcProjectLoader.java

示例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));
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:19,代码来源:ProjectTest.java

示例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));
}
 
开发者ID:zhizhounq,项目名称:azkaban-customization,代码行数:18,代码来源:ProjectTest.java

示例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;
}
 
开发者ID:zhizhounq,项目名称:azkaban-customization,代码行数:23,代码来源:ProjectManager.java

示例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;
}
 
开发者ID:zhizhounq,项目名称:azkaban-customization,代码行数:17,代码来源:Project.java


注:本文中的azkaban.user.Permission类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。