2016-04-12 22 views
0

Jersey APIで認証ヘッダーを設定するには、次の方法があります。Jersey APIクライアント側の認証ヘッダーの設定

//Universal builder having different credentials for different schemes 

HttpAuthenticationFeature feature = HttpAuthenticationFeature.universalBuilder() 

.credentialsForBasic("username1", "password1") 

.credentials("username2", "password2").build(); 



final Client client = ClientBuilder.newClient(); 

client.register(feature); 

しかし、追加のパラメータを認証ヘッダーに渡す方法を把握することができません。 IntegatorKey、SendBehalfOf。それらは特定のRESTサービスコールです。

私の場合、RESTサービスを呼び出すには、認証ヘッダーの一部として次のパラメータを渡す必要があります。

  1. ユーザー名

  2. パスワード

  3. IntegatorKey

  4. SendBehalfOf

はどのようジャージーAPIを使用してこれを達成する必要がありますか?

+0

Clientインスタンスを作成する際に

public class DocuSignAuthenticator implements ClientRequestFilter { private String user; private String password; private String integatorKey; private String sendBehalfOf; public DocuSignAuthenticator(String username, String password, String integatorKey, String sendBehalfOf) { this.username = username; this.password = password; this.integatorKey = integatorKey; this.sendBehalfOf = sendBehalfOf; } @Override public void filter(ClientRequestContext requestContext) throws IOException { requestContext.getHeaders().add( "X-DocuSign-Authentication", getAuthenticationHeader()); } private String getAuthenticationHeader() { StringBuilder builder = new StringBuilder(); builder.append("<DocuSignCredentials>"); builder.append("<SendOnBehalfOf>"); builder.append(sendBehalfOf); builder.append("</SendOnBehalfOf>"); builder.append("<Username>"); builder.append(username); builder.append("</Username>"); builder.append("<Password>"); builder.append(password); builder.append("</Password>"); builder.append("<IntegratorKey>"); builder.append(integatorKey); builder.append("</IntegratorKey>"); builder.append("</DocuSignCredentials>"); return builder.toString(); } } 

をし、それを登録します。もしそうなら、あなたは以下のように、ClientRequestFilterを作成することができますか? –

+0

情報が不十分です。 APIが必要とするものについてさらに調査を行い、これらの要件を適切な用語で詳細に反映するように投稿を更新してください。あなたの投稿は現在の状態ではあまり意味がありません。 –

答えて

0

質問に十分な情報を提供していません。達成しようとしていることを推測するのは難しいです。あなたは本当に詳細をあなたの質問を更新することを検討する必要があります。


あなたは、私はあなたがDocuSign REST APIにアクセスしようとしている推測提供表層情報を見て持ちます。あなたはこれらの追加パラメータを送信する必要がありますどのように

Client client = ClientBuilder.newClient().register(
     new DocuSignAuthenticator(username, password, integatorKey, sendBehalfOf)); 
+0

私はあなたのアプローチを試してみます –

+0

@Damajikalungeあなたの質問で詳細を提供することを検討してください。 –

+0

基本認証: 基本的ではない: ユニバーサル: –

関連する問題