私たちはRestlet 2.0.8を使用しており、アプリケーションインスタンスがorg.restlet.Application#createInboundRoot()を上書きしています。そこでは、我々は(現時点では)DigestAuthenticatorをルータインスタンスとリターンを作成し、以下の切り取らコードのように:Restlet 2.0.8:シングルリセレット用の複数の認証方法(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
私たちが望んでいたのは、基本認証でダイジェストとステータスだけでエコーを保護することです。 私たちが行ったことは、 'フォーク'ルーターを導入し、digest-とbasicAuthルーターを異なるパスに接続することです(擬似コード)。 forkingRouter.attach( "/ status"、basicAuth、Template.MODE_STARTS_WITH) ; forkingRouter.attach( "/ echo"、digestAuth、Template.MODE_STARTS_WITH); – Christof
それは行く方法です! –