Commit cdec693df54668bade3983f0a9e73befb433bf81

Authored by 张宗朋
1 parent b1a49d9d

base

src/main/java/com/cnlive/mz/live/rest/BaseUtil.java
... ... @@ -28,14 +28,11 @@ import sun.misc.BASE64Encoder;
28 28 public class BaseUtil {
29 29  
30 30 private static final String ENCODING = "UTF-8";
31   -<<<<<<< HEAD
  31 +
32 32 // AccessKey、SecretKey
33 33 private static final String SECRET_KEY = "iqljE4WxQaSMeSd1QP+PPYSpvtK0uWyH0/r6tgi7";
34 34 private static final String ACCESS_KEY = "I3TC8a4xboN9kSJnUIQh";
35   -=======
36   - private static final String AK_SECRET = "7SxVU5lFpqCEQIqxLprQat9BWoyZNKlKfSScTuIk";
37   - private static final String AK_ID = "I3TC8a4xboPUMe5xlp22";
38   ->>>>>>> 180640a4e451ae2b82ae745eb6b1d1651dc5f17f
  35 +
39 36  
40 37 /*
41 38 * 计算MD5+BASE64
... ... @@ -92,11 +89,8 @@ public class BaseUtil {
92 89 Calendar cal = Calendar.getInstance();
93 90 cal.setTime(date);
94 91 long timestamp = cal.getTimeInMillis();
95   -<<<<<<< HEAD
96 92 System.out.println("------timestamp-----"+timestamp);
97 93 //return String.valueOf(timestamp).substring(0, 10);
98   - return "1483200000";
99   -=======
100 94 Calendar calendar = Calendar.getInstance();
101 95 calendar.add(Calendar.DATE,+1);
102 96 SimpleDateFormat sdf = new SimpleDateFormat("MMddHHmmss");
... ... @@ -109,7 +103,7 @@ public class BaseUtil {
109 103 // String ss = sd.format(date);
110 104 return String.valueOf(timestamp);
111 105 //return motoday;
112   ->>>>>>> 180640a4e451ae2b82ae745eb6b1d1651dc5f17f
  106 +
113 107 }
114 108 /**
115 109 * 签名算法:signature 字符串格式,由三部分组成:GET+”\n”+Expire+”\n”+Resource
... ... @@ -120,7 +114,7 @@ public class BaseUtil {
120 114 public static String signature(String streamName) throws UnsupportedEncodingException {
121 115  
122 116 String method = "GET";
123   -<<<<<<< HEAD
  117 +
124 118 String expire = BaseUtil.getTimestamp();
125 119 String app = "live";
126 120 String methodadd = "add";
... ... @@ -137,7 +131,7 @@ public class BaseUtil {
137 131 String signature = HMACSha1(stringToSign, SECRET_KEY);
138 132 System.out.println( "---signature---"+signature );
139 133 signature = java.net.URLEncoder.encode(signature, "utf-8");
140   -=======
  134 +
141 135 String Expire = String.valueOf(BaseUtil.getTimestamp()).substring(0, 10);
142 136 System.out.println(Expire+"---expire----");
143 137 String Resource = "app=live&method=add&nonce=cnlive&public=0&vdoid=12345&stream="+streamName;
... ... @@ -147,12 +141,11 @@ public class BaseUtil {
147 141 String signature = HMACSha1(stringToSign, AK_SECRET);
148 142 System.out.println(signature+"------");
149 143 signature =java.net.URLEncoder.encode(signature,"utf-8");
150   ->>>>>>> 180640a4e451ae2b82ae745eb6b1d1651dc5f17f
  144 +
151 145 return signature;
152 146 }
153 147 public static String signature(String methodNname,String streamName) throws UnsupportedEncodingException {
154 148  
155   -<<<<<<< HEAD
156 149 String method = "GET";
157 150 String expire = BaseUtil.getTimestamp();
158 151 String app = "live";
... ... @@ -174,9 +167,9 @@ public class BaseUtil {
174 167 }
175 168  
176 169 public static String getUUid() {
177   -=======
  170 +
178 171 public static String UUid() {
179   ->>>>>>> 180640a4e451ae2b82ae745eb6b1d1651dc5f17f
  172 +
180 173 String uuid = UUID.randomUUID().toString();
181 174 uuid = uuid.replaceAll("-", "");
182 175 return uuid;
... ... @@ -347,7 +340,7 @@ public class BaseUtil {
347 340 String hhhh = MD5Base64(hh);
348 341 System.out.println(hh);
349 342 System.out.println("..............");
350   -<<<<<<< HEAD
  343 +
351 344 // String str = signature();
352 345 // System.out.println(str);//L2muBoImPzyvwyzfBtGXEu+wRNE=
353 346  
... ... @@ -357,7 +350,7 @@ public class BaseUtil {
357 350  
358 351 // long d = getTimestamp();
359 352 // System.out.println(d);
360   -=======
  353 +
361 354 //String str = signature();
362 355 //System.out.println(str);//L2muBoImPzyvwyzfBtGXEu+wRNE=
363 356 /*// 发送GET请求
... ... @@ -367,6 +360,6 @@ public class BaseUtil {
367 360 System.out.println("response body:" +sendGet(url1, ak_id1, ak_secret1));*/
368 361 //long d = getTimestamp();
369 362 //System.out.println(d);
370   ->>>>>>> 180640a4e451ae2b82ae745eb6b1d1651dc5f17f
  363 +
371 364 }
372 365 }
... ...