Keygen for JIRA Enterprise Edition - Java Security

Java examples for Security:Key

Description

Keygen for JIRA Enterprise Edition

Demo Code


import com.atlassian.license.LicensePair;
import java.io.*;
import java.security.KeyFactory;
import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;

public class Main {
  public static void main(String args[]) throws IOException {
    try {/*from   w w  w . ja  v a 2  s .co  m*/
      long l = 267L;
      long l1 = 1243123123123123L;
      long l2 = 1232123123321567765L;
      String s = "this is a test";

      try {
        PKCS8EncodedKeySpec pkcs8encodedkeyspec = new PKCS8EncodedKeySpec(EncodedPrvKey);
        KeyFactory keyfactory = KeyFactory.getInstance("DSA", "SUN");
        java.security.PrivateKey privatekey = keyfactory.generatePrivate(pkcs8encodedkeyspec);
        String s1 = Long.toString(l, 10);
        s1 = s1 + "^";
        s1 = s1 + Long.toString(l1, 10);
        s1 = s1 + "^";
        s1 = s1 + Long.toString(l2, 10);
        s1 = s1 + "^";
        s1 = s1 + s;
        byte abyte0[] = s1.getBytes();
        Signature signature = Signature.getInstance("SHA1withDSA");
        signature.initSign(privatekey);
        signature.update(abyte0);
        byte abyte1[] = signature.sign();
        LicensePair licensepair = null;
        try {
          licensepair = new LicensePair(abyte0, abyte1);
        } catch (Exception exception1) {
          exception1.printStackTrace();
        }

        System.out.println("Your license key is: ");
        System.out.println(licensepair.toString());
      } catch (Exception exception) {
        exception.printStackTrace();
      }
    } catch (IOException ioexception) {
    }
  }

  static byte EncodedPrvKey[] = { /*your private key */ };
}

Related Tutorials