生成签名

<p class="shortdesc"></p> <p class="p"><strong class="ph b">使用范围</strong></p> <p class="p">JS SDK、Android SDK、IOS SDK、Python SDK等自身未实现签名算法的SDK以及API方式接入。</p> <p class="p"><strong class="ph b">依赖</strong></p> <p class="p"><a class="xref" href="/ssr/help/storage/obs/OBS_SDK_.Java_SDK_" target="_blank">JAVA SDK下载</a></p> <p class="p"><strong class="ph b">代码示例</strong></p> <pre class="pre codeblock"><code>初始化service RadosgwService radosgwService = RadosgwServiceFactory.getFromConfigObject(new ObsClientConfig() { public String getUserAgent() { return "系统英文名称"; } public String getObsUrl() { return "一般为OBS域名,只用于生成签名时可自定义填写"; } public String getObsAccessKey() { return "有访问权限的AK"; } public String getObsSecret() { return "有访问权限的SK"; } public boolean isRepresentPathInKey() { return false; } });</code></pre> <pre class="pre codeblock"><code>Controller层 @PostMapping(value = "/getSign") public String getMobileSign(@RequestBody @Validated SignatureParamBean bean) throws Exception { AuthSignData signData = new AuthSignData(); signData.setRequestPath(bean.getUri()); signData.setRequestMethod(bean.getMethod()); signData.setContentType(bean.getContentType()); signData.getSignData().put("Date", StringUtils.isEmpty(bean.getDate()) ? bean.getExpires() : bean.getDate()); String signature = radosgwService.getSign(signData); log.debug("sign params:{}", new Gson().toJson(bean)); return "AWS " + ak + ':' + signature; }</code></pre> <pre class="pre codeblock"><code>SignatureParamBean类 public class SignatureParamBean { @NotBlank(message = "uri can not be blank") private String uri; private String contentType; /** * date和expires必填其一 */ private String date; private String expires; @NotBlank(message = "method can not be blank") private String method; //TODO getter、setter方法 } </code></pre>
以上内容是否解决了您的问题?
请补全提交信息!
咨询·建议

电话咨询

400-151-8800

邮件咨询

cloud@pingan.com

在线客服

工单支持

解决云产品相关技术问题