diff --git a/README.md b/README.md index c6b85b0..3897491 100644 --- a/README.md +++ b/README.md @@ -13,23 +13,23 @@ Use this project if you need connect to ADempiere using [ADempiere Middleware](h you should change the follows packages for your own implementation, just change the word `template` by your implementation ```Java -org.spin.template.model.validator -org.spin.template.setup -org.spin.template.util +org.spin.eca52.model.validator +org.spin.eca52.setup +org.spin.eca52.util ``` -### Model Validators -Change the `org.spin.template.model.validator.Validator` by your implementation, example: `org.spin.template.model.validator.MyOwnFunctionality` +### Security Token Generator +The main class for generate and validate token is here: `org.spin.eca52.security.JWT` -### Model Deploy class -Change the `org.spin.template.setup.Deploy` by your implementation, example: `org.spin.template.setup.MyOwnSetupForDeploy` +### Deploy Class +For deploy project just run the setup `org.spin.eca52.setup.CreateTokenDefinition`, this create a new token definition by client. -### Model Util class for core changes -Change the `org.spin.template.util.Changes` by your implementation, example: `org.spin.template.util.MyOwnChanges` +### Static util class for any constant +The util class for constat and other value is `org.spin.eca52.util.JWTUtil` ## Binary Project -You can get all binaries from github [here](https://central.sonatype.com/artifact/io.github.adempiere/adempiere-template-project/1.0.0). +You can get all binaries from github [here](https://central.sonatype.com/artifact/io.github.adempiere/adempiere-jwt-token/1.0.0). All contruction is from github actions @@ -46,13 +46,13 @@ Is very easy. - Gradle ```Java -implementation 'io.github.adempiere:adempiere-template-project:1.0.0' +implementation 'io.github.adempiere:adempiere-jwt-token:1.0.0' ``` - SBT ``` -libraryDependencies += "io.github.adempiere" % "adempiere-template-project" % "1.0.0" +libraryDependencies += "io.github.adempiere" % "adempiere-jwt-token" % "1.0.0" ``` - Apache Maven @@ -60,7 +60,27 @@ libraryDependencies += "io.github.adempiere" % "adempiere-template-project" % "1 ``` io.github.adempiere - adempiere-template-project + adempiere-jwt-token 1.0.0 ``` + +## Step by step + +### Create Token Definition + +Just Run the **Functionality Setup Process** and it add a new Token Definition, also is added a secret key (fill it). + +![Create Token Definition](docs/Create_Token_Definition.gif) + +### Set Secret Key + +Go to System configurator window and find `ECA52_JWT_SECRET_KEY`, after it just set the secret key. + +![Create Token Definition](docs/Add_Secret_Key.gif) + +### Generate Token + +Now you can generate a new token for third party access from process **System Admin** -> **General Rules** -> **Security** -> **Generate Token for Third Party Access**. + +![Create Token Definition](docs/Generate_Token.gif) \ No newline at end of file diff --git a/docs/Add_Secret_Key.gif b/docs/Add_Secret_Key.gif new file mode 100644 index 0000000..4d5feca Binary files /dev/null and b/docs/Add_Secret_Key.gif differ diff --git a/docs/Create_Token_Definition.gif b/docs/Create_Token_Definition.gif new file mode 100644 index 0000000..d8cd667 Binary files /dev/null and b/docs/Create_Token_Definition.gif differ diff --git a/docs/Generate_Token.gif b/docs/Generate_Token.gif new file mode 100644 index 0000000..b6db2f2 Binary files /dev/null and b/docs/Generate_Token.gif differ diff --git a/src/main/java/org/spin/eca52/security/JWT.java b/src/main/java/org/spin/eca52/security/JWT.java index 746942c..dfd5cf3 100644 --- a/src/main/java/org/spin/eca52/security/JWT.java +++ b/src/main/java/org/spin/eca52/security/JWT.java @@ -122,11 +122,9 @@ public String generateToken(int userId, int roleId) { userTokenValue = builder.compact(); String tokenValue = null; try { - String value = userTokenValue; // byte[] saltValue = new byte[8]; // Digest computation - userTokenValue = SecureEngine.encrypt(value); tokenValue = SecureEngine.getSHA512Hash(1000, userTokenValue, saltValue); } catch (NoSuchAlgorithmException e) { new AdempiereException(e); diff --git a/src/main/java/org/spin/eca52/setup/CreateTokenDefinition.java b/src/main/java/org/spin/eca52/setup/CreateTokenDefinition.java index 1fe7ed8..3c1f0ff 100644 --- a/src/main/java/org/spin/eca52/setup/CreateTokenDefinition.java +++ b/src/main/java/org/spin/eca52/setup/CreateTokenDefinition.java @@ -62,6 +62,7 @@ private MADTokenDefinition createTokenDefinition(Properties context, String tran // tokenDefinition = new MADTokenDefinition(context, 0, transactionName); tokenDefinition.setAD_Org_ID(0); + tokenDefinition.setTokenType(MADTokenDefinition.TOKENTYPE_ThirdPartyAccess); tokenDefinition.setValue(VALUE); tokenDefinition.setName(NAME); tokenDefinition.setDescription(DESCRIPTION);