Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Jersey API客户端中配置身份验证标头_Java_Rest_Authentication_Jersey - Fatal编程技术网

Java 在Jersey API客户端中配置身份验证标头

Java 在Jersey API客户端中配置身份验证标头,java,rest,authentication,jersey,Java,Rest,Authentication,Jersey,以下是在Jersey API中配置身份验证头的方法 //Universal builder having different credentials for different schemes HttpAuthenticationFeature feature = HttpAuthenticationFeature.universalBuilder() .credentialsForBasic("username1", "password1") .credentials("username

以下是在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服务需要传递以下参数作为身份验证头的一部分

  • 用户名

  • 密码

  • 整合市场

  • 森德贝哈尔福

  • 我应该如何使用Jersey API实现这一点?

    您在问题中没有提供足够的信息。很难猜到你想要实现什么。你确实应该考虑用更多的细节来更新你的问题。


    看一看你提供的肤浅信息,我想你是在试图访问。如果是,您可以创建一个,如下所示:

    公共类DocuSignAuthenticator实现ClientRequestFilter{
    私有字符串用户;
    私有字符串密码;
    私有字符串整合器;
    私有字符串sendBehalfOf;
    公共DocuSignAuthenticator(字符串用户名、字符串密码、,
    字符串integatorKey、字符串sendBehalfOf){
    this.username=用户名;
    this.password=密码;
    this.integatorKey=integatorKey;
    this.sendBehalfOf=sendBehalfOf;
    }
    @凌驾
    公共无效筛选器(ClientRequestContext requestContext)引发IOException{
    requestContext.getHeaders().add(
    “X-DocuSign-Authentication”,getAuthenticationHeader();
    }
    私有字符串getAuthenticationHeader(){
    StringBuilder=新的StringBuilder();
    生成器。追加(“”);
    生成器。追加(“”);
    builder.append(sendBehalfOf);
    生成器。追加(“”);
    生成器。追加(“”);
    builder.append(用户名);
    生成器。追加(“”);
    生成器。追加(“”);
    builder.append(密码);
    生成器。追加(“”);
    生成器。追加(“”);
    builder.append(integratorkey);
    生成器。追加(“”);
    生成器。追加(“”);
    返回builder.toString();
    }
    }
    
    并在创建实例时进行注册:

    Client-Client=ClientBuilder.newClient().register(
    新的DocuSignAuthenticator(用户名、密码、integatorKey、sendBehalfOf));
    
    您需要如何发送这些附加参数?信息不足。请对API的要求做更多的研究,并用适当的术语更新您的帖子以详细反映这些要求。你的帖子在当前状态下没有多大意义。我会试试你的approach@Damajikalunge请考虑在您的问题中提供更多的细节。它将遵循哪种认证策略:Basic:基本非抢占:通用:@ DaaJikalunGe,它是一个自定义身份验证。为什么不提供更多关于您试图实现的目标的详细信息呢?我正在尝试使用jersey API使用DocuSign服务。