Skip to content

Commit ba43e12

Browse files
committed
fix bug in FAToken
1 parent 1e131ba commit ba43e12

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

cloudkey-1.1.jar

16 Bytes
Binary file not shown.

examples/Example.class

424 Bytes
Binary file not shown.

examples/Example.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public static void mediaList() {
4949

5050
public static void testToken() {
5151
FAToken token1 = new FAToken(user_id, "111111111111111111111111", api_key, 1338947483);
52-
token1.setCallback("http://www.dmcloud.com/fa2");
53-
token1.setData("firstname", "john");
54-
token1.setData("lastname", "doe");
52+
token1.setCallbackUrl("http://www.dmcloud.com/fa2");
53+
token1.setMeta("firstname", "john");
54+
token1.setMeta("lastname", "doe");
5555
token1.setRight("start_date", "1327946483");
5656
token1.setRight("end_date", "1338947483");
5757
token1.setRight("playback_window", "600");
@@ -74,6 +74,7 @@ public static void testToken() {
7474
}
7575
}
7676
} catch(Exception e) {
77+
e.printStackTrace();
7778
System.out.println("oups");
7879
System.out.println(e);
7980
}
@@ -103,8 +104,8 @@ public static void getApiKey() {
103104

104105
public static void main(String[] args) {
105106
//mediaList();
106-
//testToken();
107-
getApiKey();
107+
testToken();
108+
//getApiKey();
108109
}
109110

110111
}

src/net/dmcloud/util/FAToken.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public class FAToken {
1717
private String media_id = null;
1818
private String api_key = null;
1919
private String nonce = null;
20-
private HashMap<String,String> rights;
21-
private HashMap<String,String> meta;
20+
private HashMap<String,String> rights = null;
21+
private HashMap<String,String> meta = null;
2222
private String callback_url = null;
2323
private Integer expires = 0;
2424
private Integer maxReplay = 0;
@@ -53,9 +53,13 @@ public FAToken(String token, String api_key, Boolean check_auth) throws Exceptio
5353
}
5454
if (token_info.containsKey("rights")) {
5555
rights = (HashMap<String,String>)token_info.get("rights");
56+
} else {
57+
rights = new HashMap<String,String>();
5658
}
5759
if (token_info.containsKey("meta")) {
5860
meta = (HashMap<String,String>)token_info.get("meta");
61+
} else {
62+
meta = new HashMap<String,String>();
5963
}
6064
if (token_info.containsKey("callback_url")) {
6165
callback_url = token_info.get("callback_url").toString();
@@ -157,7 +161,6 @@ public String getAuth(DCObject token_info) {
157161
public String toJSON() throws Exception {
158162
ObjectMapper mapper;
159163
DCObject token_info;
160-
161164
if (nonce == null) {
162165
genNonce();
163166
}

0 commit comments

Comments
 (0)