Class KeycloakRealmRoleConverter

java.lang.Object
com.example.vehicletaxsystem.config.KeycloakRealmRoleConverter
All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,Collection<org.springframework.security.core.GrantedAuthority>>

public class KeycloakRealmRoleConverter extends Object implements org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,Collection<org.springframework.security.core.GrantedAuthority>>

Converter for KeyCloak realm roles and users to be read by spring for authorisation and authentication purposes.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Collection<org.springframework.security.core.GrantedAuthority>
    convert(org.springframework.security.oauth2.jwt.Jwt jwt)
    Converts JWT into recognisable collections of authority the use providing the JWT has.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.core.convert.converter.Converter

    andThen
  • Constructor Details

    • KeycloakRealmRoleConverter

      public KeycloakRealmRoleConverter()
  • Method Details

    • convert

      public Collection<org.springframework.security.core.GrantedAuthority> convert(org.springframework.security.oauth2.jwt.Jwt jwt)
      Converts JWT into recognisable collections of authority the use providing the JWT has.
      Specified by:
      convert in interface org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,Collection<org.springframework.security.core.GrantedAuthority>>
      Parameters:
      jwt - Javascript Web Token from the user making requests.
      Returns:
      Collection of the authorities that the user has assigned.