|
@@ -10,6 +10,7 @@ import com.alibaba.sdk.android.oss.common.OSSConstants;
|
10
|
10
|
import com.alibaba.sdk.android.oss.common.auth.OSSCredentialProvider;
|
11
|
11
|
import com.alibaba.sdk.android.oss.common.auth.OSSCustomSignerCredentialProvider;
|
12
|
12
|
import com.alibaba.sdk.android.oss.common.auth.OSSFederationCredentialProvider;
|
|
13
|
+import com.alibaba.sdk.android.oss.common.auth.OSSPlainTextAKSKCredentialProvider;
|
13
|
14
|
import com.alibaba.sdk.android.oss.common.auth.OSSFederationToken;
|
14
|
15
|
import com.alibaba.sdk.android.oss.common.auth.OSSStsTokenCredentialProvider;
|
15
|
16
|
import com.alibaba.sdk.android.oss.common.utils.IOUtils;
|
|
@@ -83,27 +84,8 @@ public class AliyunAuthManager {
|
83
|
84
|
String accessKeySecret,
|
84
|
85
|
String endPoint,
|
85
|
86
|
ReadableMap configuration) {
|
86
|
|
- OSSCredentialProvider credentialProvider = new OSSFederationCredentialProvider() {
|
87
|
|
- @Override
|
88
|
|
- public OSSFederationToken getFederationToken() {
|
89
|
|
- try {
|
90
|
|
- URL stsUrl = new URL("http://yourip:port");
|
91
|
|
- HttpURLConnection conn = (HttpURLConnection) stsUrl.openConnection();
|
92
|
|
- InputStream input = conn.getInputStream();
|
93
|
|
- String jsonText = IOUtils.readStreamAsString(input, OSSConstants.DEFAULT_CHARSET_NAME);
|
94
|
|
- JSONObject jsonObjs = new JSONObject(jsonText);
|
95
|
|
- String ak = jsonObjs.getString("AccessKeyId");
|
96
|
|
- String sk = jsonObjs.getString("AccessKeySecret");
|
97
|
|
- String token = jsonObjs.getString("SecurityToken");
|
98
|
|
- String expiration = jsonObjs.getString("Expiration");
|
99
|
|
- return new OSSFederationToken(ak, sk, token, expiration);
|
100
|
|
- } catch (Exception e) {
|
101
|
|
- e.printStackTrace();
|
102
|
|
- }
|
103
|
|
- return null;
|
104
|
|
- }
|
105
|
|
- };
|
106
|
87
|
|
|
88
|
+ OSSCredentialProvider credentialProvider = new OSSPlainTextAKSKCredentialProvider(accessKeyId,accessKeySecret);
|
107
|
89
|
// init conf
|
108
|
90
|
ClientConfiguration conf = ConfigUtils.initAuthConfig(configuration);
|
109
|
91
|
|