Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
deviceCheat
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
luozhenzhen
deviceCheat
Commits
56dd266f
Commit
56dd266f
authored
Sep 17, 2019
by
luozhenzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改jar包下载接口
parent
367c0cae
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
25 deletions
+60
-25
DataImportController.java
src/main/java/com/demo/mongodb/DataImportController.java
+4
-2
DevicecheatController.java
src/main/java/com/demo/mongodb/DevicecheatController.java
+16
-12
FileEncryptor.java
src/main/java/com/demo/util/FileEncryptor.java
+38
-10
application-dev.properties
src/main/resources/application-dev.properties
+2
-1
keystore_win.p12
src/main/resources/keystore_win.p12
+0
-0
No files found.
src/main/java/com/demo/mongodb/DataImportController.java
View file @
56dd266f
...
...
@@ -306,7 +306,8 @@ public class DataImportController {
"\t\t\t\"type\": \"oc\"\n"
+
"\t\t}\n"
+
"\t],\n"
+
"\"period\":1800"
+
"\"period\":1800,"
+
"\"heart_period\":30"
+
"}"
;
str
=
str
.
replaceAll
(
"\n"
,
""
);
...
...
@@ -744,7 +745,8 @@ public class DataImportController {
"\"jarurl\":\"https://39.104.115.147:10081/downloadFile\","
+
"\"key\":\"5662e7c3d61fd5e0e67acd8bace6d1b0\""
+
"},"
+
"\"period\":1800"
+
"\"period\":1800,"
+
"\"heart_period\":30"
+
"}"
;
str
=
str
.
replaceAll
(
"\n"
,
""
);
str
=
str
.
replaceAll
(
"\t"
,
""
);
...
...
src/main/java/com/demo/mongodb/DevicecheatController.java
View file @
56dd266f
...
...
@@ -104,25 +104,29 @@ public class DevicecheatController {
}
@RequestMapping
(
value
=
"/encryptorFile"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
ResultObject
deviceconf
()
throws
Exception
{
String
sourceFilePath
=
"/data/application/deviceCheck/updateJar/update.jar"
;
String
destFilePath
=
"/data/application/deviceCheck/updateJar/encryptorFile/update.jar"
;
//
@RequestMapping(value = "/encryptorFile", method = RequestMethod.GET)
//
@ResponseBody
//
public ResultObject deviceconf() throws Exception {
////
String sourceFilePath = "/data/application/deviceCheck/updateJar/update.jar";
////
String destFilePath = "/data/application/deviceCheck/updateJar/encryptorFile/update.jar";
// String sourceFilePath = "C:\\Users\\reyun\\Desktop\\update.jar";
// String destFilePath = "C:\\Users\\reyun\\Desktop\\update_2.jar";
String
key
=
"5662e7c3d61fd5e0e67acd8bace6d1b0"
;
FileEncryptor
.
de
cryptFile
(
key
,
sourceFilePath
,
destFilePath
);
return
new
ResultObject
(
ResultStatus
.
SUCCESS
);
}
//
String key = "5662e7c3d61fd5e0e67acd8bace6d1b0";
// FileEncryptor.en
cryptFile(key,sourceFilePath,destFilePath);
//
return new ResultObject(ResultStatus.SUCCESS);
//
}
@RequestMapping
(
value
=
"/downloadFile"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
ResultObject
downloadFile
(
HttpServletResponse
response
,
String
fileName
)
throws
Exception
{
String
sourceFilePath
=
"/data/application/deviceCheck/updateJar/encryptorFile/update.jar"
;
public
void
downloadFile
(
HttpServletResponse
response
,
String
fileName
)
throws
Exception
{
//
String sourceFilePath = "/data/application/deviceCheck/updateJar/encryptorFile/update.jar";
// String sourceFilePath = "C:\\Users\\reyun\\Desktop\\update_2.jar";
// String sourceFilePath = "C:\\Users\\reyun\\Desktop\\update.jar";
String
sourceFilePath
=
"/data/application/deviceCheck/updateJar/update.jar"
;
if
(
StringUtils
.
isEmpty
(
fileName
)){
fileName
=
"default.jar"
;
}
FileEncryptor
.
downloadFileToPath
(
sourceFilePath
,
fileName
,
response
);
return
new
ResultObject
(
ResultStatus
.
SUCCESS
);
}
@RequestMapping
(
value
=
"/getIp"
,
method
=
RequestMethod
.
GET
)
...
...
src/main/java/com/demo/util/FileEncryptor.java
View file @
56dd266f
...
...
@@ -14,6 +14,9 @@ import javax.servlet.http.HttpServletResponse;
import
java.io.*
;
import
java.net.HttpURLConnection
;
import
java.net.URLEncoder
;
import
java.nio.ByteBuffer
;
import
java.nio.CharBuffer
;
import
java.nio.charset.Charset
;
import
java.security.Key
;
import
java.util.Random
;
...
...
@@ -51,19 +54,34 @@ public class FileEncryptor {
OutputStream
out
=
new
FileOutputStream
(
destFile
);
byte
[]
data
=
inputStreamToByte
(
in
);
byte
[]
aesData
=
SpecialSecret
.
aes256EncodeB
(
data
,
key
.
getBytes
());
ByteArrayInputStream
cin
=
StringToInputStream
(
aesData
);
//base64
// char[] aesData = DeformedBase64.encode(data);
// ByteArrayInputStream cin = StringToInputStream(getBytes(aesData));
ByteArrayInputStream
cin
=
StringToInputStream
(
data
);
// byte[] aesData = SpecialSecret.aes256EncodeB(data, key.getBytes());
// ByteArrayInputStream cin = StringToInputStream(aesData);
// byte[] raw = key.getBytes();
// SecretKeySpec secretKeySpec = new SecretKeySpec(raw, ALGORITHM);
// Cipher cipher = Cipher.getInstance(ALGORITHM);
// cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
// CipherInputStream cin = new CipherInputStream(in, cipher);
byte
[]
cache
=
new
byte
[
CACHE_SIZE
];
int
nRead
=
0
;
while
((
nRead
=
cin
.
read
(
cache
))
!=
-
1
)
{
out
.
write
(
cache
,
0
,
nRead
);
while
((
nRead
=
cin
.
read
())
!=
-
1
)
{
out
.
write
(
nRead
);
out
.
flush
();
}
// byte[] cache = new byte[CACHE_SIZE];
// int nRead = 0;
// while ((nRead = cin.read(cache)) != -1) {
// out.write(cache, 0, nRead);
// out.flush();
// }
out
.
close
();
cin
.
close
();
in
.
close
();
...
...
@@ -71,7 +89,7 @@ public class FileEncryptor {
}
public
static
byte
[]
inputStreamToByte
(
InputStream
input
)
throws
IOException
{
byte
[]
b
=
new
byte
[
4096
];
byte
[]
b
=
new
byte
[
input
.
available
()
];
for
(
int
n
;
(
n
=
input
.
read
(
b
))
!=
-
1
;)
{
}
return
b
;
...
...
@@ -83,6 +101,15 @@ public class FileEncryptor {
return
is
;
}
public
static
byte
[]
getBytes
(
char
[]
chars
)
{
Charset
cs
=
Charset
.
forName
(
"UTF-8"
);
CharBuffer
cb
=
CharBuffer
.
allocate
(
chars
.
length
);
cb
.
put
(
chars
);
cb
.
flip
();
ByteBuffer
bb
=
cs
.
encode
(
cb
);
return
bb
.
array
();
}
/**
* <p>
...
...
@@ -161,12 +188,13 @@ public class FileEncryptor {
if
(
sourceFile
.
exists
()
&&
sourceFile
.
isFile
())
{
FileInputStream
in
=
new
FileInputStream
(
sourceFile
);
byte
[]
data
=
inputStreamToByte
(
in
);
char
[]
aesData
=
DeformedBase64
.
encode
(
data
);
ByteArrayInputStream
cin
=
StringToInputStream
(
getBytes
(
aesData
));
out
=
resp
.
getOutputStream
();
byte
[]
cache
=
new
byte
[
CACHE_SIZE
];
int
nRead
=
0
;
while
((
nRead
=
in
.
read
(
cache
))
!=
-
1
)
{
out
.
write
(
cache
,
0
,
nRead
);
while
((
nRead
=
cin
.
read
(
))
!=
-
1
)
{
out
.
write
(
nRead
);
out
.
flush
();
}
}
...
...
src/main/resources/application-dev.properties
View file @
56dd266f
...
...
@@ -2,7 +2,7 @@ server.port=8081
spring.data.mongodb.host
=
192.168.168.81
spring.data.mongodb.port
=
8763
spring.data.mongodb.database
=
device
server.ssl.key-store
=
classpath:keystore.p12
server.ssl.key-store
=
classpath:keystore
_win
.p12
server.ssl.key-store-password
=
123456
server.ssl.key-store-type
=
PKCS12
server.ssl.key-alias
=
tomcat
\ No newline at end of file
src/main/resources/keystore
.p12_win
→
src/main/resources/keystore
_win.p12
View file @
56dd266f
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment