Search in sources :

Example 11 with Permission

use of org.candlepin.auth.permissions.Permission in project candlepin by candlepin.

the class User method getPermissions.

/**
 * Full list of permissions for this user.
 *
 * Includes those from roles stored in the database, as well as those explicitly added
 * by the user service adapter.
 *
 * @return full list of permissions for this user.
 */
@XmlTransient
public Set<Permission> getPermissions() {
    PermissionFactory permFactory = new PermissionFactory();
    Set<Permission> perms = new HashSet<>();
    for (Role r : getRoles()) {
        perms.addAll(permFactory.createPermissions(this, r.getPermissions()));
    }
    perms.addAll(this.permissions);
    return perms;
}
Also used : PermissionFactory(org.candlepin.auth.permissions.PermissionFactory) Permission(org.candlepin.auth.permissions.Permission) HashSet(java.util.HashSet) XmlTransient(javax.xml.bind.annotation.XmlTransient)

Example 12 with Permission

use of org.candlepin.auth.permissions.Permission in project candlepin by candlepin.

the class ConsumerResourceCreationTest method createConsumer.

protected ConsumerDTO createConsumer(String consumerName) {
    Collection<Permission> perms = new HashSet<>();
    perms.add(new OwnerPermission(owner, Access.ALL));
    Principal principal = new UserPrincipal(USER, perms, false);
    List<String> empty = Collections.emptyList();
    return createConsumer(consumerName, principal, empty);
}
Also used : OwnerPermission(org.candlepin.auth.permissions.OwnerPermission) OwnerPermission(org.candlepin.auth.permissions.OwnerPermission) Permission(org.candlepin.auth.permissions.Permission) TrustedUserPrincipal(org.candlepin.auth.TrustedUserPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) NoAuthPrincipal(org.candlepin.auth.NoAuthPrincipal) TrustedUserPrincipal(org.candlepin.auth.TrustedUserPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) HashSet(java.util.HashSet)

Aggregations

Permission (org.candlepin.auth.permissions.Permission)12 Principal (org.candlepin.auth.Principal)9 UserPrincipal (org.candlepin.auth.UserPrincipal)9 OwnerPermission (org.candlepin.auth.permissions.OwnerPermission)8 Owner (org.candlepin.model.Owner)6 HashSet (java.util.HashSet)5 Test (org.junit.Test)4 UsernameConsumersPermission (org.candlepin.auth.permissions.UsernameConsumersPermission)3 User (org.candlepin.model.User)3 LinkedList (java.util.LinkedList)2 PermissionBlueprint (org.candlepin.model.PermissionBlueprint)2 Role (org.candlepin.model.Role)2 JobDetail (org.quartz.JobDetail)2 ArrayList (java.util.ArrayList)1 XmlTransient (javax.xml.bind.annotation.XmlTransient)1 NoAuthPrincipal (org.candlepin.auth.NoAuthPrincipal)1 TrustedUserPrincipal (org.candlepin.auth.TrustedUserPrincipal)1 PermissionFactory (org.candlepin.auth.permissions.PermissionFactory)1 ConsumerTypeDTO (org.candlepin.dto.api.v1.ConsumerTypeDTO)1 OwnerDTO (org.candlepin.dto.api.v1.OwnerDTO)1