i am implmenting the java shiro for security.i need to return the message when session is expired and if session is not expired then i need to return different message like un Authenticate user.
This is my code.
@GET
@Path("/{userId}")
public Response view(@PathParam("userId")String userId)
{
ResponseBuilder builder = Response.ok();
if(SecurityUtils.getSubject().isAuthenticated())
{
Registeration registeration=new Registeration();
boolean status=registeration.getDetails(userId,builder);
log.debug("the status is:"+status);
}
else
{
builder.status(401).entity("You are currently not login .please Login for Access Services");
}
return builder.build();
}
This above rest services working fine.when user is not login .this method will return the message of else part. but i need to return message also that after session had expired and user try to access this rest services then i need to return the "your session had expired " . but in above case if session is expired then also same message and the if user is not login then also same message. i do not know that how i will check this both condition that 1)if user is not login then message="you are login" 2)if session had expired then messsage="you session had expired"