Java Restlet-在验证器中使用URI模板变量

Java Restlet-在验证器中使用URI模板变量,java,authentication,uri,restlet,Java,Authentication,Uri,Restlet,我试图在Restlet中执行身份验证,在Restlet中,我根据URI的一部分查找凭据,即多租户身份验证 我无法将认证器的路由器链接到资源访问的路由器。这可能吗?假设我有一个验证器,它需要tenantId变量来查找用户。我一直在尝试下面这样的设置,但没有成功。想法 public class MyApplication extends Application { public Authenticator authenticator; @Override public Re

我试图在Restlet中执行身份验证,在Restlet中,我根据URI的一部分查找凭据,即多租户身份验证

我无法将认证器的路由器链接到资源访问的路由器。这可能吗?假设我有一个验证器,它需要tenantId变量来查找用户。我一直在尝试下面这样的设置,但没有成功。想法

public class MyApplication extends Application
{
    public Authenticator authenticator;

    @Override
    public Restlet createInboundRoot()
    {
        Router router = new Router(getContext());
        router.attach("/", TraceResource.class);
        router.attach("/{apiVersion}/{tenantId}/pathOne/{someId}",
            ResourceOne.class);
        router.attach("/{apiVersion}/{tenantId}/pathTwo/{someId}",
            ResourceTwo.class);

        authenticator.setNext(router);

        Router authenticationRouter = new Router(getContext());
        authenticationRouter.attach("/{apiVersion}/{tenantId}/{remaining}",
            authenticator).setMatchingMode(Template.MODE_STARTS_WITH);

        return authenticationRouter;
    }
}

这几乎是正确的,这里有一个修正:

public class MyApplication extends Application
{
    public Authenticator authenticator;

    @Override
    public Restlet createInboundRoot()
    {
        Router router = new Router(getContext());
        router.attach("/", TraceResource.class);
        router.attach("/pathOne/{someId}", ResourceOne.class);
        router.attach("/pathTwo/{someId}", ResourceTwo.class);
        authenticator.setNext(router);

        Router authenticationRouter = new Router(getContext());
        authenticationRouter.attach("/{apiVersion}/{tenantId}",
            authenticator).setMatchingMode(Template.MODE_STARTS_WITH);

        return authenticationRouter;
    }
}

谢谢在这种情况下,authenticationRouter中的tenantId变量是否只提供“两条斜线之间”的值?或者我需要解析它吗?“tenantId”变量将包含URI的剩余部分,包括斜杠