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
   "dependencies": {
9
   "dependencies": {
10
     "react": "16.3.1",
10
     "react": "16.3.1",
11
     "react-native": "0.55.4",
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
     "react-native-image-picker": "^0.26.10"
13
     "react-native-image-picker": "^0.26.10"
14
   },
14
   },
15
   "devDependencies": {
15
   "devDependencies": {

+ 2
- 2
README-CN.md View File

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

+ 1
- 1
README.md View File

197
 
197
 
198
 ### initWithPlainTextAccessKey
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
 ```javascript
202
 ```javascript
203
 const endPoint = "XXX"
203
 const endPoint = "XXX"

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

10
 import com.alibaba.sdk.android.oss.common.auth.OSSCredentialProvider;
10
 import com.alibaba.sdk.android.oss.common.auth.OSSCredentialProvider;
11
 import com.alibaba.sdk.android.oss.common.auth.OSSCustomSignerCredentialProvider;
11
 import com.alibaba.sdk.android.oss.common.auth.OSSCustomSignerCredentialProvider;
12
 import com.alibaba.sdk.android.oss.common.auth.OSSFederationCredentialProvider;
12
 import com.alibaba.sdk.android.oss.common.auth.OSSFederationCredentialProvider;
13
+import com.alibaba.sdk.android.oss.common.auth.OSSPlainTextAKSKCredentialProvider;
13
 import com.alibaba.sdk.android.oss.common.auth.OSSFederationToken;
14
 import com.alibaba.sdk.android.oss.common.auth.OSSFederationToken;
14
 import com.alibaba.sdk.android.oss.common.auth.OSSStsTokenCredentialProvider;
15
 import com.alibaba.sdk.android.oss.common.auth.OSSStsTokenCredentialProvider;
15
 import com.alibaba.sdk.android.oss.common.utils.IOUtils;
16
 import com.alibaba.sdk.android.oss.common.utils.IOUtils;
83
                                            String accessKeySecret,
84
                                            String accessKeySecret,
84
                                            String endPoint,
85
                                            String endPoint,
85
                                            ReadableMap configuration) {
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
         // init conf
89
         // init conf
108
         ClientConfiguration conf = ConfigUtils.initAuthConfig(configuration);
90
         ClientConfiguration conf = ConfigUtils.initAuthConfig(configuration);
109
 
91
 

+ 1
- 1
package.json View File

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