-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* version bump to 1.1.1 in develop branch * dependencies update (jackson, lombok) * lombok 1.18.20 * Identity handling library and example added * README update * Version 1.2.0 Co-authored-by: Oleksiy Lukin <oleskiylukin@fritbridge.io>
- Loading branch information
Showing
36 changed files
with
2,740 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>ua.cn.al</groupId> | ||
<artifactId>easycrypt-top</artifactId> | ||
<version>1.2.0</version> | ||
</parent> | ||
|
||
<groupId>ua.cn.al</groupId> | ||
<artifactId>easycrypt-identity-examples</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>ua.cn.al</groupId> | ||
<artifactId>easycrypt-identity</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<type>jar</type> | ||
</dependency> | ||
</dependencies> | ||
</project> |
57 changes: 57 additions & 0 deletions
57
...pt-identity-examples/src/main/java/ua/cn/al/easycrypt/identity/examples/CheckActorId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (C) 2021 Oleksiy Lukin | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation, version 2 | ||
* of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
package ua.cn.al.easycrypt.identity.examples; | ||
|
||
import ua.cn.al.easycrypt.identity.cert.CertException; | ||
import ua.cn.al.easycrypt.identity.cert.CertKeyPersistence; | ||
import ua.cn.al.easycrypt.identity.cert.ExtCert; | ||
import ua.cn.al.easycrypt.identity.utils.Hex; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
/** | ||
* | ||
* @author alukin@gmail.com | ||
*/ | ||
@Slf4j | ||
public class CheckActorId { | ||
|
||
/** | ||
* @param args the command line arguments | ||
*/ | ||
public static void main(String[] args) { | ||
System.out.println("Checking actor ID in certificate"); | ||
|
||
String path = "test_cert.pem"; | ||
if(args.length>1){ | ||
path=args[1]; | ||
} | ||
ExtCert xcert = null; | ||
System.out.println("Reading test certificate: "+path); | ||
try (InputStream is = new FileInputStream(path)) { | ||
xcert = CertKeyPersistence.loadCertPEMFromStream(is); | ||
} catch (IOException ex) { | ||
log.error("Can not load test certificate: "+path, ex); | ||
System.exit(1); | ||
} catch (CertException ex) { | ||
log.error("can not parse test certificate: " + path, ex); | ||
System.exit(1); | ||
} | ||
System.out.println(xcert.toString()); | ||
System.out.println("Actor ID:" + Hex.encode(xcert.getActorId())); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<name>esycrypt-identity</name> | ||
<groupId>ua.cn.al</groupId> | ||
<artifactId>easycrypt-identity</artifactId> | ||
<version>1.2.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<parent> | ||
<groupId>ua.cn.al</groupId> | ||
<artifactId>easycrypt-top</artifactId> | ||
<version>1.2.0</version> | ||
</parent> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>ua.cn.al</groupId> | ||
<artifactId>easycrypt</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- <dependency> | ||
<groupId>javax.enterprise</groupId> | ||
<artifactId>cdi-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.annotation</groupId> | ||
<artifactId>javax.annotation-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency>--> | ||
|
||
<!-- unit tests --> | ||
<dependency> | ||
<groupId>org.junit.platform</groupId> | ||
<artifactId>junit-platform-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.platform</groupId> | ||
<artifactId>junit-platform-commons</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>3.2.0</version> | ||
<configuration> | ||
<reportOutputDirectory>../../docs/java-api</reportOutputDirectory> | ||
<destDir>fbcrypto</destDir> | ||
<doclint>none</doclint> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.2.0</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.2</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<showDeprecation>true</showDeprecation> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
106 changes: 106 additions & 0 deletions
106
easycrypt-identity/src/main/java/ua/cn/al/easycrypt/identity/cert/ActorType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright (C) 2021 Oleksiy Lukin | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation, version 2 | ||
* of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
package ua.cn.al.easycrypt.identity.cert; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.nio.ByteOrder; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* @author alukin@gmail.com | ||
*/ | ||
public class ActorType { | ||
//actor types | ||
public static final int NODE = 1; | ||
public static final int SERVICE = 2; | ||
public static final int PERSON = 3; | ||
//actor sub-types for NODE | ||
public static final int NODE_REGULAR = 0; | ||
public static final int NODE_ARCHIVE = 1; | ||
public static final int NODE_CERTIFIED_STORAGE = 2; | ||
public static final int NODE_REGULAR_STORAGE = 3; | ||
//actor sub-types for services | ||
public static final int SERVICE_NONE = 0; | ||
public static final int SERVICE_EXCHANE = 1; | ||
public static final int SERVICE_WEBSITE = 2; | ||
public static final int SERVICE_CDN = 3; | ||
//actor sub-types for PERSON | ||
public static final int PERSON_UNKNOWN = 0; | ||
public static final int PERSON_DEVELOPER = 16; | ||
public static final int PERSON_RELESE_ENG = 17; | ||
public static final int PERSON_QUALITY_ASSURANCE = 18; | ||
public static final int PERSON_DEV_MANAGEMENT = 19; | ||
public static final int PERSON_DEVOPS = 20; | ||
public static final int PERSON_MARKETING = 21; | ||
|
||
public static final int PERSON_PRIVILEGED_USER = 128; | ||
|
||
private int[] at = {0, 0}; | ||
|
||
public ActorType(int atype) { | ||
ByteBuffer bb = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN).putInt(atype); | ||
at[0] = bb.get(2); | ||
at[1] = bb.get(3); | ||
} | ||
|
||
public ActorType() { | ||
} | ||
|
||
public Integer getValue() { | ||
return at[0] << 8 | at[1]; | ||
} | ||
|
||
public Integer getType() { | ||
return at[0]; | ||
} | ||
|
||
public void setType(int t) { | ||
at[0] = t & 0xFF; | ||
} | ||
|
||
public Integer getSubType() { | ||
return at[1]; | ||
} | ||
|
||
public void setSubType(int t) { | ||
at[1] = t & 0xFF; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
|
||
if (!ActorType.class.isAssignableFrom(obj.getClass())) { | ||
return false; | ||
} | ||
|
||
final ActorType other = (ActorType) obj; | ||
if ((this.at == null) ? (other.at != null) : !Arrays.equals(this.at, other.at)) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
//generated by IDE | ||
public int hashCode() { | ||
int hash = 3; | ||
hash = 43 * hash + Arrays.hashCode(this.at); | ||
return hash; | ||
} | ||
|
||
} |
Oops, something went wrong.