Package com.qiniu.util
Class Auth
- java.lang.Object
-
- com.qiniu.util.Auth
-
public final class Auth extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAuth.Request
-
Field Summary
Fields Modifier and Type Field Description java.lang.StringaccessKeystatic java.lang.StringDISABLE_QINIU_TIMESTAMP_SIGNATURE_ENV_KEYstatic java.lang.StringDTOKEN_ACTION_STATUSstatic java.lang.StringDTOKEN_ACTION_TUTKstatic java.lang.StringDTOKEN_ACTION_VODstatic java.lang.StringHTTP_HEADER_KEY_CONTENT_TYPE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description StringMapauthorization(java.lang.String url)Deprecated.StringMapauthorization(java.lang.String url, byte[] body, java.lang.String contentType)Deprecated.StringMapauthorizationV2(java.lang.String url)Deprecated.StringMapauthorizationV2(java.lang.String url, java.lang.String method, byte[] body, java.lang.String contentType)Deprecated.static Authcreate(java.lang.String accessKey, java.lang.String secretKey)java.lang.StringgenerateLinkingDeviceStatusTokenWithExpires(java.lang.String appid, java.lang.String deviceName, long expires)java.lang.StringgenerateLinkingDeviceToken(java.lang.String appid, java.lang.String deviceName, long deadline, java.lang.String[] actions)java.lang.StringgenerateLinkingDeviceTokenWithExpires(java.lang.String appid, java.lang.String deviceName, long expires, java.lang.String[] actions)java.lang.StringgenerateLinkingDeviceVodTokenWithExpires(java.lang.String appid, java.lang.String deviceName, long expires)booleanisValidCallback(java.lang.String originAuthorization, Auth.Request callback)验证回调签名是否正确,此方法支持验证 QBox 和 Qiniu 签名booleanisValidCallback(java.lang.String originAuthorization, java.lang.String url, byte[] body, java.lang.String contentType)Deprecated.java.lang.StringprivateDownloadUrl(java.lang.String baseUrl)下载签名java.lang.StringprivateDownloadUrl(java.lang.String baseUrl, long expires)下载签名java.lang.StringprivateDownloadUrlWithDeadline(java.lang.String baseUrl, long deadline)HeadersqiniuAuthorization(java.lang.String url, java.lang.String method, byte[] body, Headers headers)java.lang.Stringsign(byte[] data)Deprecated.java.lang.Stringsign(java.lang.String data)Deprecated.java.lang.StringsignQiniuAuthorization(java.lang.String url, java.lang.String method, byte[] body, Headers headers)java.lang.StringsignQiniuAuthorization(java.lang.String url, java.lang.String method, byte[] body, java.lang.String contentType)java.lang.StringsignRequest(java.lang.String urlString, byte[] body, java.lang.String contentType)Deprecated.java.lang.StringsignRequestV2(java.lang.String url, java.lang.String method, byte[] body, java.lang.String contentType)Deprecated.java.lang.StringsignRoomToken(java.lang.String roomAccess)java.lang.StringsignWithData(byte[] data)Deprecated.java.lang.StringsignWithData(java.lang.String data)Deprecated.java.lang.StringuploadToken(java.lang.String bucket)scope = bucket 一般情况下可通过此方法获取tokenjava.lang.StringuploadToken(java.lang.String bucket, java.lang.String key)scope = bucket:key 同名文件覆盖操作、只能上传指定key的文件可以可通过此方法获取tokenjava.lang.StringuploadToken(java.lang.String bucket, java.lang.String key, long expires, StringMap policy)生成上传tokenjava.lang.StringuploadToken(java.lang.String bucket, java.lang.String key, long expires, StringMap policy, boolean strict)生成上传tokenjava.lang.StringuploadTokenWithDeadline(java.lang.String bucket, java.lang.String key, long deadline, StringMap policy, boolean strict)java.lang.StringuploadTokenWithPolicy(java.lang.Object obj)
-
-
-
Field Detail
-
DISABLE_QINIU_TIMESTAMP_SIGNATURE_ENV_KEY
public static final java.lang.String DISABLE_QINIU_TIMESTAMP_SIGNATURE_ENV_KEY
- See Also:
- Constant Field Values
-
DTOKEN_ACTION_VOD
public static final java.lang.String DTOKEN_ACTION_VOD
- See Also:
- Constant Field Values
-
DTOKEN_ACTION_STATUS
public static final java.lang.String DTOKEN_ACTION_STATUS
- See Also:
- Constant Field Values
-
DTOKEN_ACTION_TUTK
public static final java.lang.String DTOKEN_ACTION_TUTK
- See Also:
- Constant Field Values
-
HTTP_HEADER_KEY_CONTENT_TYPE
public static final java.lang.String HTTP_HEADER_KEY_CONTENT_TYPE
- See Also:
- Constant Field Values
-
accessKey
public final java.lang.String accessKey
-
-
Method Detail
-
create
public static Auth create(java.lang.String accessKey, java.lang.String secretKey)
-
sign
@Deprecated public java.lang.String sign(byte[] data)
Deprecated.
-
sign
@Deprecated public java.lang.String sign(java.lang.String data)
Deprecated.
-
signWithData
@Deprecated public java.lang.String signWithData(byte[] data)
Deprecated.
-
signWithData
@Deprecated public java.lang.String signWithData(java.lang.String data)
Deprecated.
-
signRequest
@Deprecated public java.lang.String signRequest(java.lang.String urlString, byte[] body, java.lang.String contentType)Deprecated.生成HTTP请求签名字符串- Parameters:
urlString- 签名请求的 urlbody- 签名请求的 bodycontentType- 签名请求的 contentType- Returns:
- 签名信息
-
isValidCallback
@Deprecated public boolean isValidCallback(java.lang.String originAuthorization, java.lang.String url, byte[] body, java.lang.String contentType)Deprecated.验证回调签名是否正确,此方法仅能验证 QBox 签名以及 GET 请求的 Qiniu 签名- Parameters:
originAuthorization- 待验证签名字符串,以 "QBox " 作为起始字符,GET 请求支持 "Qiniu " 开头。url- 回调地址body- 回调请求体。原始请求体,不要解析后再封装成新的请求体--可能导致签名不一致。contentType- 回调 ContentType- Returns:
- 签名是否正确
-
isValidCallback
public boolean isValidCallback(java.lang.String originAuthorization, Auth.Request callback)验证回调签名是否正确,此方法支持验证 QBox 和 Qiniu 签名- Parameters:
originAuthorization- 待验证签名字符串,以 "QBox " 或 "Qiniu " 作为起始字符callback- callback 请求信息- Returns:
- 签名是否正确
-
privateDownloadUrl
public java.lang.String privateDownloadUrl(java.lang.String baseUrl)
下载签名- Parameters:
baseUrl- 待签名文件url,如 http://img.domain.com/u/3.jpg 、 http://img.domain.com/u/3.jpg?imageView2/1/w/120- Returns:
- 签名
-
privateDownloadUrl
public java.lang.String privateDownloadUrl(java.lang.String baseUrl, long expires)下载签名- Parameters:
baseUrl- 待签名文件url,如 http://img.domain.com/u/3.jpg 、 http://img.domain.com/u/3.jpg?imageView2/1/w/120expires- 有效时长,单位秒。默认3600s- Returns:
- 签名
-
privateDownloadUrlWithDeadline
public java.lang.String privateDownloadUrlWithDeadline(java.lang.String baseUrl, long deadline)
-
uploadToken
public java.lang.String uploadToken(java.lang.String bucket)
scope = bucket 一般情况下可通过此方法获取token- Parameters:
bucket- 空间名- Returns:
- 生成的上传token
-
uploadToken
public java.lang.String uploadToken(java.lang.String bucket, java.lang.String key)scope = bucket:key 同名文件覆盖操作、只能上传指定key的文件可以可通过此方法获取token- Parameters:
bucket- 空间名key- key,可为 null- Returns:
- 生成的上传token
-
uploadToken
public java.lang.String uploadToken(java.lang.String bucket, java.lang.String key, long expires, StringMap policy)生成上传token- Parameters:
bucket- 空间名key- key,可为 nullexpires- 有效时长,单位秒policy- 上传策略的其它参数,如 new StringMap().put("endUser", "uid").putNotEmpty("returnBody", "")。 scope通过 bucket、key间接设置,deadline 通过 expires 间接设置- Returns:
- 生成的上传token
-
uploadToken
public java.lang.String uploadToken(java.lang.String bucket, java.lang.String key, long expires, StringMap policy, boolean strict)生成上传token- Parameters:
bucket- 空间名key- key,可为 nullexpires- 有效时长,单位秒。默认3600spolicy- 上传策略的其它参数,如 new StringMap().put("endUser", "uid").putNotEmpty("returnBody", "")。 scope通过 bucket、key间接设置,deadline 通过 expires 间接设置strict- 是否去除非限定的策略字段,默认true- Returns:
- 生成的上传token
-
uploadTokenWithDeadline
public java.lang.String uploadTokenWithDeadline(java.lang.String bucket, java.lang.String key, long deadline, StringMap policy, boolean strict)
-
uploadTokenWithPolicy
public java.lang.String uploadTokenWithPolicy(java.lang.Object obj)
-
authorization
@Deprecated public StringMap authorization(java.lang.String url, byte[] body, java.lang.String contentType)
Deprecated.
-
authorization
@Deprecated public StringMap authorization(java.lang.String url)
Deprecated.
-
signRequestV2
@Deprecated public java.lang.String signRequestV2(java.lang.String url, java.lang.String method, byte[] body, java.lang.String contentType)Deprecated.生成 HTTP 请求签名字符串- Parameters:
url- 签名请求的 urlmethod- 签名请求的 methodbody- 签名请求的 bodycontentType- 签名请求的 contentType- Returns:
- 签名
-
signQiniuAuthorization
public java.lang.String signQiniuAuthorization(java.lang.String url, java.lang.String method, byte[] body, java.lang.String contentType)
-
signQiniuAuthorization
public java.lang.String signQiniuAuthorization(java.lang.String url, java.lang.String method, byte[] body, Headers headers)
-
qiniuAuthorization
public Headers qiniuAuthorization(java.lang.String url, java.lang.String method, byte[] body, Headers headers)
-
authorizationV2
@Deprecated public StringMap authorizationV2(java.lang.String url, java.lang.String method, byte[] body, java.lang.String contentType)
Deprecated.
-
authorizationV2
@Deprecated public StringMap authorizationV2(java.lang.String url)
Deprecated.
-
signRoomToken
public java.lang.String signRoomToken(java.lang.String roomAccess) throws java.lang.Exception- Throws:
java.lang.Exception
-
generateLinkingDeviceToken
public java.lang.String generateLinkingDeviceToken(java.lang.String appid, java.lang.String deviceName, long deadline, java.lang.String[] actions)
-
generateLinkingDeviceTokenWithExpires
public java.lang.String generateLinkingDeviceTokenWithExpires(java.lang.String appid, java.lang.String deviceName, long expires, java.lang.String[] actions)
-
generateLinkingDeviceVodTokenWithExpires
public java.lang.String generateLinkingDeviceVodTokenWithExpires(java.lang.String appid, java.lang.String deviceName, long expires)
-
generateLinkingDeviceStatusTokenWithExpires
public java.lang.String generateLinkingDeviceStatusTokenWithExpires(java.lang.String appid, java.lang.String deviceName, long expires)
-
-