Search in sources :

Example 1 with BlueUserPermission

use of io.jenkins.blueocean.rest.model.BlueUserPermission in project blueocean-plugin by jenkinsci.

the class UserImpl method getPermission.

@Override
public BlueUserPermission getPermission() {
    Authentication authentication = Jenkins.getAuthentication();
    String name = authentication.getName();
    if (isAnonymous(name)) {
        return null;
    }
    User loggedInUser = User.get(name, false, Collections.EMPTY_MAP);
    if (loggedInUser == null) {
        return null;
    }
    //      round trip to fetch user and authorizations
    if (!loggedInUser.getId().equals(user.getId())) {
        return null;
    }
    return new BlueUserPermission() {

        @Override
        public boolean isAdministration() {
            return isAdmin();
        }

        @Override
        public Map<String, Boolean> getPipelinePermission() {
            return UserImpl.this.getPipelinePermissions();
        }

        @Override
        public Map<String, Boolean> getCredentialPermission() {
            return UserImpl.this.getCredentialPermissions();
        }
    };
}
Also used : BlueUserPermission(io.jenkins.blueocean.rest.model.BlueUserPermission) BlueUser(io.jenkins.blueocean.rest.model.BlueUser) User(hudson.model.User) Authentication(org.acegisecurity.Authentication)

Aggregations

User (hudson.model.User)1 BlueUser (io.jenkins.blueocean.rest.model.BlueUser)1 BlueUserPermission (io.jenkins.blueocean.rest.model.BlueUserPermission)1 Authentication (org.acegisecurity.Authentication)1