我們正在使用Restlet 2.0.8,並且應用程序實例覆蓋org.restlet.Application#createInboundRoot()。在那裏,我們創造的路由器實例和回報(目前)一DigestAuthenticator,像下面的代碼剪斷:Restlet 2.0.8:用於單個restlet應用程序實例的多種身份驗證方法(BASIC,DIGEST)?
@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有可能嗎?
最佳, 克里斯
如果我錯了,請糾正我,但這意味着/ echo和/ status至少受基本權限保護? – Christof
我們想要的只是Echo只受基本身份驗證的Digest和Status保護。 (僞碼): forkingRouter.attach(「/ status」,basicAuth,Template.MODE_STARTS_WITH)我們所做的是引入一個'分叉'路由器,並將digest-和basicAuth路由器連接到不同的路徑。 ; forkingRouter.attach(「/ echo」,digestAuth,Template.MODE_STARTS_WITH); – Christof
這就是要走的路! –