Search in sources :

Example 1 with PrincipalAcegiUserToken

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

the class PipelineBaseTest method login.

protected User login() throws IOException {
    j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
    hudson.model.User bob = j.jenkins.getUser("bob");
    bob.setFullName("Bob Smith");
    bob.addProperty(new Mailer.UserProperty("bob@jenkins-ci.org"));
    UserDetails d = Jenkins.getInstance().getSecurityRealm().loadUserByUsername(bob.getId());
    SecurityContextHolder.getContext().setAuthentication(new PrincipalAcegiUserToken(bob.getId(), bob.getId(), bob.getId(), d.getAuthorities(), bob.getId()));
    return bob;
}
Also used : UserDetails(org.acegisecurity.userdetails.UserDetails) Mailer(hudson.tasks.Mailer) User(hudson.model.User) PrincipalAcegiUserToken(org.acegisecurity.adapters.PrincipalAcegiUserToken)

Example 2 with PrincipalAcegiUserToken

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

the class ProfileApiTest method testPermissionOfOtherUser.

@Test
public void testPermissionOfOtherUser() throws IOException {
    j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
    hudson.model.User alice = j.jenkins.getUser("alice");
    alice.setFullName("Alice Cooper");
    alice.addProperty(new Mailer.UserProperty("alice@jenkins-ci.org"));
    hudson.model.User bob = j.jenkins.getUser("bob");
    bob.setFullName("Bob Cooper");
    bob.addProperty(new Mailer.UserProperty("bob@jenkins-ci.org"));
    UserDetails d = Jenkins.getInstance().getSecurityRealm().loadUserByUsername(bob.getId());
    SecurityContextHolder.getContext().setAuthentication(new PrincipalAcegiUserToken(bob.getId(), bob.getId(), bob.getId(), d.getAuthorities(), bob.getId()));
    Assert.assertNull(new UserImpl(alice).getPermission());
}
Also used : UserDetails(org.acegisecurity.userdetails.UserDetails) UserImpl(io.jenkins.blueocean.service.embedded.rest.UserImpl) Mailer(hudson.tasks.Mailer) User(hudson.model.User) PrincipalAcegiUserToken(org.acegisecurity.adapters.PrincipalAcegiUserToken) Test(org.junit.Test)

Aggregations

User (hudson.model.User)2 Mailer (hudson.tasks.Mailer)2 PrincipalAcegiUserToken (org.acegisecurity.adapters.PrincipalAcegiUserToken)2 UserDetails (org.acegisecurity.userdetails.UserDetails)2 UserImpl (io.jenkins.blueocean.service.embedded.rest.UserImpl)1 Test (org.junit.Test)1