Search in sources :

Example 1 with GrantedAuthority

use of org.acegisecurity.GrantedAuthority in project blueocean-plugin by jenkinsci.

the class PipelineStepImpl method canSubmit.

private boolean canSubmit(InputStep inputStep) {
    Authentication a = Jenkins.getAuthentication();
    String submitter = inputStep.getSubmitter();
    if (submitter == null || a.getName().equals(submitter)) {
        return true;
    }
    for (GrantedAuthority ga : a.getAuthorities()) {
        if (ga.getAuthority().equals(submitter)) {
            return true;
        }
    }
    return false;
}
Also used : Authentication(org.acegisecurity.Authentication) GrantedAuthority(org.acegisecurity.GrantedAuthority)

Example 2 with GrantedAuthority

use of org.acegisecurity.GrantedAuthority in project promoted-builds-plugin by jenkinsci.

the class ManualCondition method isInGroupList.

/*
     * Check if user is a member of a groups as listed in the user / group field
     */
public boolean isInGroupList() {
    Set<String> groups = getUsersAsSet();
    GrantedAuthority[] authorities = Hudson.getAuthentication().getAuthorities();
    for (GrantedAuthority authority : authorities) {
        if (groups.contains(authority.getAuthority()))
            return true;
    }
    return false;
}
Also used : GrantedAuthority(org.acegisecurity.GrantedAuthority)

Example 3 with GrantedAuthority

use of org.acegisecurity.GrantedAuthority in project hudson-2.x by hudson.

the class PAMSecurityRealm method createSecurityComponents.

public SecurityComponents createSecurityComponents() {
    Binding binding = new Binding();
    binding.setVariable("instance", this);
    BeanBuilder builder = new BeanBuilder();
    builder.parse(Hudson.getInstance().servletContext.getResourceAsStream("/WEB-INF/security/PAMSecurityRealm.groovy"), binding);
    WebApplicationContext context = builder.createApplicationContext();
    return new SecurityComponents(findBean(AuthenticationManager.class, context), new UserDetailsService() {

        public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
            if (!UnixUser.exists(username))
                throw new UsernameNotFoundException("No such Unix user: " + username);
            // return some dummy instance
            return new User(username, "", true, true, true, true, new GrantedAuthority[] { AUTHENTICATED_AUTHORITY });
        }
    });
}
Also used : Binding(groovy.lang.Binding) BeanBuilder(hudson.util.spring.BeanBuilder) AuthenticationManager(org.acegisecurity.AuthenticationManager) UsernameNotFoundException(org.acegisecurity.userdetails.UsernameNotFoundException) UserDetails(org.acegisecurity.userdetails.UserDetails) UnixUser(org.jvnet.libpam.UnixUser) User(org.acegisecurity.userdetails.User) GrantedAuthority(org.acegisecurity.GrantedAuthority) UserDetailsService(org.acegisecurity.userdetails.UserDetailsService) DataAccessException(org.springframework.dao.DataAccessException) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Aggregations

GrantedAuthority (org.acegisecurity.GrantedAuthority)3 Binding (groovy.lang.Binding)1 BeanBuilder (hudson.util.spring.BeanBuilder)1 Authentication (org.acegisecurity.Authentication)1 AuthenticationManager (org.acegisecurity.AuthenticationManager)1 User (org.acegisecurity.userdetails.User)1 UserDetails (org.acegisecurity.userdetails.UserDetails)1 UserDetailsService (org.acegisecurity.userdetails.UserDetailsService)1 UsernameNotFoundException (org.acegisecurity.userdetails.UsernameNotFoundException)1 UnixUser (org.jvnet.libpam.UnixUser)1 DataAccessException (org.springframework.dao.DataAccessException)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1