Restlet 2.0.8:单个 restlet 应用程序实例的多种身份验证方法(基本、摘要)?



我们使用Restlet 2.0.8,并且有一个Application实例覆盖org. Restlet . application# createInboundRoot()。在这里,我们创建Router实例并返回(目前)一个DigestAuthenticator,如下所示:

@Override
public synchronized Restlet createInboundRoot() {
    log.info("App::createInboundRoot called");
    this.authenticator = getAuthenticator();
    Router router = new Router(getContext());
    router.attach("/echo", EchoResource.class);
    router.attach("/status", StatusResource.class);
    authenticator.setNext(router);
    return authenticator;
}
private ChallengeAuthenticator getAuthenticator() {
    DigestAuthenticator auth = new DigestAuthenticator(getContext(), "Guard", "s3cret");
    auth.setWrappedVerifier(new SimpleVerifier("user","pass");
    auth.setOptional(false);
    return auth;
}

我想达到的目标是:

  • 有EchoResource使用摘要认证和StatusResource应该使用HTTP基本认证

这是可能的Restlets吗?

最好的,克里斯。

这可以通过链接DigestAuthenticator(可选:true)和BasicAuthenticator(可选:false)实现。伪代码:

   digestAuth.setNext(basicAuth);
   basicAuth.setNext(router);

在类似的情况下,我们创建了两个org.restlet.Application对象,像上面的问题一样需要对一个应用程序进行身份验证,并将这两个应用程序附加到Servlet容器中的不同路径上。

最新更新