Search in sources :

Example 1 with ProjectSynchronizationAuthenticationToken

use of ca.corefacility.bioinformatics.irida.security.ProjectSynchronizationAuthenticationToken in project irida by phac-nml.

the class ProjectOwnerPermissionTest method testRemoteProject.

@Test
public void testRemoteProject() {
    project.setRemoteStatus(new RemoteStatus("http://somewhere", null));
    Authentication authentication = new ProjectSynchronizationAuthenticationToken(user);
    boolean customPermissionAllowed = permission.customPermissionAllowed(authentication, project);
    assertTrue("user should be able to read project", customPermissionAllowed);
}
Also used : ProjectSynchronizationAuthenticationToken(ca.corefacility.bioinformatics.irida.security.ProjectSynchronizationAuthenticationToken) Authentication(org.springframework.security.core.Authentication) RemoteStatus(ca.corefacility.bioinformatics.irida.model.remote.RemoteStatus) Test(org.junit.Test)

Example 2 with ProjectSynchronizationAuthenticationToken

use of ca.corefacility.bioinformatics.irida.security.ProjectSynchronizationAuthenticationToken in project irida by phac-nml.

the class ProjectSynchronizationService method setAuthentication.

/**
 * Set the given user's authentication in the SecurityContextHolder
 *
 * @param userAuthentication
 *            The {@link User} to set in the context holder
 */
private void setAuthentication(User user) {
    ProjectSynchronizationAuthenticationToken userAuthentication = new ProjectSynchronizationAuthenticationToken(user);
    SecurityContext context = SecurityContextHolder.createEmptyContext();
    context.setAuthentication(userAuthentication);
    SecurityContextHolder.setContext(context);
}
Also used : ProjectSynchronizationAuthenticationToken(ca.corefacility.bioinformatics.irida.security.ProjectSynchronizationAuthenticationToken) SecurityContext(org.springframework.security.core.context.SecurityContext)

Aggregations

ProjectSynchronizationAuthenticationToken (ca.corefacility.bioinformatics.irida.security.ProjectSynchronizationAuthenticationToken)2 RemoteStatus (ca.corefacility.bioinformatics.irida.model.remote.RemoteStatus)1 Test (org.junit.Test)1 Authentication (org.springframework.security.core.Authentication)1 SecurityContext (org.springframework.security.core.context.SecurityContext)1