Coder Social home page Coder Social logo

include76 / bsi-core Goto Github PK

View Code? Open in Web Editor NEW

This project forked from biosignin/bsi-core

0.0 0.0 0.0 90 KB

Biometric Signature Interface

Home Page: http://www.biosignin.org

License: GNU Affero General Public License v3.0

Java 99.90% FreeMarker 0.10%

bsi-core's Introduction

#Biometric Signature Interface Biometric Signature Interface (aka bsi-core) is a java library for manipulating Signature/sign time series data according to ISO/IEC 19794-7:2007

What you can do

  • You can import from ISO
  • You can build your own ISO from a list of ManagedIsoPoint captured (Capturing will be in the scope of next projects so... stay tuned)
  • You can build a generic structure where include your ISO and a list of custom extended data (like AdditionalHashInfo)
  • You can encrypt/decrypt those structures using CMS PKCS7 standards

Examples

Import/Export from ISO

import eu.inn.biometric.signature.device.CapturingComponent;
import eu.inn.biometric.signature.managed.ManagedIsoPoint;
import eu.inn.biometric.signature.managed.impl.IsoSignatureData;

void fromIso(byte[] isoBytes){	
	IsoSignatureData iso = IsoSignatureData.fromIso(isoBytes);
    CapturingComponent componentInfo = iso.getCapturingComponent();
    List<ManagedIsoPoint> points = getIsoPoints();
}

byte[] toIso(List<ManagedIsoPoint> points, CapturingComponent componentInfo){
	IsoSignatureData iso = IsoSignatureData.fromData(points, componentInfo);
    return iso.getIsoData(); //pure byte[] iso
}

Enrich with your own data

  1. Let's define your custom data
package eu.inn.examples;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import eu.inn.biometric.signature.extendeddata.AbstractExtendedData;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class GpsCoordinates extends AbstractExtendedData {	

	@XmlElement
    public double latitude;
    
	@XmlElement
    public double longitude;

    public GpsCoordinates() {
	}
    
    public GpsCoordinates(double latitude, double longitude) {
    	this.latitude = latitude;
        this.longitude = longitude;
    }
}
  1. Enrich your ISO
import eu.inn.biometric.signature.device.CapturingComponent;
import eu.inn.biometric.signature.managed.ManagedIsoPoint;
import eu.inn.biometric.signature.managed.impl.IsoSignatureData;
import eu.inn.examples.GpsCoordinates;

void enrich(IsoSignatureData iso){		
	GpsCoordinates coord = new GpsCoordinates(41.1212, 11.2323);
    coord.setKey("Coord1");
    iso.getExtendedDatas().add(coord); //add your pre-defined extended-data    
    System.out.println(iso.toOutput());
}
  1. Export your data (yes, this is the output of "toOutput" method)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<isoSignatureData>
    <extendedDatas>
        <gpsCoordinates componentClass="eu.inn.examples.GpsCoordinates" key="Coord1">
            <latitude>41.1212</latitude>
            <longitude>11.2323</longitude>
        </gpsCoordinates>
    </extendedDatas>
    <isoData>MIAGCSqGSIb3DQEHA6CAMIACAQAxg3MQswCQ........5w7LEtmv6OqFXiGbN9nf9vmAAAAAAAAAAAAAA=</isoData>
</isoSignatureData>

Encrypt/Decrypt

import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import eu.inn.biometric.signature.managed.impl.CMSEncryptedBdi;
import eu.inn.biometric.signature.managed.impl.IsoSignatureData;

void encrypt(IsoSignatureData iso, List<X509Certificate> publicKeys, int maxKeyLength){		
	CMSEncryptedBdi<IsoSignatureData> encrypted = CMSEncryptedBdi.encrypt(origIso, certs, 128);
    String base64Encrypted = encrypted.toOutput();
}

void decrypt(byte[] encryptedBytes, PrivateKey privateKey) {
	CMSEncryptedBdi<IsoSignatureData> enc = CMSEncryptedBdi.fromCMSbytes(encryptedBytes);
	enc.setPrivateKey(privateKey);			
	IsoSignatureData dec = enc.decrypt(IsoSignatureData.class);
}

Requirements

Include in your maven project
<project>
	[.......]
	<dependencies>
    	[.......]
		<dependency>
			<groupId>eu.inn.biometric.sign</groupId>
			<artifactId>bsi-core</artifactId>
			<version>0.0.2</version>
		</dependency>
		<dependency>   <!-- you can either use your own cryptographic implementation -->
			<groupId>eu.inn.biometric.sign</groupId>
			<artifactId>bc-crypto-bsi</artifactId>	
			<version>0.0.1</version>
			<scope>runtime</scope>
		</dependency>
	</dependencies>
	<distributionManagement>
		<repository>
			<id>InnoveryRelease</id>
			<name>Innovery Public Releases</name>
			<url>https://developers.innovery.net/artifactory/public-release</url>
		</repository>
	</distributionManagement>
</project>

bsi-core's People

Contributors

herr-seppia avatar epaterna avatar innovery avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.