@Override
public void filter(ContainerRequestContext requestContext) throws IOException
{
String xAuthToken = requestContext.getHeaderString("X-Auth-Token");
String xAuthSignedToken = requestContext.getHeaderString("X-Auth-Signed-Token");
Access token = null;
if (xAuthToken == null && xAuthSignedToken == null) return;
else if (xAuthSignedToken != null && certificate != null)
{
token = signed(xAuthSignedToken);
}
else if (xAuthToken != null)
{
token = getTokenFromServer(xAuthToken);
}
if (token == null) return; // do nothing
if (token.getToken().expired()) return; // todo maybe throw 401 with an error stating token is expired?
final UserPrincipal principal = new UserPrincipal(token.getUser());
final Set<String> roleSet = new HashSet<String>();
for (Role role : token.getUser().getRoles())
{
roleSet.add(role.getName());
}
SecurityContext ctx = new SecurityContext()
{