Commit 5de358d38e885505866c4882267c2ab0f2bd4c8d
1 parent
6faf7fc9
格式调整
Showing
5 changed files
with
57 additions
and
58 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java
| 1 | 1 | /* |
| 2 | -* Conditions Of Use | |
| 3 | -* | |
| 4 | -* This software was developed by employees of the National Institute of | |
| 5 | -* Standards and Technology (NIST), an agency of the Federal Government. | |
| 6 | -* Pursuant to title 15 Untied States Code Section 105, works of NIST | |
| 7 | -* employees are not subject to copyright protection in the United States | |
| 8 | -* and are considered to be in the public domain. As a result, a formal | |
| 9 | -* license is not needed to use the software. | |
| 10 | -* | |
| 11 | -* This software is provided by NIST as a service and is expressly | |
| 12 | -* provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED | |
| 13 | -* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF | |
| 14 | -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT | |
| 15 | -* AND DATA ACCURACY. NIST does not warrant or make any representations | |
| 16 | -* regarding the use of the software or the results thereof, including but | |
| 17 | -* not limited to the correctness, accuracy, reliability or usefulness of | |
| 18 | -* the software. | |
| 19 | -* | |
| 20 | -* Permission to use this software is contingent upon your acceptance | |
| 21 | -* of the terms of this agreement | |
| 22 | -* | |
| 23 | -* . | |
| 24 | -* | |
| 25 | -*/ | |
| 2 | + * Conditions Of Use | |
| 3 | + * | |
| 4 | + * This software was developed by employees of the National Institute of | |
| 5 | + * Standards and Technology (NIST), an agency of the Federal Government. | |
| 6 | + * Pursuant to title 15 Untied States Code Section 105, works of NIST | |
| 7 | + * employees are not subject to copyright protection in the United States | |
| 8 | + * and are considered to be in the public domain. As a result, a formal | |
| 9 | + * license is not needed to use the software. | |
| 10 | + * | |
| 11 | + * This software is provided by NIST as a service and is expressly | |
| 12 | + * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED | |
| 13 | + * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF | |
| 14 | + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT | |
| 15 | + * AND DATA ACCURACY. NIST does not warrant or make any representations | |
| 16 | + * regarding the use of the software or the results thereof, including but | |
| 17 | + * not limited to the correctness, accuracy, reliability or usefulness of | |
| 18 | + * the software. | |
| 19 | + * | |
| 20 | + * Permission to use this software is contingent upon your acceptance | |
| 21 | + * of the terms of this agreement | |
| 22 | + * | |
| 23 | + * . | |
| 24 | + * | |
| 25 | + */ | |
| 26 | 26 | package com.genersoft.iot.vmp.gb28181.auth; |
| 27 | 27 | |
| 28 | 28 | import java.security.MessageDigest; |
| ... | ... | @@ -42,18 +42,18 @@ import gov.nist.core.InternalErrorHandler; |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Implements the HTTP digest authentication method server side functionality. |
| 45 | - * | |
| 45 | + * | |
| 46 | 46 | * @author M. Ranganathan |
| 47 | 47 | * @author Marc Bednarek |
| 48 | 48 | */ |
| 49 | 49 | |
| 50 | 50 | public class DigestServerAuthenticationHelper { |
| 51 | - | |
| 51 | + | |
| 52 | 52 | private MessageDigest messageDigest; |
| 53 | - | |
| 53 | + | |
| 54 | 54 | public static final String DEFAULT_ALGORITHM = "MD5"; |
| 55 | 55 | public static final String DEFAULT_SCHEME = "Digest"; |
| 56 | - | |
| 56 | + | |
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | |
| ... | ... | @@ -63,11 +63,11 @@ public class DigestServerAuthenticationHelper { |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * Default constructor. |
| 66 | - * @throws NoSuchAlgorithmException | |
| 66 | + * @throws NoSuchAlgorithmException | |
| 67 | 67 | */ |
| 68 | - public DigestServerAuthenticationHelper() | |
| 69 | - throws NoSuchAlgorithmException { | |
| 70 | - messageDigest = MessageDigest.getInstance(DEFAULT_ALGORITHM); | |
| 68 | + public DigestServerAuthenticationHelper() | |
| 69 | + throws NoSuchAlgorithmException { | |
| 70 | + messageDigest = MessageDigest.getInstance(DEFAULT_ALGORITHM); | |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | public static String toHexString(byte b[]) { |
| ... | ... | @@ -79,7 +79,7 @@ public class DigestServerAuthenticationHelper { |
| 79 | 79 | } |
| 80 | 80 | return new String(c); |
| 81 | 81 | } |
| 82 | - | |
| 82 | + | |
| 83 | 83 | /** |
| 84 | 84 | * Generate the challenge string. |
| 85 | 85 | * |
| ... | ... | @@ -121,34 +121,34 @@ public class DigestServerAuthenticationHelper { |
| 121 | 121 | * |
| 122 | 122 | * @param request - the request to authenticate. |
| 123 | 123 | * @param hashedPassword -- the MD5 hashed string of username:realm:plaintext password. |
| 124 | - * | |
| 124 | + * | |
| 125 | 125 | * @return true if authentication succeded and false otherwise. |
| 126 | 126 | */ |
| 127 | 127 | public boolean doAuthenticateHashedPassword(Request request, String hashedPassword) { |
| 128 | - AuthorizationHeader authHeader = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); | |
| 128 | + AuthorizationHeader authHeader = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); | |
| 129 | 129 | if ( authHeader == null ) return false; |
| 130 | 130 | String realm = authHeader.getRealm(); |
| 131 | 131 | String username = authHeader.getUsername(); |
| 132 | - | |
| 132 | + | |
| 133 | 133 | if ( username == null || realm == null ) { |
| 134 | 134 | return false; |
| 135 | 135 | } |
| 136 | - | |
| 136 | + | |
| 137 | 137 | String nonce = authHeader.getNonce(); |
| 138 | 138 | URI uri = authHeader.getURI(); |
| 139 | 139 | if (uri == null) { |
| 140 | 140 | return false; |
| 141 | 141 | } |
| 142 | - | |
| 143 | 142 | |
| 144 | - | |
| 143 | + | |
| 144 | + | |
| 145 | 145 | String A2 = request.getMethod().toUpperCase() + ":" + uri.toString(); |
| 146 | 146 | String HA1 = hashedPassword; |
| 147 | 147 | |
| 148 | - | |
| 148 | + | |
| 149 | 149 | byte[] mdbytes = messageDigest.digest(A2.getBytes()); |
| 150 | 150 | String HA2 = toHexString(mdbytes); |
| 151 | - | |
| 151 | + | |
| 152 | 152 | String cnonce = authHeader.getCNonce(); |
| 153 | 153 | String KD = HA1 + ":" + nonce; |
| 154 | 154 | if (cnonce != null) { |
| ... | ... | @@ -158,7 +158,7 @@ public class DigestServerAuthenticationHelper { |
| 158 | 158 | mdbytes = messageDigest.digest(KD.getBytes()); |
| 159 | 159 | String mdString = toHexString(mdbytes); |
| 160 | 160 | String response = authHeader.getResponse(); |
| 161 | - | |
| 161 | + | |
| 162 | 162 | |
| 163 | 163 | return mdString.equals(response); |
| 164 | 164 | } |
| ... | ... | @@ -168,11 +168,11 @@ public class DigestServerAuthenticationHelper { |
| 168 | 168 | * |
| 169 | 169 | * @param request - the request to authenticate. |
| 170 | 170 | * @param pass -- the plain text password. |
| 171 | - * | |
| 171 | + * | |
| 172 | 172 | * @return true if authentication succeded and false otherwise. |
| 173 | 173 | */ |
| 174 | 174 | public boolean doAuthenticatePlainTextPassword(Request request, String pass) { |
| 175 | - AuthorizationHeader authHeader = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); | |
| 175 | + AuthorizationHeader authHeader = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); | |
| 176 | 176 | if ( authHeader == null ) return false; |
| 177 | 177 | String realm = authHeader.getRealm().trim(); |
| 178 | 178 | String username = authHeader.getUsername().trim(); |
| ... | ... | @@ -184,7 +184,7 @@ public class DigestServerAuthenticationHelper { |
| 184 | 184 | String nonce = authHeader.getNonce(); |
| 185 | 185 | URI uri = authHeader.getURI(); |
| 186 | 186 | if (uri == null) { |
| 187 | - return false; | |
| 187 | + return false; | |
| 188 | 188 | } |
| 189 | 189 | // qop 保护质量 包含auth(默认的)和auth-int(增加了报文完整性检测)两种策略 |
| 190 | 190 | String qop = authHeader.getQop(); |
| ... | ... | @@ -233,6 +233,6 @@ public class DigestServerAuthenticationHelper { |
| 233 | 233 | String response = authHeader.getResponse(); |
| 234 | 234 | System.out.println("response: " + response); |
| 235 | 235 | return mdString.equals(response); |
| 236 | - | |
| 236 | + | |
| 237 | 237 | } |
| 238 | 238 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
src/main/resources/application-dev.yml
| ... | ... | @@ -13,12 +13,12 @@ spring: |
| 13 | 13 | timeout: 10000 |
| 14 | 14 | # [不可用] jdbc数据库配置, 暂不支持 |
| 15 | 15 | datasource: |
| 16 | - # name: eiot | |
| 17 | - # url: jdbc:mysql://127.0.0.1:3306/eiot?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true | |
| 18 | - # username: | |
| 19 | - # password: | |
| 20 | - # type: com.alibaba.druid.pool.DruidDataSource | |
| 21 | - # driver-class-name: com.mysql.jdbc.Driver | |
| 16 | + #name: eiot | |
| 17 | + #url: jdbc:mysql://127.0.0.1:3306/eiot?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true | |
| 18 | + #username: | |
| 19 | + #password: | |
| 20 | + #type: com.alibaba.druid.pool.DruidDataSource | |
| 21 | + #driver-class-name: com.mysql.jdbc.Driver | |
| 22 | 22 | name: eiot |
| 23 | 23 | url: jdbc:sqlite::resource:wvp.sqlite |
| 24 | 24 | username: | ... | ... |
src/main/resources/application.yml
web_src/src/components/gb28181/devicePlayer.vue
| 1 | 1 | <template> |
| 2 | 2 | <div id="devicePlayer" v-loading="isLoging"> |
| 3 | - | |
| 3 | + | |
| 4 | 4 | <el-dialog title="视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" :destroy-on-close="true" @close="close()"> |
| 5 | 5 | <!-- <LivePlayer v-if="showVideoDialog" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" :message="videoError" :hasaudio="hasaudio" fluent autoplay live></LivePlayer> --> |
| 6 | 6 | <player ref="videoPlayer" :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError" :hasaudio="hasaudio" fluent autoplay live></player> |
| ... | ... | @@ -125,7 +125,7 @@ |
| 125 | 125 | <p>采样率: {{item.sample_rate}}</p> |
| 126 | 126 | </div> |
| 127 | 127 | </div> |
| 128 | - | |
| 128 | + | |
| 129 | 129 | </div> |
| 130 | 130 | |
| 131 | 131 | </el-tab-pane> |
| ... | ... | @@ -237,7 +237,7 @@ export default { |
| 237 | 237 | console.log(val) |
| 238 | 238 | }, |
| 239 | 239 | play: function (streamInfo, hasAudio) { |
| 240 | - | |
| 240 | + | |
| 241 | 241 | this.hasaudio = hasAudio; |
| 242 | 242 | this.isLoging = false; |
| 243 | 243 | this.videoUrl = streamInfo.ws_flv; |
| ... | ... | @@ -319,7 +319,7 @@ export default { |
| 319 | 319 | } |
| 320 | 320 | this.convertKey = '' |
| 321 | 321 | }, |
| 322 | - | |
| 322 | + | |
| 323 | 323 | copySharedInfo: function (data) { |
| 324 | 324 | console.log('复制内容:' + data); |
| 325 | 325 | this.coverPlaying = false; | ... | ... |