New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

com.github.reducktion:socrates-java

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.github.reducktion:socrates-java

Socrates allows you to validate and retrieve personal data from National Identification Numbers across the world.

  • 1.4.0
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

Socrates logo

Usage example

Build License Maven Central


Introduction

This package is a port of the php package socrates.

socrates-java allows you to validate and retrieve personal data from National Identification Numbers across the world, with the goal of eventually supporting as many countries in the world as possible.

Some countries also encode personal information of the citizen, such as gender or the place of birth. This package allows you to extract that information in a consistent way.

It can be useful for many things, such as validating a user's ID for finance related applications or verifying a user's age without asking for it explicitly. However, we recommend you review your country's data protection laws before storing any information.

Usage

Socrates provides two methods:

  • validateId, which returns a boolean indicating if an id is valid in a specific country
  • extractCitizenFromId, which returns an Optional Citizen with information retrievable from the identifier (gender, date of birth, ...)

You can find a list of supported countries here.

validateId

final Socrates socrates = new Socrates();
socrates.validateId("15420355 6 ZX9", Country.PT); // true

extractCitizenFromId

final Socrates socrates = new Socrates();
final Optional<Citizen> citizen = socrates.extractCitizenFromId("2820819398814 09", Country.FR);
citizen.ifPresent(c -> {
  c.getGender().ifPresent(System.out::println);       // "FEMALE"
  c.getYearOfBirth().ifPresent(System.out::println);  // "1982"
  c.getMonthOfBirth().ifPresent(System.out::println); // "8"
  c.getDayOfBirth().ifPresent(System.out::println);
  c.getPlaceOfBirth().ifPresent(System.out::println); // "Corrèze"
});
Gender

Gender is an enum that represents the gender of the Citizen extracted from the ID. It can have the values FEMALE or MALE. However, you can get the short hand "F" and "M" for FEMALE and MALE respectively, by using the method getShortHand() present in the class.

Contributing

Did you find a problem in any of the algorithms? Do you know how to implement a country which we have missed? Are there any improvements that you think should be made to the codebase? Any help is appreciated! Take a look at our contributing guidelines.

License

The MIT License (MIT). Please see License File for more information.

FAQs

Package last updated on 18 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc