Browse Source

Merge pull request #11 from aliyun/luozhang

repair initWithAKSK
Albert Luo 6 years ago
parent
commit
cfa75d12a7
No account linked to committer's email address
5 changed files with 7 additions and 25 deletions
  1. 1
    1
      Example/package.json
  2. 2
    2
      README-CN.md
  3. 1
    1
      README.md
  4. 2
    20
      android/src/main/java/com/reactlibrary/AliyunAuthManager.java
  5. 1
    1
      package.json

+ 1
- 1
Example/package.json View File

@@ -9,7 +9,7 @@
9 9
   "dependencies": {
10 10
     "react": "16.3.1",
11 11
     "react-native": "0.55.4",
12
-    "aliyun-oss-react-native": "^1.0.0-alpha.5",
12
+    "aliyun-oss-react-native": "^1.0.0-alpha.6",
13 13
     "react-native-image-picker": "^0.26.10"
14 14
   },
15 15
   "devDependencies": {

+ 2
- 2
README-CN.md View File

@@ -191,9 +191,9 @@ asyncDeleteObject | 支持| 支持
191 191
 AliyunOSS.enableDevMode()
192 192
 ```
193 193
 
194
-### initWithPlainTextAccessKey
194
+### initWithPlainTextAccessKey(不建议)
195 195
 
196
-该接口需要通过明文授权acckeyId和accekeySecret,使用可查看
196
+该接口需要通过明文授权acckeyId和accekeySecret,开发者这可以使用,但是我们不建议
197 197
 
198 198
 ```javascript
199 199
 const endPoint = "XXX"

+ 1
- 1
README.md View File

@@ -197,7 +197,7 @@ AliyunOSS.enableDevMode()
197 197
 
198 198
 ### initWithPlainTextAccessKey
199 199
 
200
-init auth client with accessKeyId and accessKeySecret,please refer to the code.
200
+init auth client with accessKeyId and accessKeySecret,please refer to the code.you can use ,but we do not suggest use it。
201 201
 
202 202
 ```javascript
203 203
 const endPoint = "XXX"

+ 2
- 20
android/src/main/java/com/reactlibrary/AliyunAuthManager.java View File

@@ -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
 

+ 1
- 1
package.json View File

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "aliyun-oss-react-native",
3
-  "version": "1.0.0-alpha.5",
3
+  "version": "1.0.0-alpha.6",
4 4
   "description": "React Native SDK for aliyun object storage service",
5 5
   "main": "index.js",
6 6
   "scripts": {