Skip to content

Protegrity-Developer-Edition/protegrity-developer-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Protegrity AI Developer Edition Java

Version License: MIT Java 11+ Linux Windows macOS Maven Central 1.1.0 Ask DeepWiki

Welcome to the protegrity-developer-java repository, part of the Protegrity AI Developer Edition suite. This repository provides the Java SDK for integrating Protegrity's Data Discovery and Protection APIs into GenAI and traditional applications. Customize, compile, and use the modules as per your requirement.

💡Note: This SDK should be built and used only if you intend to modify the source code or default behavior.

Table of Contents

  1. Overview
  2. Repository Structure
  3. Features
  4. Getting Started
  5. Protegrity AI Developer Edition Module
  6. Application Protector Java Module
  7. Documentation
  8. Sample Use Case
  9. License

Overview

This repository contains two powerful modules designed to handle different aspects of data protection:

  • protegrity-developer-edition - Focuses on data discovery, classification, and redaction of Personally Identifiable Information (PII) in unstructured text
  • application-protector-java - Provides comprehensive data protection and unprotection capabilities for structured data

Why This Matters

Sensitive data shows up in more places than you'd expect — logs, payloads, prompts, training sets, and unstructured text. This Java SDK gives you tools to find and protect that data using tokenization, masking, and discovery — whether it's in an AI pipeline or a local application. No infrastructure, no UI, just code.

  • Developer-first experience: Open APIs, sample apps, and modular design make it easy to embed data discovery and protection into any Java project.

  • Accelerate innovation: Prototype and validate data discovery and protection strategies in a lightweight, containerized sandbox.

  • Enable responsible AI: Protect sensitive information in training data, prompts, and outputs for GenAI and machine learning workflows.

  • Simplify compliance: Meet regulatory requirements for data privacy with built-in detection and protection capabilities.

Repository Structure

├── LICENSE
├── README.md
├── pom.xml                                    # Parent POM
├── mvnw, mvnw.cmd                            # Maven wrapper
├── application-protector-java/               # Core SDK module
│   ├── pom.xml
│   ├── src/
│   │   ├── main/java/com/protegrity/ap/java/
│   │   └── test/
│   └── target/
│       └── ApplicationProtectorJava-1.0.1.jar
├── protegrity-developer-edition/            # Developer utilities module
│   ├── pom.xml
│   ├── src/
│   │   ├── main/java/com/protegrity/devedition/
│   │   └── test/
│   └── target/
│       └── ProtegrityDeveloperJava-1.0.1.jar
└── integration-tests/                        # Cucumber BDD tests
    ├── pom.xml
    ├── src/
    │   └── test/
    │       ├── java/com/protegrity/
    │       └── resources/features/
    └── README.md

Features

Protegrity AI Developer Edition Module

Feature Description
Find and Redact Classifies and redacts Personally Identifiable Information (PII) in unstructured text.
Find and Protect Classifies and protects Personally Identifiable Information (PII) in unstructured text using Protegrity protection policies.
Find and Unprotect Restores original Personally Identifiable Information (PII) data from its protected form.
Cross-Platform Support Compatible with Linux, Windows, and MacOS.

Application Protector Java Module

Feature Description
Data Protection Protects sensitive structured data using Protegrity policies.
Data Unprotection Restores original data from its protected form.
Session Management Manages secure sessions for protection and unprotection operations.
Cross-Platform Support Compatible with Linux, Windows, and MacOS.
Multiple Data Types Supports primitives, strings, bytes, dates, and more.

Getting Started

Prerequisites

Common Prerequisites

Protegrity AI Developer Edition Prerequisites

No additional prerequisites required beyond the common ones.

Application Protector Java Prerequisites

  • In addition to the common prerequisites, Application Protector Java requires API Key, Email, and Password

    Obtaining Credentials

    AI Developer Edition Portal Registration

Build the protegrity-developer-java modules

  1. Clone the repository.

    git clone https://github.com/Protegrity-Developer-Edition/protegrity-developer-java.git
  2. Navigate to the protegrity-developer-java directory

  3. Build and install the modules by running the following command from the root directory of the repository.

    ./mvnw clean install

    The build completes and the success message is displayed. This creates:

    • application-protector-java/target/ApplicationProtectorJava-1.0.1.jar (fat JAR with dependencies)
    • protegrity-developer-edition/target/ProtegrityDeveloperJava-1.0.1.jar (fat JAR with dependencies)
    • Maven artifacts in your local repository (.m2/repository)
  4. To run integration tests (optional):

    ./mvnw clean verify -DskipITs=false

Protegrity AI Developer Edition Module

💡Note: Ensure that the Protegrity AI Developer Edition is running before using this module. For setup instructions, please refer to the documentation here.

Usage Examples

Find and Redact

package com.protegrity.devedition.samples;

import com.protegrity.devedition.utils.Discover;
import com.protegrity.devedition.utils.PiiProcessing;
import com.protegrity.devedition.utils.Config;
import com.fasterxml.jackson.databind.JsonNode;
import java.util.List;
import java.util.HashMap;
import java.util.Map;

public class FindAndRedactExample {
    public static void main(String[] args) throws Exception {
        // Configure
        Map<String, String> entityMap = new HashMap<>();
        entityMap.put("PERSON", "NAME");
        entityMap.put("SOCIAL_SECURITY_ID", "SSN");
        Config.setNamedEntityMap(entityMap);
        Config.setMaskingChar("#");
        Config.setMethod("redact");
        
        // Discover and redact
        String inputText = "John Doe's SSN is 123-45-6789.";
        JsonNode discoveryResult = Discover.discover(inputText);
        List<PiiProcessing.EntitySpan> entities = PiiProcessing.collectEntitySpans(discoveryResult, inputText);
        String outputText = PiiProcessing.redactData(entities, inputText);
        
        System.out.println("Redacted: " + outputText);
    }
}

Set your credentials as environment variables for running Protection examples:

export DEV_EDITION_EMAIL='<email_used_for_registration>'
export DEV_EDITION_PASSWORD='<Password_provided_in_email>'
export DEV_EDITION_API_KEY='<API_key_provided_in_email>'

Find and Protect

package com.protegrity.devedition.samples;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.databind.JsonNode;
import com.protegrity.devedition.utils.Config;
import com.protegrity.devedition.utils.Discover;
import com.protegrity.devedition.utils.PiiProcessing;

public class FindAndProtectExample {
    public static void main(String[] args) throws Exception {
        
        // Configure
        Map<String, String> entityMap = new HashMap<>();
        entityMap.put("PERSON", "NAME");
        entityMap.put("SOCIAL_SECURITY_ID", "SSN");
        Config.setNamedEntityMap(entityMap);

        // Discover PII
        String inputText = "John Doe's SSN is 123-45-6789.";
        JsonNode discoveryResult = Discover.discover(inputText);
        List<PiiProcessing.EntitySpan> entities = PiiProcessing.collectEntitySpans(discoveryResult, inputText);
        
        // Protect data
        String outputText = PiiProcessing.protectData(entities, inputText);
        
        System.out.println("Protected: " + outputText);
    }
}

Find and Unprotect

package com.protegrity.devedition.samples;

import com.protegrity.devedition.utils.PiiProcessing;

public class FindAndUnprotectExample {
    public static void main(String[] args) throws Exception {
        
        // Protected text from FindAndProtectExample
        String protectedText = "[PERSON]7ro8 lfU'I[/PERSON] SSN is [SOCIAL_SECURITY_ID]616-16-2210[/SOCIAL_SECURITY_ID].";
        
        // Unprotect
        String outputText = PiiProcessing.unprotectData(protectedText);
        
        System.out.println("Unprotected: " + outputText);
    }
}

Application Protector Java Module

Usage Examples

Set your credentials as environment variables:

export DEV_EDITION_EMAIL='<email_used_for_registration>'
export DEV_EDITION_PASSWORD='<Password_provided_in_email>'
export DEV_EDITION_API_KEY='<API_key_provided_in_email>'

Protect & Unprotect Data

package com.protegrity.devedition.samples;

import com.protegrity.ap.java.*;
import java.util.Arrays;

public class BulkProtectExample {
    public static void main(String[] args) {
        try {
            Protector protector = Protector.getProtector();
            String userName = "superuser";
            String dataElement = "ccn";
            String[] data = {"5555555555554444", "378282246310005", "4111111111111111"};
            
            SessionObject session = protector.createSession(userName);
            System.out.println("Original Data: " + Arrays.toString(data));

            // Protect bulk
            String[] protectedData = new String[data.length];
            protector.protect(session, dataElement, data, protectedData);
            System.out.println("Protected Data: " + Arrays.toString(protectedData));
            
            // Unprotect bulk
            String[] unprotectedData = new String[data.length];
            protector.unprotect(session, dataElement, protectedData, unprotectedData);
            System.out.println("Unprotected Data: " + Arrays.toString(unprotectedData));
            
        } catch (ProtectorException e) {
            e.printStackTrace();
        }
    }
}

💡Note: You do not need Protegrity AI Developer Edition running before executing just the Application Protector Java Module.

Documentation

Sample Use Case

Use this SDK to build GenAI applications like chatbots that:

  • Detect Personally Identifiable Information (PII) in prompts using the classifier
  • Protect, Redact, or Mask sensitive data before processing
  • Protect and Unprotect structured sensitive data

License

See LICENSE for terms and conditions.

About

Protegrity Developer Java

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •