Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
license-spring-boot-starter
Overview
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
黄营
license-spring-boot-starter
Commits
cfa63cd5
Commit
cfa63cd5
authored
Jan 12, 2024
by
hy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加LicenseProperties
parent
60560651
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
21 deletions
+44
-21
Constants.java
src/main/java/com/tbyf/license/Constants.java
+6
-0
LicenseInstallationServlet.java
...ain/java/com/tbyf/license/LicenseInstallationServlet.java
+1
-2
LicenseManager.java
src/main/java/com/tbyf/license/LicenseManager.java
+26
-7
LicenseValidationFilter.java
src/main/java/com/tbyf/license/LicenseValidationFilter.java
+10
-9
NetUtil.java
src/main/java/com/tbyf/license/NetUtil.java
+1
-3
No files found.
src/main/java/com/tbyf/license/Constants.java
0 → 100644
View file @
cfa63cd5
package
com
.
tbyf
.
license
;
public
class
Constants
{
public
static
final
String
LICENSE_FILE_NAME
=
"hip.lic"
;
}
src/main/java/com/tbyf/license/LicenseInstallationServlet.java
View file @
cfa63cd5
...
...
@@ -30,9 +30,8 @@ public class LicenseInstallationServlet extends HttpServlet {
@Override
protected
void
doPost
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
Part
filePart
=
req
.
getPart
(
"license"
);
String
fileName
=
filePart
.
getSubmittedFileName
();
try
(
InputStream
is
=
filePart
.
getInputStream
())
{
Path
dest
=
Paths
.
get
(
properties
.
getLocation
(),
fileName
).
toAbsolutePath
().
normalize
();
Path
dest
=
Paths
.
get
(
properties
.
getLocation
(),
Constants
.
LICENSE_FILE_NAME
).
toAbsolutePath
().
normalize
();
Files
.
copy
(
is
,
dest
,
StandardCopyOption
.
REPLACE_EXISTING
);
this
.
licenseManager
.
install
(
dest
.
toString
());
resp
.
setStatus
(
HttpStatus
.
OK
.
value
());
...
...
src/main/java/com/tbyf/license/LicenseManager.java
View file @
cfa63cd5
...
...
@@ -9,9 +9,15 @@ import global.namespace.truelicense.api.LicenseValidationException;
import
global.namespace.truelicense.core.passwd.ObfuscatedPasswordProtection
;
import
global.namespace.truelicense.obfuscate.ObfuscatedString
;
import
global.namespace.truelicense.v4.V4
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
public
class
LicenseManager
{
public
class
LicenseManager
implements
InitializingBean
{
private
static
final
String
SUBJECT
=
"HIP"
;
private
static
final
String
KEY_STORE_FILE
=
"public.ks"
;
...
...
@@ -24,6 +30,9 @@ public class LicenseManager {
volatile
ConsumerLicenseManager
_manager
;
@Autowired
LicenseProperties
licenseProperties
;
private
static
void
verifyMAC
(
Object
MAC
)
throws
LicenseValidationException
{
if
(
MAC
==
null
||
!
NetUtil
.
containsMAC
(
MAC
.
toString
()))
{
throw
new
LicenseValidationException
(
Messages
.
message
(
"Invalid License"
));
...
...
@@ -39,13 +48,13 @@ public class LicenseManager {
return
_managementContext
.
consumer
()
.
encryption
()
.
protection
(
protection
(
new
long
[]{
0x9d823a2b21bef869
L
,
0x4f4790eaa895d3d8
L
}))
.
up
()
.
protection
(
protection
(
new
long
[]{
0x9d823a2b21bef869
L
,
0x4f4790eaa895d3d8
L
}))
.
up
()
.
authentication
()
.
alias
(
"standard"
)
.
loadFromResource
(
KEY_STORE_FILE
)
.
storeProtection
(
protection
(
new
long
[]{
0x10111721aeba73dc
L
,
0x1aba2dc58b17fdbe
L
,
0x126b920ac6703949
L
}))
.
up
()
.
alias
(
"standard"
)
.
loadFromResource
(
KEY_STORE_FILE
)
.
storeProtection
(
protection
(
new
long
[]{
0x10111721aeba73dc
L
,
0x1aba2dc58b17fdbe
L
,
0x126b920ac6703949
L
}))
.
up
()
.
storeInUserPreferences
(
getClass
())
.
build
();
}
...
...
@@ -73,4 +82,14 @@ public class LicenseManager {
period
.
setExpirationTime
(
license
.
getNotAfter
());
return
period
;
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
Path
dir
=
Paths
.
get
(
this
.
licenseProperties
.
getLocation
()).
toAbsolutePath
().
normalize
();
Files
.
createDirectories
(
dir
);
Path
licensePath
=
dir
.
resolve
(
Constants
.
LICENSE_FILE_NAME
);
if
(
Files
.
isRegularFile
(
licensePath
)
&&
Files
.
exists
(
licensePath
))
{
install
(
licensePath
.
toString
());
}
}
}
src/main/java/com/tbyf/license/LicenseValidationFilter.java
View file @
cfa63cd5
package
com
.
tbyf
.
license
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
global.namespace.fun.io.api.NoContentException
;
import
global.namespace.truelicense.api.LicenseManagementException
;
import
global.namespace.truelicense.api.LicenseValidationException
;
...
...
@@ -15,6 +17,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
public
class
LicenseValidationFilter
extends
OncePerRequestFilter
{
...
...
@@ -40,16 +43,17 @@ public class LicenseValidationFilter extends OncePerRequestFilter {
// Invalid License
private
final
static
String
INVALID_LICENSE
=
new
ObfuscatedString
(
new
long
[]{
0x49e5266592028869
L
,
0x9315b379de60a1be
L
,
0xe1fde0262ab5ed27
L
,
0xde54ce8a8e5d4e19
L
,
0x42880fae5dbb8a13
L
,
0x7dc34d7fb839ec0d
L
,
0x99a3515ef60c84a5
L
,
0xc708fcab8319dfb3
L
}).
toString
();
0xf028f58c58a58b70
L
,
0x8e3687628cabf715
L
,
0x1d7b18d3be15ee3c
L
,
0x6484235954092864
L
,
0x1d0c5795e106b625
L
,
0x85bd4fc5f74c1953
L
,
0xbd8ecfc20bd71d2
L
,
0x43a6f39da2c77092
L
,
0xdb66a1baf052acd
L
,
0x5289ce404edb39b2
L
}).
toString
();
// No License
private
final
static
String
NO_LICENSE
=
new
ObfuscatedString
(
new
long
[]{
0x
8cb7df8f04d69f43
L
,
0xd616159bdf90a5e
L
,
0x508a735a1546f8bc
L
,
0x
7925f6557e460d53
L
,
0x4667e92ce4bcef22
L
,
0x359b5eefb590ca78
L
,
0x
239eba55236200f0
L
}).
toString
();
0x
c8eb6c067584a44f
L
,
0x3b927f424d2f8b3d
L
,
0x63b037cacbc18631
L
,
0x
ea641540f5303384
L
,
0xf74c5ed8383e8a2a
L
,
0x58e83b8ba2f4d29d
L
,
0x
a87739551ba09b21
L
,
0x388b360692cb587
L
,
0x9a270e40ae793a05
L
}).
toString
();
public
void
setLicenseManager
(
LicenseManager
licenseManager
)
{
this
.
licenseManager
=
licenseManager
;
...
...
@@ -94,7 +98,4 @@ public class LicenseValidationFilter extends OncePerRequestFilter {
return
false
;
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
ObfuscatedString
.
obfuscate
(
"/license/uninstall"
));
}
}
src/main/java/com/tbyf/license/NetUtil.java
View file @
cfa63cd5
...
...
@@ -2,11 +2,9 @@ package com.tbyf.license;
import
java.net.NetworkInterface
;
import
java.net.SocketException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
public
class
NetUtil
{
...
...
@@ -41,7 +39,7 @@ public class NetUtil {
allMACs
.
add
(
String
.
join
(
"-"
,
MAC
));
}
}
System
.
out
.
println
(
allMACs
);
System
.
out
.
println
(
"本地MAC地址为: "
+
allMACs
);
return
allMACs
;
}
catch
(
SocketException
e
)
{
...
...
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