class AtnProviderSync extends SynchronousProvider implements AuthenticationProvider {

    @Override
    protected AuthenticationResponse syncAuthenticate(ProviderRequest providerRequest) {

        // first obtain the configuration of this request
        // either from annotation, custom object or config
        AtnObject myObject = getCustomObject(providerRequest.endpointConfig());

        if (null == myObject) {
            // I do not have my required information, this request is probably not for me
            return AuthenticationResponse.abstain();
        }

        if (myObject.isValid()) {
            // now authenticate - this example just creates a subject
            // based on the value (user subject) and size (group subject)
            return AuthenticationResponse.success(Subject.builder()
                                                          .addPrincipal(Principal.create(myObject.getValue()))
                                                          .addGrant(Role.create("role_" + myObject.getSize()))
                                                          .build());
        } else {
            return AuthenticationResponse.failed("Invalid request");
        }
    }

}