Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error refreshing token #2

Open
kr580vm80a opened this issue Aug 26, 2018 · 1 comment
Open

Error refreshing token #2

kr580vm80a opened this issue Aug 26, 2018 · 1 comment

Comments

@kr580vm80a
Copy link

When I send a request POST to http://localhost:8080/api/auth/refresh, I got error in class AuthenticationResource, method refresh() in line 70:
AuthenticationTokenDetails tokenDetails = ((TokenBasedSecurityContext) securityContext).getAuthenticationTokenDetails();

javax.servlet.ServletException: java.lang.ClassCastException: org.glassfish.jersey.server.internal.process.SecurityContextInjectee cannot be cast to com.cassiomolin.example.security.api.TokenBasedSecurityContext
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:489)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
...

@kr580vm80a kr580vm80a changed the title Error refreshin token Error refreshing token Aug 26, 2018
@fullerlee
Copy link

fullerlee commented Sep 23, 2018

Hi,
I had a similar problem. Instead of using the injected security context, change the refresh method signature to grab the request context like this:

public Response refresh(@Context ContainerRequestContext context) {

AuthenticationTokenDetails tokenDetails =
                ((TokenBasedSecurityContext) context.getSecurityContext()).getAuthenticationTokenDetails();
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants