package oasis.web.authn.testing;

import java.io.IOException;
import java.security.Principal;

import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.core.SecurityContext;

import oasis.web.authn.ClientPrincipal;

public class TestClientAuthenticationFilter implements ContainerRequestFilter {
  private final String clientId;

  public TestClientAuthenticationFilter(String clientId) {
    this.clientId = clientId;
  }

  @Override
  public void filter(ContainerRequestContext requestContext) throws IOException {
    final SecurityContext oldSecurityContext = requestContext.getSecurityContext();
    requestContext.setSecurityContext(new SecurityContext() {
      @Override
      public Principal getUserPrincipal() {
        return new ClientPrincipal(clientId);
      }

      @Override
      public boolean isUserInRole(String role) {
        return false;
      }

      @Override
      public boolean isSecure() {
        return oldSecurityContext.isSecure();
      }

      @Override
      public String getAuthenticationScheme() {
        return SecurityContext.BASIC_AUTH;
      }
    });
  }
}

@@ -88,16 +88,81 @@
 cipal;%0A%0A
+import javax.annotation.Priority;%0Aimport javax.ws.rs.Priorities;%0A
 import j
@@ -329,25 +329,154 @@
 thn.
-ClientPrincipal;%0A
+Authenticated;%0Aimport oasis.web.authn.Client;%0Aimport oasis.web.authn.ClientPrincipal;%0A%0A@Authenticated @Client%0A@Priority(Priorities.AUTHENTICATION)
 %0Apub

Add annotations to TestClientAuthenticationFilter, just to be sure