Skip to content

Commit

Permalink
Add more docs and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
artemlos committed Feb 1, 2019
1 parent 4b34267 commit 7d63227
Show file tree
Hide file tree
Showing 20 changed files with 269 additions and 285 deletions.
1 change: 1 addition & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

331 changes: 198 additions & 133 deletions .idea/workspace.xml

Large diffs are not rendered by default.

26 changes: 0 additions & 26 deletions src/main/java/io/cryptolens/ResponseParser.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.cryptolens.models;
package io.cryptolens.internal;

public class ActivateResult extends BasicResult {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.cryptolens.models;
package io.cryptolens.internal;

public class BasicResult {
public int result;
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/io/cryptolens/internal/HelperMethods.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package io.cryptolens.internal;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import io.cryptolens.*;
import io.cryptolens.models.ActivateResult;
import io.cryptolens.models.BasicResult;
import io.cryptolens.legacy.HttpsURLConnectionRequestHandler;
import io.cryptolens.legacy.RequestHandler;

import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.cryptolens;
package io.cryptolens.legacy;

import java.io.*;
import java.nio.*;
Expand All @@ -19,7 +19,7 @@
import java.security.spec.RSAPublicKeySpec;
import java.util.Base64;
import java.util.*;

@Deprecated
public class Base64Response {
public byte[] licenseKey;
public byte[] signature;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
package io.cryptolens;
package io.cryptolens.legacy;

import java.io.*;
import java.nio.*;
import java.nio.charset.*;
import java.net.*;
import java.util.*;

import javax.net.ssl.*;

import com.google.gson.*;

import java.math.BigInteger;
import java.security.*;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.spec.RSAPublicKeySpec;
import java.util.Base64;
import java.util.*;

/**
* The main class that contains methods to verify license keys.
*/
@Deprecated
public class Cryptolens {
private JavaSecuritySignatureVerifier signatureVerifier;
private RequestHandler requestHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
package io.cryptolens;
package io.cryptolens.legacy;

import java.io.*;
import java.nio.*;
import java.nio.charset.*;
import java.net.*;
import java.util.*;

import javax.net.ssl.*;

import com.google.gson.*;

import java.math.BigInteger;
import java.security.*;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.spec.RSAPublicKeySpec;
import java.util.Base64;
import java.util.*;

@Deprecated
public class GsonResponseParser implements ResponseParser {
private static class GsonBase64Response {
public String licenseKey;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
package io.cryptolens;
package io.cryptolens.legacy;

import java.io.*;
import java.nio.*;
import java.nio.charset.*;
import java.net.*;
import java.util.*;

import javax.net.ssl.*;

import com.google.gson.*;

import java.math.BigInteger;
import java.security.*;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.spec.RSAPublicKeySpec;
import java.util.Base64;
import java.util.*;

@Deprecated
public class HttpsURLConnectionRequestHandler implements RequestHandler {
public String makePostRequest(String url, Map<String,String> params) throws Exception {
URL url_ = new URL(url);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.cryptolens;
package io.cryptolens.legacy;

import java.io.*;
import java.nio.*;
Expand All @@ -19,7 +19,7 @@
import java.security.spec.RSAPublicKeySpec;
import java.util.Base64;
import java.util.*;

@Deprecated
public class JavaSecuritySignatureVerifier {
private BigInteger mod;
private BigInteger exp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
package io.cryptolens;

import java.io.*;
import java.nio.*;
import java.nio.charset.*;
import java.net.*;
import java.util.*;

import javax.net.ssl.*;

import com.google.gson.*;

import java.math.BigInteger;
import java.security.*;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.spec.RSAPublicKeySpec;
import java.util.Base64;
import java.util.*;

package io.cryptolens.legacy;
@Deprecated
public class LicenseKey {
public static class Builder {
private final LicenseKey licenseKey;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.cryptolens;
package io.cryptolens.legacy;

import java.io.*;
import java.nio.*;
Expand All @@ -19,7 +19,7 @@
import java.security.spec.RSAPublicKeySpec;
import java.util.Base64;
import java.util.*;

@Deprecated
public interface MachineCodeComputer {
public String computeMachineCode();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.cryptolens;
package io.cryptolens.legacy;

import java.io.*;
import java.nio.*;
Expand All @@ -19,7 +19,7 @@
import java.security.spec.RSAPublicKeySpec;
import java.util.Base64;
import java.util.*;

@Deprecated
public interface RequestHandler {
public String makePostRequest(String url, Map<String,String> params) throws Exception;
}
6 changes: 6 additions & 0 deletions src/main/java/io/cryptolens/legacy/ResponseParser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.cryptolens.legacy;
@Deprecated
public interface ResponseParser {
public Base64Response parseBase64Response(String response);
public LicenseKey parseLicenseKey(byte[] licenseKey);
}
3 changes: 3 additions & 0 deletions src/main/java/io/cryptolens/methods/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;

/**
* A collection of helper methods that operate on a license key.
*/
public class Helpers {

/**
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/io/cryptolens/methods/Key.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package io.cryptolens.methods;

import com.google.gson.Gson;
import io.cryptolens.*;
import io.cryptolens.internal.HelperMethods;
import io.cryptolens.models.ActivateModel;
import io.cryptolens.models.ActivateResult;
import io.cryptolens.models.BasicResult;
import io.cryptolens.internal.ActivateResult;
import io.cryptolens.models.LicenseKey;

import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;

/**
* A collection of methods that operate on a license key. Please see a complete
* list here: https://app.cryptolens.io/docs/api/v3/Key
*/
public class Key {

/**
Expand Down
59 changes: 31 additions & 28 deletions src/main/java/io/cryptolens/models/ActivateModel.java
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
package io.cryptolens.models;

/**
* The parameters that are used when calling the Key.Activate method.
*/
public class ActivateModel {

/// <summary>
/// The product id, which can be found on the product page.
/// </summary>
/**
* The product id, which can be found on the product page.
*/
public int ProductId;

/// <summary>
/// The Key string, eg. AAAA-BBBB-CCCC-DDDD.
/// </summary>
/**
* The Key string, eg. AAAA-BBBB-CCCC-DDDD.
*/
public String Key;

/// <summary>
/// The machine code (a string that identifies a device) for activation.
/// </summary>
/**
* The machine code (a string that identifies a device) for activation.
*/
public String MachineCode;

/// <summary>
/// An integer that allows you to restrict the information returned in the license key data object.
/// Please read https://app.cryptolens.io/docs/api/v3/Activate#remarks for more details.
/// </summary>
/**
* An integer that allows you to restrict the information returned in the license key data object.
* Please read https://app.cryptolens.io/docs/api/v3/Activate#remarks for more details.
*/
public int FieldsToReturn;

/// <summary>
/// Includes additional information about the license key, such as number of activated devices, etc.
/// </summary>
/**
* Includes additional information about the license key, such as number of activated devices, etc.
*/
public boolean Metadata;

/// <summary>
/// When set to something greater than zero, floating licensing will be enabled.
/// The time interval is then used to check that no more than the allowed number
/// of machine codes (specified in maximumNumberOfMachines) have been activated
/// in that time period (in seconds).
/// </summary>
/**
* When set to something greater than zero, floating licensing will be enabled.
* The time interval is then used to check that no more than the allowed number
* of machine codes (specified in maximumNumberOfMachines) have been activated
* in that time period (in seconds).
*/
public int FloatingTimeInterval;

/// <summary>
/// When set to something greater than zero (and assuming FloatingTimeInterval is set too)
/// floating licensing will permit a license overdraft (eg. activation will succeed even if
/// maximumNumberOfMachines is reached). MaxOverdraft value specifies how much we can exceed
/// the maximumNumberOfMachines value.
/// </summary>
/**
* When set to something greater than zero (and assuming FloatingTimeInterval is set too)
* floating licensing will permit a license overdraft (eg. activation will succeed even if
* maximumNumberOfMachines is reached). MaxOverdraft value specifies how much we can exceed
* the maximumNumberOfMachines value.
*/
public int MaxOverdraft;

public ActivateModel() {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/io/cryptolens/models/LicenseKey.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package io.cryptolens.models;

import com.google.gson.Gson;
import io.cryptolens.JavaSecuritySignatureVerifier;
import io.cryptolens.internal.ActivateResult;
import io.cryptolens.legacy.JavaSecuritySignatureVerifier;
import io.cryptolens.methods.Helpers;

import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.List;

/**
* Represents a license returned by Key.Activate.
*/
public class LicenseKey {
public int ProductId;
public long Id;
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/io/cryptolens/KeyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import io.cryptolens.methods.Helpers;
import io.cryptolens.methods.Key;
import io.cryptolens.models.ActivateModel;
import io.cryptolens.models.ActivateResult;
import io.cryptolens.models.BasicResult;
import io.cryptolens.models.LicenseKey;
import junit.framework.Test;
import junit.framework.TestCase;
Expand Down

0 comments on commit 7d63227

Please sign in to comment.