🟪
SunLicense Docs
  • Welcome
  • Getting Started
    • Quickstart
    • VPS Setup
  • API Documentation
    • License API
    • Java API
  • Automations
    • BuiltByBit Automation
    • Discord Automation
  • PRODUCT INTEGRATIONS
    • Minecraft Plugins
    • Server Software
    • Minecraft Mods
    • Discord Bots
    • FiveM Projects
    • PHP Projects
    • Python Projects
    • JavaScript Projects
    • Lua Projects
  • SERVICES
    • Managed Hosting
  • LINKS
    • Discord
    • Store
    • Java API Wrapper
    • Sample Project
    • Pterodactyl Egg
    • Other Products
Powered by GitBook
On this page
  • Prerequisites
  • Project Setup
  • Basic Integration
  • Advanced Configuration
  • Troubleshooting
  1. API Documentation

Java API

SunLicenseAPI Integration Guide

Prerequisites

  • Java 8 or higher

  • SunLicense Server API URL

  • Product ID

Project Setup

1. Configure Maven Repository

Add the Sundevs repository to your pom.xml:

<repositories>
    <repository>
        <id>sundevs</id>
        <name>Sundevs Repository</name>
        <url>https://repo.hapangama.com/releases</url>
    </repository>
</repositories>

2. Add Dependency

Include the SunLicenseAPI dependency in your pom.xml:

<dependencies>
    <dependency>
        <groupId>com.hapangama</groupId>
        <artifactId>SunLicenseAPI</artifactId>
        <version>1.0.3</version>
    </dependency>
</dependencies>

Basic Integration

1. Initialize the API

Create an instance of SunLicenseAPI with your license details:

SunLicenseAPI api = SunLicenseAPI.getLicense(
    "YOUR-LICENSE-KEY",    // License key
    YOUR_PRODUCT_ID,       // Product ID (integer)
    "YOUR_VERSION",        // Product version
    "YOUR_API_URL"         // API endpoint
);

License Key cannot be hardcoded its different from license to license and you have to write a logic to take license key from a config file and pass as a parameter.

2. Implement License Validation

Add basic license validation to your application:

try {
    api.validate();
    System.out.println("License is valid");
} catch (IOException e) {
    System.out.println("License validation failed: " + e.getMessage());
    System.exit(1);
}

Advanced Configuration

Custom IP Address Configuration

You can manually set the IP address for validation:

// Option 1: Get public IP automatically
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.ipify.org"))
    .GET()
    .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
String publicIP = response.body();
api.setIp(publicIP);

// Option 2: Set IP manually
api.setIp("YOUR.IP.ADDRESS");

Loading License from File

For production environments, load the license key from a file:

SunLicenseAPI api = SunLicenseAPI.getLicenseFromFile(
    "path/to/license.txt",
    YOUR_PRODUCT_ID,
    "YOUR_VERSION",
    "YOUR_API_URL"
);

Custom HWID You can write your own implementation for HWID and pass it with the request.

api.setHwid("YOUR-CUSTOM-HWID");

Troubleshooting

Common issues and solutions:

  1. Connection Issues

    • Verify API endpoint URL

    • Check network connectivity

    • Confirm firewall settings

  2. Validation Failures

    • Verify license key format

    • Check product ID is correct

    • Confirm IP address restrictions

  3. Configuration Problems

    • Ensure Java version compatibility

    • Check dependency versions

Remember to replace placeholder values (YOUR-LICENSE-KEY, YOUR_PRODUCT_ID, YOUR_API_URL) with your actual values from your SunLicense account.

PreviousLicense APINextBuiltByBit Automation

Last updated 4 months ago