Skip to content

Null check on tokenTypeHint variable#3

Open
dileepagayan wants to merge 3 commits intofacilelogin:masterfrom
dileepagayan:master
Open

Null check on tokenTypeHint variable#3
dileepagayan wants to merge 3 commits intofacilelogin:masterfrom
dileepagayan:master

Conversation

@dileepagayan
Copy link
Copy Markdown

When we build the token introspection component using JDK 1.8, it throws a below error,

[2017-10-25 17:31:58,950] ERROR {org.apache.catalina.core.StandardWrapperValve} - Servlet.service() for servlet [cxf] in context with path [/introspect] threw exception java.lang.RuntimeException: org.apache.cxf.interceptor.Fault at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:116) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:336)

Furthermore, I debugged the code and identified that the request hits the method with two parameters (i.e. introspect(@FormParam("token") String token, @FormParam("token_type_hint") String tokenTypeHint)) even if we send just one parameter (i.e Token) in JDK 1.8.

In order to fix the error, I removed the single parameter method (i.e introspect(@FormParam("token") String token) ) and added a null check on tokenTypeHint parameter string.

I tested the component with both JDK 1.8 and JDK 1.7 it works fine with both versions now.

accessToken.setIdentifier(token);
accessToken.setTokenType(tokenTypeHint);

if(tokenTypeHint != null && !tokenTypeHint.isEmpty()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix formatting

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User StringUtils.isBlank()

if(tokenTypeHint != null && !tokenTypeHint.isEmpty()) {
accessToken.setTokenType(tokenTypeHint);
}else {
accessToken.setTokenType("bearer");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the already defined 'DEFAULT_TOKEN_TYPE_HINT' constant.

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

Successfully merging this pull request may close these issues.

2 participants