Add online licensing system, web calls now use https
parent
2eff46e6ad
commit
d6d0ba9bd4
@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.ButtonGroup" name="grp1">
|
||||
</Component>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="title" type="java.lang.String" value="Welcome"/>
|
||||
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/net/apocalypselabs/symat/icon16.png"/>
|
||||
</Property>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[435, 350]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[435, 350]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[435, 350]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="emailBox" alignment="0" min="-2" pref="267" max="-2" attributes="0"/>
|
||||
<Component id="noLicSel" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="orgLicSel" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="singLicSel" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="emailLbl" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="28" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="contBtn" max="32767" attributes="0"/>
|
||||
<Component id="exitBtn" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="singLicSel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="orgLicSel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="noLicSel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="emailLbl" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="exitBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="emailBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="contBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="<html>
<h1>Welcome to SyMAT!</h1>
<p>It would be a good idea to get this copy fully activated
<br />before you go any further.</p>
<br />
<p>Do you have a license?</p>"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="singLicSel">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="grp1"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Yes, I have a single-user license"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="singLicSelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="orgLicSel">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="grp1"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="No, but my school or work might have one"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="orgLicSelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="noLicSel">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="grp1"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="No, I don't have a license"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="noLicSelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="emailBox">
|
||||
<Properties>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Text Cursor"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="emailBoxActionPerformed"/>
|
||||
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="emailBoxKeyPressed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="emailBox.setVisible(false);"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="emailLbl">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Great! Enter your email address and we'll get things set up."/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="emailLbl.setVisible(false);
"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="contBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Continue"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="contBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="exitBtn">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Exit"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -0,0 +1,399 @@
|
||||
/*
|
||||
* Apocalypse Laboratories
|
||||
* Open Source License
|
||||
*
|
||||
* Source code can be used for any purpose, as long as:
|
||||
* - Compiled binaries are rebranded and trademarks are not
|
||||
* visible by the end user at any time, except to give
|
||||
* credit to Apocalypse Laboratories, such as by showing
|
||||
* "Based on <product> by Apocalypse Laboratories" or a
|
||||
* similar notice;
|
||||
* - You do not use the code for evil;
|
||||
* - Rebranded compiled applications have significant
|
||||
* differences in functionality;
|
||||
* - and you provide your modified source code for download,
|
||||
* under the terms of the GNU LGPL v3 or a comparable
|
||||
* license.
|
||||
*
|
||||
* Compiled binaries cannot be redistributed or mirrored,
|
||||
* unless:
|
||||
* - You have written permission from Apocalypse Laboratories;
|
||||
* - Downloads are not available from Apocalypse Laboratories,
|
||||
* not even behind a paywall or other blocking mechanism;
|
||||
* - or you have received a multi-computer license, in which
|
||||
* case you should take measures to prevent unauthorized
|
||||
* downloads, such as preventing download access from the
|
||||
* Internet.
|
||||
*/
|
||||
package net.apocalypselabs.symat;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import javax.swing.JOptionPane;
|
||||
import static net.apocalypselabs.symat.MainGUI.API_URL;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Skylar
|
||||
*/
|
||||
public class FirstRun extends javax.swing.JInternalFrame {
|
||||
|
||||
/**
|
||||
* Creates new form FirstRun
|
||||
*/
|
||||
public FirstRun() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
grp1 = new javax.swing.ButtonGroup();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
singLicSel = new javax.swing.JRadioButton();
|
||||
orgLicSel = new javax.swing.JRadioButton();
|
||||
noLicSel = new javax.swing.JRadioButton();
|
||||
emailBox = new javax.swing.JTextField();
|
||||
emailLbl = new javax.swing.JLabel();
|
||||
contBtn = new javax.swing.JButton();
|
||||
exitBtn = new javax.swing.JButton();
|
||||
|
||||
setTitle("Welcome");
|
||||
setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icon16.png"))); // NOI18N
|
||||
setMaximumSize(new java.awt.Dimension(435, 350));
|
||||
setMinimumSize(new java.awt.Dimension(435, 350));
|
||||
setPreferredSize(new java.awt.Dimension(435, 350));
|
||||
|
||||
jLabel1.setText("<html>\n<h1>Welcome to SyMAT!</h1>\n<p>It would be a good idea to get this copy fully activated\n<br />before you go any further.</p>\n<br />\n<p>Do you have a license?</p>");
|
||||
|
||||
grp1.add(singLicSel);
|
||||
singLicSel.setText("Yes, I have a single-user license");
|
||||
singLicSel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
singLicSelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
grp1.add(orgLicSel);
|
||||
orgLicSel.setText("No, but my school or work might have one");
|
||||
orgLicSel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
orgLicSelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
grp1.add(noLicSel);
|
||||
noLicSel.setSelected(true);
|
||||
noLicSel.setText("No, I don't have a license");
|
||||
noLicSel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
noLicSelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
emailBox.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
|
||||
emailBox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
emailBoxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
emailBox.addKeyListener(new java.awt.event.KeyAdapter() {
|
||||
public void keyPressed(java.awt.event.KeyEvent evt) {
|
||||
emailBoxKeyPressed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
emailLbl.setText("Great! Enter your email address and we'll get things set up.");
|
||||
|
||||
contBtn.setText("Continue");
|
||||
contBtn.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
contBtnActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
exitBtn.setText("Exit");
|
||||
exitBtn.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
exitBtnActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(emailBox, javax.swing.GroupLayout.PREFERRED_SIZE, 267, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(noLicSel)
|
||||
.addComponent(orgLicSel)
|
||||
.addComponent(singLicSel)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(emailLbl))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(contBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(exitBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGap(18, 18, 18))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(singLicSel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(orgLicSel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(noLicSel)
|
||||
.addGap(17, 17, 17)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(emailLbl)
|
||||
.addComponent(exitBtn))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(emailBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(contBtn))
|
||||
.addGap(20, 20, 20))
|
||||
);
|
||||
|
||||
emailBox.setVisible(false);
|
||||
emailLbl.setVisible(false);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void singLicSelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_singLicSelActionPerformed
|
||||
emailLbl.setVisible(true);
|
||||
emailBox.setVisible(true);
|
||||
emailLbl.setText("Great! Now just enter your email address.");
|
||||
}//GEN-LAST:event_singLicSelActionPerformed
|
||||
|
||||
private void orgLicSelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_orgLicSelActionPerformed
|
||||
emailLbl.setVisible(true);
|
||||
emailBox.setVisible(true);
|
||||
emailLbl.setText("OK, enter your school or work email address.");
|
||||
}//GEN-LAST:event_orgLicSelActionPerformed
|
||||
|
||||
private void noLicSelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_noLicSelActionPerformed
|
||||
emailLbl.setVisible(false);
|
||||
emailBox.setVisible(false);
|
||||
}//GEN-LAST:event_noLicSelActionPerformed
|
||||
|
||||
private void openShop() {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI(MainGUI.API_URL + "shoplink.php"));
|
||||
} catch (IOException | URISyntaxException ex) {
|
||||
JOptionPane.showInternalMessageDialog(this, "Please go to symatapp.com to purchase a license.");
|
||||
}
|
||||
} else {
|
||||
JOptionPane.showInternalMessageDialog(this, "Please go to symatapp.com to purchase a license.");
|
||||
}
|
||||
}
|
||||
|
||||
private void contBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_contBtnActionPerformed
|
||||
if (noLicSel.isSelected()) {
|
||||
if (PrefStorage.getSetting("licensetype").equals("demo")
|
||||
&& PrefStorage.getSetting("licensedemo").equals("used")) {
|
||||
int ans = JOptionPane.showInternalConfirmDialog(this,
|
||||
"You have already used a trial license."
|
||||
+ "\nWould you like to purchase a license?",
|
||||
"Expired",
|
||||
JOptionPane.YES_NO_OPTION);
|
||||
if (ans == JOptionPane.NO_OPTION) {
|
||||
|
||||
} else {
|
||||
openShop();
|
||||
}
|
||||
} else {
|
||||
int ans = JOptionPane.showInternalConfirmDialog(this,
|
||||
"Would you like to open the shop and"
|
||||
+ " purchase a license?",
|
||||
"Open Browser",
|
||||
JOptionPane.YES_NO_OPTION);
|
||||
if (ans == JOptionPane.NO_OPTION) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(new Date());
|
||||
c.add(Calendar.DATE, 15); // Adds 15 days
|
||||
|
||||
PrefStorage.saveSetting("licensetype", "demo");
|
||||
PrefStorage.saveSetting("license", String.valueOf(c.getTimeInMillis()));
|
||||
PrefStorage.saveSetting("licensedemo", "used");
|
||||
JOptionPane.showInternalMessageDialog(this,
|
||||
"A trial license of 15 days has been activated.",
|
||||
"Activated",
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
exit();
|
||||
} else {
|
||||
openShop();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (checkRegex()) {
|
||||
new CheckThread(emailBox.getText()).start();
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_contBtnActionPerformed
|
||||
|
||||
private void emailBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emailBoxActionPerformed
|
||||
checkRegex();
|
||||
}//GEN-LAST:event_emailBoxActionPerformed
|
||||
|
||||
private void emailBoxKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_emailBoxKeyPressed
|
||||
checkRegex();
|
||||
}//GEN-LAST:event_emailBoxKeyPressed
|
||||
|
||||
private void exitBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitBtnActionPerformed
|
||||
int result = JOptionPane.showInternalConfirmDialog(this,
|
||||
"Are you sure you want to exit SyMAT?",
|
||||
"Quit",
|
||||
JOptionPane.YES_NO_OPTION);
|
||||
if (result == JOptionPane.YES_OPTION) {
|
||||
System.exit(0);
|
||||
}
|
||||
}//GEN-LAST:event_exitBtnActionPerformed
|
||||
|
||||
private boolean checkRegex() {
|
||||
String regex = "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]+$";
|
||||
if (emailBox.getText().matches(regex)) {
|
||||
contBtn.setEnabled(true);
|
||||
return true;
|
||||
} else {
|
||||
contBtn.setEnabled(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
MainGUI.updateNamemark(); // Make sure it displays trial or not
|
||||
dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the email address for a license.
|
||||
*/
|
||||
private class CheckThread extends Thread {
|
||||
|
||||
private String email;
|
||||
|
||||
public CheckThread(String useremail) {
|
||||
email = useremail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Debug.println("Checking license...");
|
||||
URL url = new URL(API_URL + "liccheck.php?email=" + email);
|
||||
InputStream is = url.openStream();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
String line = br.readLine();
|
||||
br.close();
|
||||
is.close();
|
||||
|
||||
switch (line) {
|
||||
case "ok:single":
|
||||
success("single");
|
||||
break;
|
||||
case "ok:domain":
|
||||
success("domain");
|
||||
break;
|
||||
case "checkemail":
|
||||
email();
|
||||
break;
|
||||
default:
|
||||
fail();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Debug.printerr("License check failed.");
|
||||
Debug.stacktrace(e);
|
||||
ioerror();
|
||||
}
|
||||
}
|
||||
|
||||
private void success(String type) {
|
||||
PrefStorage.saveSetting("license", email);
|
||||
PrefStorage.saveSetting("licensetype", type);
|
||||
JOptionPane.showInternalMessageDialog(MainGUI.mainPane,
|
||||
"Thank you for activating SyMAT!",
|
||||
"Success",
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
exit();
|
||||
}
|
||||
|
||||
private void fail() {
|
||||
JOptionPane.showInternalMessageDialog(MainGUI.mainPane,
|
||||
"There is not a valid license for that email address.",
|
||||
"Activation failure",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
private void email() {
|
||||
try {
|
||||
String code = JOptionPane.showInternalInputDialog(MainGUI.mainPane,
|
||||
"A code has been emailed to you. "
|
||||
+ "Enter it below to verify.",
|
||||
"Almost done!",
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
Debug.println("Checking license code (" + code + ")...");
|
||||
URL url = new URL(API_URL + "emailverify.php?code=" + code + "&email=" + email);
|
||||
InputStream is = url.openStream();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
String line = br.readLine();
|
||||
br.close();
|
||||
is.close();
|
||||
if (code.equals(line)) {
|
||||
success("domain");
|
||||
} else {
|
||||
JOptionPane.showInternalMessageDialog(MainGUI.mainPane,
|
||||
"Code invalid.",
|
||||
"Error",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ioerror();
|
||||
}
|
||||
}
|
||||
|
||||
private void ioerror() {
|
||||
JOptionPane.showMessageDialog(MainGUI.mainPane,
|
||||
"An error occured while verifying your license. "
|
||||
+ "Ensure you have an Internet connection and "
|
||||
+ "try again later.",
|
||||
"Error",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton contBtn;
|
||||
private javax.swing.JTextField emailBox;
|
||||
private javax.swing.JLabel emailLbl;
|
||||
private javax.swing.JButton exitBtn;
|
||||
private javax.swing.ButtonGroup grp1;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JRadioButton noLicSel;
|
||||
private javax.swing.JRadioButton orgLicSel;
|
||||
private javax.swing.JRadioButton singLicSel;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
Loading…
Reference in New Issue