Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
license-generator
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-generator
Commits
2976ebf9
Commit
2976ebf9
authored
Jan 11, 2024
by
hy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9cea664d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
38 deletions
+41
-38
.gitignore
.gitignore
+3
-2
LicenseGenerator.java
src/main/java/com/tbyf/license/LicenseGenerator.java
+8
-11
LicenseParams.java
src/main/java/com/tbyf/license/LicenseParams.java
+1
-1
LicenseGeneratorTest.java
src/test/java/com/tbyf/license/LicenseGeneratorTest.java
+29
-0
LicenseManagerTest.java
src/test/java/com/tbyf/license/LicenseManagerTest.java
+0
-24
No files found.
.gitignore
View file @
2976ebf9
...
@@ -36,4 +36,5 @@ build/
...
@@ -36,4 +36,5 @@ build/
### Mac OS ###
### Mac OS ###
.DS_Store
.DS_Store
.idea/
.idea/
\ No newline at end of file
*.lic
\ No newline at end of file
src/main/java/com/tbyf/license/License
Manage
r.java
→
src/main/java/com/tbyf/license/License
Generato
r.java
View file @
2976ebf9
...
@@ -2,7 +2,6 @@ package com.tbyf.license;
...
@@ -2,7 +2,6 @@ package com.tbyf.license;
import
global.namespace.fun.io.bios.BIOS
;
import
global.namespace.fun.io.bios.BIOS
;
import
global.namespace.truelicense.api.License
;
import
global.namespace.truelicense.api.License
;
import
global.namespace.truelicense.api.LicenseInitialization
;
import
global.namespace.truelicense.api.LicenseManagementContext
;
import
global.namespace.truelicense.api.LicenseManagementContext
;
import
global.namespace.truelicense.api.LicenseManagementException
;
import
global.namespace.truelicense.api.LicenseManagementException
;
import
global.namespace.truelicense.api.VendorLicenseManager
;
import
global.namespace.truelicense.api.VendorLicenseManager
;
...
@@ -12,14 +11,12 @@ import global.namespace.truelicense.v4.V4;
...
@@ -12,14 +11,12 @@ import global.namespace.truelicense.v4.V4;
import
javax.security.auth.x500.X500Principal
;
import
javax.security.auth.x500.X500Principal
;
public
class
License
Manage
r
{
public
class
License
Generato
r
{
private
static
final
String
SUBJECT
=
"HIP"
;
private
static
final
String
SUBJECT
=
"HIP"
;
private
static
final
String
DISTINGUISHED_NAME
=
"CN=TBYF HIP"
;
private
static
final
String
DISTINGUISHED_NAME
=
"CN=TBYF HIP"
;
private
static
final
String
KEY_STORE_FILE
=
"private.ks"
;
private
static
final
String
KEY_STORE_FILE
=
"private.ks"
;
static
LicenseInitialization
licenseInitialization
;
private
static
final
LicenseManagementContext
_managementContext
=
V4
private
static
final
LicenseManagementContext
_managementContext
=
V4
.
builder
()
.
builder
()
.
initialization
(
license
->
{
.
initialization
(
license
->
{
...
@@ -41,13 +38,13 @@ public class LicenseManager {
...
@@ -41,13 +38,13 @@ public class LicenseManager {
return
_managementContext
return
_managementContext
.
vendor
()
.
vendor
()
.
encryption
()
.
encryption
()
.
protection
(
protection
(
new
long
[]{
0xa62021d62ef7e061
L
,
0xd32b4d88c40291af
L
}))
/* "P@ssw0rd" */
.
protection
(
protection
(
new
long
[]{
0xa62021d62ef7e061
L
,
0xd32b4d88c40291af
L
}))
/* "P@ssw0rd" */
.
up
()
.
up
()
.
authentication
()
.
authentication
()
.
alias
(
"standard"
)
.
alias
(
"standard"
)
.
loadFromResource
(
KEY_STORE_FILE
)
.
loadFromResource
(
KEY_STORE_FILE
)
.
storeProtection
(
protection
(
new
long
[]{
0x1bc1838eb8e7378c
L
,
0x88679932d1e8bedc
L
,
0x6e59d724487b1939
L
}))
/* "Esb@123$%^" */
.
storeProtection
(
protection
(
new
long
[]{
0x1bc1838eb8e7378c
L
,
0x88679932d1e8bedc
L
,
0x6e59d724487b1939
L
}))
/* "Esb@123$%^" */
.
up
()
.
up
()
.
build
();
.
build
();
}
}
...
@@ -62,7 +59,7 @@ public class LicenseManager {
...
@@ -62,7 +59,7 @@ public class LicenseManager {
license
.
setNotAfter
(
params
.
getExpirationDate
());
license
.
setNotAfter
(
params
.
getExpirationDate
());
license
.
setExtra
(
params
.
getMAC
());
license
.
setExtra
(
params
.
getMAC
());
manager
.
generateKeyFrom
(
license
)
manager
.
generateKeyFrom
(
license
)
.
saveTo
(
BIOS
.
file
(
params
.
get
Filename
()));
.
saveTo
(
BIOS
.
file
(
params
.
get
LicensePath
()));
}
}
}
}
src/main/java/com/tbyf/license/LicenseParams.java
View file @
2976ebf9
...
@@ -10,7 +10,7 @@ import java.util.Date;
...
@@ -10,7 +10,7 @@ import java.util.Date;
public
class
LicenseParams
{
public
class
LicenseParams
{
@Getter
@Getter
private
String
filename
;
private
String
licensePath
;
private
Date
startDate
;
private
Date
startDate
;
...
...
src/test/java/com/tbyf/license/LicenseGeneratorTest.java
0 → 100644
View file @
2976ebf9
package
com
.
tbyf
.
license
;
import
global.namespace.truelicense.api.LicenseManagementException
;
import
org.junit.jupiter.api.Test
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
class
LicenseGeneratorTest
{
@Test
void
generate
()
throws
LicenseManagementException
,
ParseException
{
LicenseGenerator
licenseGenerator
=
new
LicenseGenerator
();
licenseGenerator
.
generate
(
LicenseParams
.
builder
()
.
licensePath
(
"hip.lic"
)
.
validity
(
3
)
// .expirationDate(toDate("2024-01-11 15:12:00"))
.
MAC
(
"00-50-56-C0-00-08"
)
.
build
());
}
Date
toDate
(
String
dateStr
)
throws
ParseException
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
return
dateFormat
.
parse
(
dateStr
);
}
}
\ No newline at end of file
src/test/java/com/tbyf/license/LicenseManagerTest.java
deleted
100644 → 0
View file @
9cea664d
package
com
.
tbyf
.
license
;
import
global.namespace.truelicense.api.LicenseManagementException
;
import
org.junit.jupiter.api.Test
;
import
java.util.Date
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
class
LicenseManagerTest
{
@Test
void
generate
()
throws
LicenseManagementException
{
new
LicenseManager
()
.
generate
(
LicenseParams
.
builder
()
.
filename
(
"hip.lic"
)
.
startDate
(
new
Date
())
.
validity
(
5
)
.
MAC
(
"CC-F9-E4-97-CA-48"
)
.
build
());
}
}
\ No newline at end of file
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