<commit_before>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(repository.keycloak.qualified_test_auth_service_implementation_name) %>;

public class <%= repository.keycloak.test_auth_service_implementation_name %>
  extends <%= repository.keycloak.qualified_auth_service_implementation_name %>
{
  private final org.keycloak.representations.IDToken _idToken = new org.keycloak.representations.IDToken();
  private final org.keycloak.representations.AccessToken _token = new org.keycloak.representations.AccessToken();
  private final java.security.Principal _principal = new TestPrincipal( org.realityforge.guiceyloops.shared.ValueUtil.randomString() );
  private org.keycloak.adapters.OidcKeycloakAccount _account;

  @javax.annotation.Nonnull
  @java.lang.Override
  public org.keycloak.adapters.OidcKeycloakAccount getAccount()
  {
    return _account;
  }

  @java.lang.Override
  public boolean isAuthenticated()
  {
    return null != _account;
  }

  public void setupAccount( <%= repository.keycloak.default_client.claims.collect {|claim| "@javax.annotation.Nonnull final #{claim.java_type} #{Reality::Naming.camelize(claim.java_accessor_key)}"}.join(', ') -%> )
  {
    _account = new Account();
<% repository.keycloak.default_client.claims.each do |claim| -%>
<% if claim.standard_claim? -%>
    _token.set<%= claim.token_accessor_key %>( <%= Reality::Naming.camelize(claim.java_accessor_key) %> );
<% else -%>
    _token.setOtherClaims( "<%= Reality::Naming.camelize(claim.token_accessor_key) %>", <%= Reality::Naming.camelize(claim.java_accessor_key) %> );
<% end -%>
<% end -%>
  }

  private class TestPrincipal
    implements java.security.Principal
  {
    private final java.lang.String _name;

    TestPrincipal( final java.lang.String name )
    {
      _name = name;
    }

    @java.lang.Override
    public java.lang.String getName()
    {
      return _name;
    }
  }

  private class Account
    implements org.keycloak.adapters.OidcKeycloakAccount
  {
    @java.lang.Override
    public java.security.Principal getPrincipal()
    {
      return _principal;
    }

    @java.lang.Override
    public java.util.Set<java.lang.String> getRoles()
    {
      return new java.util.HashSet<>();
    }

    @Override
    public org.keycloak.KeycloakSecurityContext getKeycloakSecurityContext()<commit_msg>Nullability<commit_after>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(repository.keycloak.qualified_test_auth_service_implementation_name) %>;

public class <%= repository.keycloak.test_auth_service_implementation_name %>
  extends <%= repository.keycloak.qualified_auth_service_implementation_name %>
{
  @javax.annotation.Nonnull
  private final org.keycloak.representations.IDToken _idToken = new org.keycloak.representations.IDToken();
  @javax.annotation.Nonnull
  private final org.keycloak.representations.AccessToken _token = new org.keycloak.representations.AccessToken();
  @javax.annotation.Nonnull
  private final java.security.Principal _principal = new TestPrincipal( org.realityforge.guiceyloops.shared.ValueUtil.randomString() );
  @javax.annotation.Nullable
  private org.keycloak.adapters.OidcKeycloakAccount _account;

  @javax.annotation.Nonnull
  @java.lang.Override
  public org.keycloak.adapters.OidcKeycloakAccount getAccount()
  {
    assert null != _account;
    return _account;
  }

  @java.lang.Override
  public boolean isAuthenticated()
  {
    return null != _account;
  }

  public void setupAccount( <%= repository.keycloak.default_client.claims.collect {|claim| "@javax.annotation.Nonnull final #{claim.java_type} #{Reality::Naming.camelize(claim.java_accessor_key)}"}.join(', ') -%> )
  {
    _account = new Account();
<% repository.keycloak.default_client.claims.each do |claim| -%>
<% if claim.standard_claim? -%>
    _token.set<%= claim.token_accessor_key %>( <%= Reality::Naming.camelize(claim.java_accessor_key) %> );
<% else -%>
    _token.setOtherClaims( "<%= Reality::Naming.camelize(claim.token_accessor_key) %>", <%= Reality::Naming.camelize(claim.java_accessor_key) %> );
<% end -%>
<% end -%>
  }

  private class TestPrincipal
    implements java.security.Principal
  {
    @javax.annotation.Nonnull
    private final java.lang.String _name;

    TestPrincipal( @javax.annotation.Nonnull final java.lang.String name )
    {
      _name = java.util.Objects.requireNonNull( name );
    }

    @java.lang.Override
    @javax.annotation.Nonnull
    public java.lang.String getName()
    {
      return _name;
    }
  }

  private class Account
    implements org.keycloak.adapters.OidcKeycloakAccount
  {
    @javax.annotation.Nonnull
    @java.lang.Override
    public java.security.Principal getPrincipal()
    {
      return _principal;
    }

    @javax.annotation.Nonnull
    @java.lang.Override
    public java.util.Set<java.lang.String> getRoles()
    {
      return new java.util.HashSet<>();
    }

    @javax.annotation.Nonnull
    @Override
    public org.keycloak.KeycloakSecurityContext getKeycloakSecurityContext()
{'fraction_non_alphanumeric': 0.12197059992054032, 'fraction_numerical': 0.0, 'mean_word_length': 4.190721649484536, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4265570', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1602, 'n_words': 251}