Keycloak how to get data in protocol mapper from custom authenticator?

175 views Asked by At

I have created on CustomAuthenticator as below:

    public class MyCustomAuthenticator extends UsernamePasswordForm {

  @Override
  public boolean validatePassword(final AuthenticationFlowContext context, final UserModel user,
      final MultivaluedMap<String, String> inputData, final boolean clearUser) {
    context.getSession().setAttribute("data","test");
  }
}

but when i tried to get it on protocol mapper as below:

 public class RmDataTokenMapper extends AbstractOIDCProtocolMapper implements OIDCAccessTokenMapper, OIDCIDTokenMapper, UserInfoTokenMapper {
   @Override
    protected void setClaim(IDToken token, ProtocolMapperModel mappingModel, UserSessionModel userSession, KeycloakSession keycloakSession, ClientSessionContext clientSessionCtx) {
       keycloakSession.sessions().getKeycloakSession().getAttribute("data");
    }
}

I am not able to get data. Any one help me how to achieve?

0

There are 0 answers