Skip to content

Commit

Permalink
Develop (#8)
Browse files Browse the repository at this point in the history
* 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
alukin and Oleksiy Lukin authored May 24, 2021
1 parent 3ccf441 commit ba8de29
Show file tree
Hide file tree
Showing 36 changed files with 2,740 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ hs_err_pid*
/easycrypt/testdata/out

/graalvm-example/target/
/easycrypt-identity/target/
/easycrypt-identity-examples/target/
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ ___The Goals of EasyCrypt design are:___
* [EasyCrypt library](easycrypt) Java library, builds into a JAR file
* [EasyCrypt util](easycrypt-util) OpenSSL-like utility
* [EasyCrypt examples](easycrypt-examples) Examples of code
* [EasyCrypt identity](easycrypt-dentity) X.509 based identity library
* [EasyCrypt identity examples](easycrypt-dentity-examples) X.509 based identity library examples

For component description and other documentation, please see REAME.md files in the directory of the component.

## History

Expand All @@ -35,12 +39,12 @@ libraries.

## Copyright

EasyCrypt is free software and licensed under GPL v.2. Dual licensing is possible.
EasyCrypt is free software and licensed under GPL v.2. Dual licensing is possible, please conntact authors.

## Releases

The current release is 1.1.0. It features streaming crypto and digesting interfaces, as well as native builds with
GraalVM.
Current release is 1.2.0. It features streaming crypto and digesting interfaces, native builds with GraalVM,
and identity library with examples

### How do I get set up? ###

Expand Down
2 changes: 1 addition & 1 deletion easycrypt-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ua.cn.al</groupId>
<artifactId>easycrypt-top</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</parent>
<artifactId>easycrypt-examples</artifactId>
<packaging>jar</packaging>
Expand Down
27 changes: 27 additions & 0 deletions easycrypt-identity-examples/pom.xml
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>
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()));

}
}
99 changes: 99 additions & 0 deletions easycrypt-identity/pom.xml
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>
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;
}

}
Loading

0 comments on commit ba8de29

Please sign in to comment.