public static JaxbRole fromRole(Role role) { if (role instanceof JaxbRole) return (JaxbRole) role; JaxbOrganization org = JaxbOrganization.fromOrganization(role.getOrganization()); return new JaxbRole(role.getName(), org, role.getDescription(), role.getType()); }
@Override public boolean equals(Object obj) { if (!(obj instanceof Role)) return false; Role other = (Role) obj; return name.equals(other.getName()) && organization.equals(other.getOrganization()); }
/** * @see org.opencastproject.security.api.User#hasRole(java.lang.String) */ @Override public boolean hasRole(String roleName) { for (Role role : roles) { if (role.getName().equals(roleName)) return true; } return false; }
/** * Constructs a user with the specified username, password, provider and roles. * * @param username * the username * @param password * the password * @param organization * the organization * @param provider * the provider * @param manageable * whether the user is manageable * @param roles * the roles */ public JpaUser(String username, String password, JpaOrganization organization, String provider, boolean manageable, Set<JpaRole> roles) { this(username, password, organization, null, null, provider, manageable); for (Role role : roles) { if (role.getOrganization() == null || !organization.getId().equals(role.getOrganization().getId())) throw new IllegalArgumentException("Role " + role + " is not from the same organization!"); } this.roles = roles; }
/** * @see org.opencastproject.security.api.User#hasRole(String) */ @Override public boolean hasRole(String roleName) { for (Role role : roles) { if (role.getName().equals(roleName)) return true; } return false; }
/** * {@inheritDoc} * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (!(obj instanceof Role)) return false; Role other = (Role) obj; return name.equals(other.getName()) && organization.equals(other.getOrganization()); }
/** * Constructs a user with the specified username, password, name, email, provider and roles. * * @param username * the username * @param password * the password * @param organization * the organization * @param name * the name * @param email * the email * @param provider * the provider * @param manageable * whether the user is manageable * @param roles * the roles */ public JpaUser(String username, String password, JpaOrganization organization, String name, String email, String provider, boolean manageable, Set<JpaRole> roles) { this(username, password, organization, name, email, provider, manageable); for (Role role : roles) { if (role.getOrganization() == null || !organization.getId().equals(role.getOrganization().getId())) throw new IllegalArgumentException("Role " + role + " is not from the same organization!"); } this.roles = roles; }
protected boolean isUserAllowed(File aclFile) throws SAXException, IOException, XPathExpressionException { Document aclDoc = builder.parse(aclFile); XPath xPath = XPathFactory.newInstance().newXPath(); NodeList roles = (NodeList) xPath.evaluate("//*[local-name() = 'role']", aclDoc, XPathConstants.NODESET); for (int i = 0; i < roles.getLength(); i++) { Node role = roles.item(i); for (Role userRole : securityService.getUser().getRoles()) { if (userRole.getName().equals(role.getTextContent())) { return true; } } } return false; }
/** * Constructs a user with the specified username, name, email, login mechanism, last login date, organization and * roles. * * @param username * the username * @param name * the name * @param email * the email address * @param loginMechanism * the login mechanism * @param lastLogin * the last login date * @param organization * the organization * @param roles * the roles */ public JpaUserReference(String username, String name, String email, String loginMechanism, Date lastLogin, JpaOrganization organization, Set<JpaRole> roles) { this(username, name, email, loginMechanism, lastLogin, organization); for (Role role : roles) { if (role.getOrganization() == null || !organization.getId().equals(role.getOrganization().getId())) throw new IllegalArgumentException("Role " + role + " is not from the same organization!"); } this.roles = roles; }
this.roles = new HashSet<JaxbRole>(); for (Role role : roles) { if (role.getOrganization() == null || !organization.getId().equals(role.getOrganization().getId())) throw new IllegalArgumentException("Role " + role + " is not from the same organization!");
if (!role.getName().equals(aceRole)) continue;