I have a slight problem understanding where i should store my token (client side). So it is sent every time i change page on the server.
@Override
public User getValue(HttpContext c) {
// This is where the credentials are extracted from the request
final String header = c.getRequest().getHeaderValue(CUSTOM_HEADER);
try {
if (header != null) {
final Optional<User> result = authenticator.authenticate(new Credentials(header,"",""));
if (result.isPresent()) {
return result.get();
}
}
} catch (AuthenticationException e) {
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
}
if (required) {
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
}
System.out.println("NO TOKEN RETURNING NULL");
return null;
}
}
This is how my authentication looks like in dropwizard. I need the token to be sent with the HttpContext
.
So if i try to go into adress/securedpage
. Then the HttpContext
should have this token. So the server knows if the user is authorized to access or not
So after a successful login from the clientside. Where should i put the token that is received from the server?