8000 NPE thrown when encoding a token without having a client set in the session · Issue #40935 · keycloak/keycloak · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content 8000
NPE thrown when encoding a token without having a client set in the session #40935
Closed
@mkrueger92

Description

@mkrueger92

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

core

Describe the bug

Encoding a token can result in an NPE in case no client is set to the session.
In the DefaultTokenManager some functions check for that fact but not the type(TokenCategory) function. As a result, when calling encode(Token) a NPE is thrown.

Version

26.2.5

Regression

  • The issue is a regression

Expected behavior

I would like to have the token encoded without having an NPE thrown.

Actual behavior

The NPE is thrown.

How to Reproduce?

        AccessToken newToken = new AccessToken();
        newToken.id(KeycloakModelUtils.generateId());
        newToken.type(TokenUtil.TOKEN_TYPE_BEARER);
        ...
        ...
        newTokenString = session.tokens().encode(newToken);

Anything else?

I will provide a PR to fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0