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