org.pac4j.jax.rs.resources.TestSessionResource Maven / Gradle / Ivy
package org.pac4j.jax.rs.resources;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.pac4j.core.context.DefaultAuthorizers;
import org.pac4j.core.profile.CommonProfile;
import org.pac4j.jax.rs.annotations.Pac4JCallback;
import org.pac4j.jax.rs.annotations.Pac4JProfile;
import org.pac4j.jax.rs.annotations.Pac4JSecurity;
/**
* This contains session-based interactions
*
* @author Victor Noel - Linagora
* @since 1.0.0
*
*/
@Path("/session")
public class TestSessionResource extends TestResource {
@GET
@Path("/logged")
@Pac4JSecurity(clients = "FormClient", authorizers = DefaultAuthorizers.IS_AUTHENTICATED)
public String logged() {
return "ok";
}
@GET
@Path("/inject")
@Pac4JSecurity(clients = "FormClient", authorizers = DefaultAuthorizers.IS_AUTHENTICATED)
public String inject(@Pac4JProfile CommonProfile profile) {
if (profile != null) {
return "ok";
} else {
return "error";
}
}
@POST
@Path("/login")
// TODO apparently we need to disable session renewal because grizzly
// send 2 JSESSIONID if not...
@Pac4JCallback(defaultUrl = "/session/logged", renewSession = false)
public void login() {
// nothing
}
}