diff --git a/auth-security/pom.xml b/auth-security/pom.xml index 6f207940..04902bf1 100644 --- a/auth-security/pom.xml +++ b/auth-security/pom.xml @@ -7,7 +7,7 @@ de.alpharogroup mystic-crypt - 4.18.0 + 4.19.0 auth-security diff --git a/crypt-core/pom.xml b/crypt-core/pom.xml index 09561594..9fa242db 100644 --- a/crypt-core/pom.xml +++ b/crypt-core/pom.xml @@ -5,7 +5,7 @@ de.alpharogroup mystic-crypt - 4.18.0 + 4.19.0 crypt-core diff --git a/crypt-data/pom.xml b/crypt-data/pom.xml index cdc2fd2f..e190c478 100644 --- a/crypt-data/pom.xml +++ b/crypt-data/pom.xml @@ -5,7 +5,7 @@ de.alpharogroup mystic-crypt - 4.18.0 + 4.19.0 crypt-data diff --git a/mystic-crypt-ui/pom.xml b/mystic-crypt-ui/pom.xml index 18c305ce..dee259e2 100644 --- a/mystic-crypt-ui/pom.xml +++ b/mystic-crypt-ui/pom.xml @@ -5,12 +5,12 @@ de.alpharogroup mvn-ui-parent - 1.6.1 + 1.7.0 mystic-crypt-ui - 4.18.0 + 4.19.0 5.0 @@ -340,8 +340,8 @@ - de.alpharogroup.duplicate.files.desktoppane.MainApplication - de.alpharogroup.duplicate.files.desktoppane + de.alpharogroup.mystic.crypt.MainApplication + de.alpharogroup.mystic.crypt development @@ -362,7 +362,7 @@ - de.alpharogroup.duplicate.files.desktoppane.MainApplication + de.alpharogroup.mystic.crypt.MainApplication @@ -373,7 +373,7 @@ package - attached + single @@ -385,6 +385,7 @@ + maven-jar-plugin @@ -523,8 +524,204 @@ + + + + maven-dependency-plugin + + + + org.codehaus.izpack + izpack-maven-plugin + + + + + + + + + + + + prepare-and-release-and-izpack + + + performRelease + true + + + + + + + + + + + maven-jar-plugin + + + + de.alpharogroup.mystic.crypt.MainApplication + de.alpharogroup.mystic.crypt + + + development + ${pom.url} + + src/main/resources/META-INF/MANIFEST.MF + + + + + + + maven-assembly-plugin + + + jar-with-dependencies + + + + de.alpharogroup.mystic.crypt.MainApplication + + + + + + make-assembly + + package + + + single + + + + + + + + maven-antrun-plugin + + + create-staging-area + process-resources + + run + + + + + + + + + + + + + + maven-dependency-plugin + + false + + true + true + true + true + system + + + + + copy-product-dependencies + prepare-package + + copy-dependencies + + + ${izpack.staging}/lib + system + + ${project.artifactId} + + org.codehaus.izpack + + + + + + copy-izpack-dependencies + prepare-package + + copy-dependencies + + + ${izpack.staging}/custom + ${project.artifactId} + + + + + + + + org.codehaus.izpack + izpack-maven-plugin + + + package + + izpack + + + + ${izpack.staging} + ${izpack.dir.app}/install.xml + + + + + + + org.codehaus.izpack + izpack-panel + ${izpack.version} + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + + + + + + + + + + + maven-jar-plugin + + + + maven-assembly-plugin + + + + maven-antrun-plugin + maven-dependency-plugin diff --git a/mystic-crypt-ui/src/main/java/de/alpharogroup/mystic/crypt/MainFrame.java b/mystic-crypt-ui/src/main/java/de/alpharogroup/mystic/crypt/MainFrame.java index 1b5b0b18..4b7efd8a 100644 --- a/mystic-crypt-ui/src/main/java/de/alpharogroup/mystic/crypt/MainFrame.java +++ b/mystic-crypt-ui/src/main/java/de/alpharogroup/mystic/crypt/MainFrame.java @@ -31,6 +31,7 @@ import org.jdesktop.swingx.JXFrame; +import de.alpharogroup.mystic.crypt.panels.GenerateKeysPanel; // //import de.alpharogroup.duplicate.files.controller.FindDuplicateFilesController; //import de.alpharogroup.duplicate.files.gen.view.FindDuplicateFilesView; @@ -101,8 +102,9 @@ private void initComponents() { // create internal frame internalFrame = JComponentFactory.newInternalFrame("Random generator", true, true, true, true); -// final FindDuplicateFilesView view = new FindDuplicateFilesView(new FindDuplicateFilesController()); -// JInternalFrameExtensions.setViewAndControllerForJInternalFrame(internalFrame, view); + + final GenerateKeysPanel component = new GenerateKeysPanel(); + JInternalFrameExtensions.addComponentToFrame(internalFrame, component); JInternalFrameExtensions.addJInternalFrame(desktopPane, internalFrame); diff --git a/mystic-crypt-ui/src/main/java/de/alpharogroup/mystic/crypt/panels/CryptographyPanel.java b/mystic-crypt-ui/src/main/java/de/alpharogroup/mystic/crypt/panels/CryptographyPanel.java index 80b8e495..62e334b4 100644 --- a/mystic-crypt-ui/src/main/java/de/alpharogroup/mystic/crypt/panels/CryptographyPanel.java +++ b/mystic-crypt-ui/src/main/java/de/alpharogroup/mystic/crypt/panels/CryptographyPanel.java @@ -37,6 +37,8 @@ import javax.swing.JScrollPane; import javax.swing.JTextArea; +import org.apache.log4j.Logger; + import de.alpharogroup.crypto.key.KeySize; import de.alpharogroup.layout.GridBagLayoutModel; import de.alpharogroup.layout.InsetsModel; @@ -50,6 +52,9 @@ public class CryptographyPanel extends JPanel { + /** The Constant logger. */ + protected static final Logger logger = Logger.getLogger(CryptographyPanel.class.getName()); + /** The Constant serialVersionUID. */ private static final long serialVersionUID = 1L; @@ -112,7 +117,6 @@ protected void initialize() @SuppressWarnings({ "unchecked", "rawtypes" }) protected void initializeComponents() { - scpPrivateKey = new JScrollPane(); txtPrivateKey = new JTextArea(); cmbKeySize = new JComboBox<>(); @@ -126,9 +130,11 @@ protected void initializeComponents() btnSavePrivateKey = new JButton(); btnSavePublicKey = new JButton(); + txtPrivateKey.setEditable(false); + txtPublicKey.setEditable(false); - txtPublicKey.setFont(new Font("monospaced", Font.PLAIN, 12)); txtPrivateKey.setFont(new Font("monospaced", Font.PLAIN, 12)); + txtPublicKey.setFont(new Font("monospaced", Font.PLAIN, 12)); cmbKeySize.addActionListener(actionEvent -> onChangeKeySize(actionEvent)); btnGenerate.addActionListener(actionEvent -> onGenerate(actionEvent)); @@ -170,240 +176,158 @@ protected void initializeComponents() protected void initializeLayout() { initializeGroupLayout(); -// initializeGridBagLayout(); + // initializeGridBagLayout(); } - private void initializeGridBagLayout() { + protected void initializeGridBagLayout() + { final GridBagLayout gbl = new GridBagLayout(); final GridBagConstraints gbc = new GridBagConstraints(); this.setLayout(gbl); - LayoutExtensions.add(GridBagLayoutModel.builder() - .layoutComponent(lblKeySize) - .parent(this) - .gridBagLayout(gbl) - .gridBagConstraints(gbc) - .anchor(GridBagConstraints.NORTHWEST) - .fill(GridBagConstraints.BOTH) - .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()) - .gridx(0) - .gridy(1) - .gridwidth(1) - .gridheight(1) - .weightx(100) - .weighty(100) - .build()); - - LayoutExtensions.add(GridBagLayoutModel.builder() - .layoutComponent(lblPrivateKey) - .parent(this) - .gridBagLayout(gbl) - .gridBagConstraints(gbc) - .anchor(GridBagConstraints.NORTHWEST) + LayoutExtensions.add(GridBagLayoutModel.builder().layoutComponent(lblKeySize).parent(this) + .gridBagLayout(gbl).gridBagConstraints(gbc).anchor(GridBagConstraints.NORTHWEST) .fill(GridBagConstraints.BOTH) - .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()) - .gridx(1) - .gridy(1) - .gridwidth(1) - .gridheight(1) - .weightx(100) - .weighty(100) - .build()); - - LayoutExtensions.add(GridBagLayoutModel.builder() - .layoutComponent(lblPublicKey) - .parent(this) - .gridBagLayout(gbl) - .gridBagConstraints(gbc) - .anchor(GridBagConstraints.NORTHWEST) + .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()).gridx(0) + .gridy(1).gridwidth(1).gridheight(1).weightx(100).weighty(100).build()); + + LayoutExtensions.add(GridBagLayoutModel.builder().layoutComponent(lblPrivateKey) + .parent(this).gridBagLayout(gbl).gridBagConstraints(gbc) + .anchor(GridBagConstraints.NORTHWEST).fill(GridBagConstraints.BOTH) + .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()).gridx(1) + .gridy(1).gridwidth(1).gridheight(1).weightx(100).weighty(100).build()); + + LayoutExtensions.add(GridBagLayoutModel.builder().layoutComponent(lblPublicKey).parent(this) + .gridBagLayout(gbl).gridBagConstraints(gbc).anchor(GridBagConstraints.NORTHWEST) .fill(GridBagConstraints.BOTH) - .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()) - .gridx(2) - .gridy(1) - .gridwidth(1) - .gridheight(1) - .weightx(100) - .weighty(100) - .build()); - - LayoutExtensions.add(GridBagLayoutModel.builder() - .layoutComponent(cmbKeySize) - .parent(this) - .gridBagLayout(gbl) - .gridBagConstraints(gbc) - .anchor(GridBagConstraints.NORTHWEST) + .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()).gridx(2) + .gridy(1).gridwidth(1).gridheight(1).weightx(100).weighty(100).build()); + + LayoutExtensions.add(GridBagLayoutModel.builder().layoutComponent(cmbKeySize).parent(this) + .gridBagLayout(gbl).gridBagConstraints(gbc).anchor(GridBagConstraints.NORTHWEST) .fill(GridBagConstraints.HORIZONTAL) - .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()) - .gridx(0) - .gridy(2) - .gridwidth(1) - .gridheight(1) - .weightx(100) - .weighty(100) - .build()); - - LayoutExtensions.add(GridBagLayoutModel.builder() - .layoutComponent(txtPrivateKey) - .parent(this) - .gridBagLayout(gbl) - .gridBagConstraints(gbc) - .anchor(GridBagConstraints.NORTHWEST) - .fill(GridBagConstraints.BOTH) - .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()) - .gridx(1) - .gridy(2) - .gridwidth(1) - .gridheight(1) - .weightx(100) - .weighty(100) - .build()); - - LayoutExtensions.add(GridBagLayoutModel.builder() - .layoutComponent(txtPublicKey) - .parent(this) - .gridBagLayout(gbl) - .gridBagConstraints(gbc) - .anchor(GridBagConstraints.NORTHWEST) + .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()).gridx(0) + .gridy(2).gridwidth(1).gridheight(1).weightx(100).weighty(100).build()); + + LayoutExtensions.add(GridBagLayoutModel.builder().layoutComponent(txtPrivateKey) + .parent(this).gridBagLayout(gbl).gridBagConstraints(gbc) + .anchor(GridBagConstraints.NORTHWEST).fill(GridBagConstraints.BOTH) + .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()).gridx(1) + .gridy(2).gridwidth(1).gridheight(1).weightx(100).weighty(100).build()); + + LayoutExtensions.add(GridBagLayoutModel.builder().layoutComponent(txtPublicKey).parent(this) + .gridBagLayout(gbl).gridBagConstraints(gbc).anchor(GridBagConstraints.NORTHWEST) .fill(GridBagConstraints.BOTH) - .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()) - .gridx(2) - .gridy(2) - .ipady(140)// make this component tall - .gridwidth(1) - .gridheight(1) - .weightx(100) - .weighty(100) - .build()); - - LayoutExtensions.add(GridBagLayoutModel.builder() - .layoutComponent(btnGenerate) - .parent(this) - .gridBagLayout(gbl) - .gridBagConstraints(gbc) - .anchor(GridBagConstraints.NORTHWEST) + .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()).gridx(2) + .gridy(2).ipady(140)// make this component tall + .gridwidth(1).gridheight(1).weightx(100).weighty(100).build()); + + LayoutExtensions.add(GridBagLayoutModel.builder().layoutComponent(btnGenerate).parent(this) + .gridBagLayout(gbl).gridBagConstraints(gbc).anchor(GridBagConstraints.NORTHWEST) .fill(GridBagConstraints.HORIZONTAL) - .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()) - .gridx(0) - .gridy(3) - .gridwidth(1) - .gridheight(1) - .weightx(100) - .weighty(100) - .build()); - - LayoutExtensions.add(GridBagLayoutModel.builder() - .layoutComponent(btnClear) - .parent(this) - .gridBagLayout(gbl) - .gridBagConstraints(gbc) - .anchor(GridBagConstraints.NORTHWEST) + .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()).gridx(0) + .gridy(3).gridwidth(1).gridheight(1).weightx(100).weighty(100).build()); + + LayoutExtensions.add(GridBagLayoutModel.builder().layoutComponent(btnClear).parent(this) + .gridBagLayout(gbl).gridBagConstraints(gbc).anchor(GridBagConstraints.NORTHWEST) .fill(GridBagConstraints.HORIZONTAL) - .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()) - .gridx(0) - .gridy(4) - .gridwidth(1) - .gridheight(1) - .weightx(100) - .weighty(100) - .build()); - - LayoutExtensions.add(GridBagLayoutModel.builder() - .layoutComponent(btnSavePrivateKey) - .parent(this) - .gridBagLayout(gbl) - .gridBagConstraints(gbc) - .anchor(GridBagConstraints.NORTHWEST) - .fill(GridBagConstraints.BOTH) - .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()) - .gridx(1) - .gridy(5) - .gridwidth(1) - .gridheight(1) - .weightx(100) - .weighty(100) - .build()); - - LayoutExtensions.add(GridBagLayoutModel.builder() - .layoutComponent(btnSavePublicKey) - .parent(this) - .gridBagLayout(gbl) - .gridBagConstraints(gbc) - .anchor(GridBagConstraints.NORTHWEST) - .fill(GridBagConstraints.BOTH) - .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()) - .gridx(2) - .gridy(5) - .gridwidth(1) - .gridheight(1) - .weightx(100) - .weighty(100) - .build()); + .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()).gridx(0) + .gridy(4).gridwidth(1).gridheight(1).weightx(100).weighty(100).build()); + + LayoutExtensions.add(GridBagLayoutModel.builder().layoutComponent(btnSavePrivateKey) + .parent(this).gridBagLayout(gbl).gridBagConstraints(gbc) + .anchor(GridBagConstraints.NORTHWEST).fill(GridBagConstraints.BOTH) + .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()).gridx(1) + .gridy(5).gridwidth(1).gridheight(1).weightx(100).weighty(100).build()); + + LayoutExtensions.add(GridBagLayoutModel.builder().layoutComponent(btnSavePublicKey) + .parent(this).gridBagLayout(gbl).gridBagConstraints(gbc) + .anchor(GridBagConstraints.NORTHWEST).fill(GridBagConstraints.BOTH) + .insets(InsetsModel.builder().top(2).left(2).bottom(2).right(2).build()).gridx(2) + .gridy(5).gridwidth(1).gridheight(1).weightx(100).weighty(100).build()); } - private void initializeGroupLayout() + protected void initializeGroupLayout() { - - final javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(cmbKeySize, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(btnGenerate, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE))) - .addGroup(layout.createSequentialGroup() - .addGap(21, 21, 21) - .addComponent(lblKeySize, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(btnClear, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(scpPrivateKey, javax.swing.GroupLayout.PREFERRED_SIZE, 480, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(lblPrivateKey, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGroup(layout.createSequentialGroup() - .addGap(542, 542, 542) - .addComponent(btnSavePrivateKey, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(lblPublicKey, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(scpPublicKey, javax.swing.GroupLayout.PREFERRED_SIZE, 480, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(btnSavePublicKey, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(31, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGap(26, 26, 26) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(lblPrivateKey, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(lblKeySize, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(lblPublicKey, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(layout.createSequentialGroup() - .addComponent(cmbKeySize, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(btnGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(btnClear, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(scpPrivateKey, javax.swing.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE) - .addComponent(scpPublicKey)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(btnSavePublicKey, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(btnSavePrivateKey, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap()) - ); + final javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup( + javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout + .createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createSequentialGroup().addGroup(layout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(cmbKeySize, 0, javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent(btnGenerate, javax.swing.GroupLayout.DEFAULT_SIZE, 206, + Short.MAX_VALUE))) + .addGroup(layout.createSequentialGroup().addGap(21, 21, 21).addComponent( + lblKeySize, javax.swing.GroupLayout.PREFERRED_SIZE, 147, + javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup().addContainerGap().addComponent( + btnClear, javax.swing.GroupLayout.DEFAULT_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGap(18, 18, 18).addGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(scpPrivateKey, javax.swing.GroupLayout.PREFERRED_SIZE, + 480, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblPrivateKey, javax.swing.GroupLayout.PREFERRED_SIZE, + 147, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup().addGap(542, 542, 542).addComponent( + btnSavePrivateKey, javax.swing.GroupLayout.PREFERRED_SIZE, 174, + javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, + Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(lblPublicKey, javax.swing.GroupLayout.PREFERRED_SIZE, 147, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(scpPublicKey, javax.swing.GroupLayout.PREFERRED_SIZE, 480, + javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(btnSavePublicKey, javax.swing.GroupLayout.Alignment.TRAILING, + javax.swing.GroupLayout.PREFERRED_SIZE, 174, + javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(31, Short.MAX_VALUE))); + layout + .setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup().addGap(26, 26, 26) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lblPrivateKey, javax.swing.GroupLayout.PREFERRED_SIZE, 29, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblKeySize, javax.swing.GroupLayout.PREFERRED_SIZE, 29, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblPublicKey, javax.swing.GroupLayout.PREFERRED_SIZE, 29, + javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(cmbKeySize, javax.swing.GroupLayout.PREFERRED_SIZE, 43, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(btnGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 41, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(btnClear, javax.swing.GroupLayout.PREFERRED_SIZE, 41, + javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(scpPrivateKey, javax.swing.GroupLayout.DEFAULT_SIZE, 265, + Short.MAX_VALUE) + .addComponent(scpPublicKey)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, + Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnSavePublicKey, javax.swing.GroupLayout.PREFERRED_SIZE, 41, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnSavePrivateKey, javax.swing.GroupLayout.PREFERRED_SIZE, 41, + javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap())); } /** @@ -415,8 +339,6 @@ private void initializeGroupLayout() */ protected void onChangeKeySize(final ActionEvent actionEvent) { - final Object selected = cmbKeySize.getSelectedItem(); - System.out.println("selected item:" + selected); } /** @@ -428,7 +350,6 @@ protected void onChangeKeySize(final ActionEvent actionEvent) */ protected void onSavePublicKey(final ActionEvent actionEvent) { - System.out.println("onSavePublicKey"); } /** @@ -440,7 +361,6 @@ protected void onSavePublicKey(final ActionEvent actionEvent) */ protected void onSavePrivateKey(final ActionEvent actionEvent) { - System.out.println("onSavePrivateKey"); } /** @@ -451,7 +371,6 @@ protected void onSavePrivateKey(final ActionEvent actionEvent) */ protected void onClear(final ActionEvent actionEvent) { - System.out.println("onClear"); } /** @@ -462,7 +381,6 @@ protected void onClear(final ActionEvent actionEvent) */ protected void onGenerate(final ActionEvent actionEvent) { - System.out.println("onGenerate"); } } diff --git a/mystic-crypt-ui/src/main/java/de/alpharogroup/mystic/crypt/panels/GenerateKeysPanel.java b/mystic-crypt-ui/src/main/java/de/alpharogroup/mystic/crypt/panels/GenerateKeysPanel.java index 9fd4c280..958c446e 100644 --- a/mystic-crypt-ui/src/main/java/de/alpharogroup/mystic/crypt/panels/GenerateKeysPanel.java +++ b/mystic-crypt-ui/src/main/java/de/alpharogroup/mystic/crypt/panels/GenerateKeysPanel.java @@ -1,40 +1,40 @@ package de.alpharogroup.mystic.crypt.panels; import java.awt.event.ActionEvent; +import java.io.FileWriter; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.PublicKey; import java.security.spec.InvalidKeySpecException; import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.swing.JComboBox; +import javax.swing.JFileChooser; import org.apache.commons.codec.DecoderException; +import org.apache.log4j.Logger; import org.jdesktop.swingx.JXPanel; import de.alpharogroup.crypto.algorithm.KeyPairGeneratorAlgorithm; -import de.alpharogroup.crypto.algorithm.KeyPairWithModeAndPaddingAlgorithm; import de.alpharogroup.crypto.factories.KeyPairFactory; import de.alpharogroup.crypto.key.KeySize; import de.alpharogroup.crypto.key.PrivateKeyExtensions; import de.alpharogroup.crypto.key.PrivateKeyHexDecryptor; import de.alpharogroup.crypto.key.PublicKeyExtensions; import de.alpharogroup.crypto.key.PublicKeyHexEncryptor; -import de.alpharogroup.crypto.model.CryptModel; import lombok.Getter; import net.miginfocom.swing.MigLayout; @Getter public class GenerateKeysPanel extends JXPanel { + /** The Constant logger. */ + protected static final Logger logger = Logger.getLogger(GenerateKeysPanel.class.getName()); private static final long serialVersionUID = 1L; @@ -42,14 +42,7 @@ public class GenerateKeysPanel extends JXPanel private EnDecryptPanel enDecryptPanel; - private PrivateKey privateKey; - private PublicKey publicKey; - - private PublicKeyHexEncryptor encryptor; - - private PrivateKeyHexDecryptor decryptor; - - private final GenerateKeysModelBean model= GenerateKeysModelBean.builder().build(); + private final GenerateKeysModelBean model = GenerateKeysModelBean.builder().build(); public GenerateKeysPanel() { @@ -71,9 +64,11 @@ protected void initialize() */ protected void initializeComponents() { - cryptographyPanel = new CryptographyPanel(){ + cryptographyPanel = new CryptographyPanel() + { private static final long serialVersionUID = 1L; + @Override protected void onChangeKeySize(final ActionEvent actionEvent) { @@ -91,24 +86,29 @@ protected void onGenerate(final ActionEvent actionEvent) { GenerateKeysPanel.this.onGenerate(actionEvent); } + @Override protected void onSavePrivateKey(final ActionEvent actionEvent) { GenerateKeysPanel.this.onSavePrivateKey(actionEvent); } + @Override protected void onSavePublicKey(final ActionEvent actionEvent) { GenerateKeysPanel.this.onSavePublicKey(actionEvent); } }; - enDecryptPanel = new EnDecryptPanel(){ + enDecryptPanel = new EnDecryptPanel() + { private static final long serialVersionUID = 1L; + @Override protected void onDecrypt(final ActionEvent actionEvent) { GenerateKeysPanel.this.onDecrypt(actionEvent); } + @Override protected void onEncrypt(final ActionEvent actionEvent) { @@ -123,7 +123,7 @@ protected void onEncrypt(final ActionEvent actionEvent) protected void initializeLayout() { setLayout(new MigLayout()); - add(cryptographyPanel, "wrap"); + add(cryptographyPanel, "wrap"); add(enDecryptPanel); } @@ -153,7 +153,24 @@ protected void onChangeKeySize(final ActionEvent actionEvent) */ protected void onSavePublicKey(final ActionEvent actionEvent) { - System.out.println("onSavePublicKey"); + final JFileChooser fileChooser = new JFileChooser(); + final int state = fileChooser.showSaveDialog(this); + if (state == JFileChooser.APPROVE_OPTION) + { + try + { + final FileWriter fw = new FileWriter(fileChooser.getSelectedFile() + ".pem"); + fw.write(getCryptographyPanel().getTxtPublicKey().getText()); + fw.close(); + } + catch (final Exception ex) + { + ex.printStackTrace(); + } + } + if (state == JFileChooser.CANCEL_OPTION) + { + } } /** @@ -165,7 +182,24 @@ protected void onSavePublicKey(final ActionEvent actionEvent) */ protected void onSavePrivateKey(final ActionEvent actionEvent) { - System.out.println("onSavePrivateKey"); + final JFileChooser fileChooser = new JFileChooser(); + final int state = fileChooser.showSaveDialog(this); + if (state == JFileChooser.APPROVE_OPTION) + { + try + { + final FileWriter fw = new FileWriter(fileChooser.getSelectedFile() + ".pem"); + fw.write(getCryptographyPanel().getTxtPrivateKey().getText()); + fw.close(); + } + catch (final Exception ex) + { + ex.printStackTrace(); + } + } + if (state == JFileChooser.CANCEL_OPTION) + { + } } /** @@ -176,7 +210,16 @@ protected void onSavePrivateKey(final ActionEvent actionEvent) */ protected void onClear(final ActionEvent actionEvent) { - System.out.println("onClear"); + getCryptographyPanel().getCmbKeySize().setSelectedItem(KeySize.KEYSIZE_1024); + getCryptographyPanel().getTxtPrivateKey().setText(""); + getCryptographyPanel().getTxtPublicKey().setText(""); + getEnDecryptPanel().getTxtEncrypted().setText(""); + getEnDecryptPanel().getTxtToEncrypt().setText(""); + model.setDecryptor(null); + model.setEncryptor(null); + model.setKeySize(KeySize.KEYSIZE_1024); + model.setPrivateKey(null); + model.setPublicKey(null); } /** @@ -187,15 +230,18 @@ protected void onClear(final ActionEvent actionEvent) */ protected void onGenerate(final ActionEvent actionEvent) { - System.out.println("onGenerate"); final KeySize selected = (KeySize)getCryptographyPanel().getCmbKeySize().getSelectedItem(); try { - final KeyPair keyPair = KeyPairFactory.newKeyPair(KeyPairGeneratorAlgorithm.RSA, selected.getKeySize()); + final KeyPair keyPair = KeyPairFactory.newKeyPair(KeyPairGeneratorAlgorithm.RSA, + selected.getKeySize()); model.setPrivateKey(keyPair.getPrivate()); model.setPublicKey(keyPair.getPublic()); + model.setDecryptor(new PrivateKeyHexDecryptor(model.getPrivateKey())); + model.setEncryptor(new PublicKeyHexEncryptor(model.getPublicKey())); + final String privateKeyFormat = PrivateKeyExtensions.toPemFormat(model.getPrivateKey()); final String publicKeyFormat = PublicKeyExtensions.toPemFormat(model.getPublicKey()); @@ -205,13 +251,11 @@ protected void onGenerate(final ActionEvent actionEvent) } catch (final NoSuchAlgorithmException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("", e); } catch (final IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("", e); } } @@ -220,15 +264,16 @@ protected void onGenerate(final ActionEvent actionEvent) /** * Callback method that can be overwritten to provide specific action for the on decrypt. * - * @param actionEvent the action event + * @param actionEvent + * the action event */ protected void onDecrypt(final ActionEvent actionEvent) { System.out.println("onDecrypt"); - decryptor = new PrivateKeyHexDecryptor(privateKey); try { - final String decryted = decryptor.decrypt(getEnDecryptPanel().getTxtEncrypted().getText()); + final String decryted = model.getDecryptor() + .decrypt(getEnDecryptPanel().getTxtEncrypted().getText()); getEnDecryptPanel().getTxtToEncrypt().setText(decryted); getEnDecryptPanel().getTxtEncrypted().setText(""); } @@ -236,8 +281,7 @@ protected void onDecrypt(final ActionEvent actionEvent) | IllegalBlockSizeException | BadPaddingException | InvalidKeySpecException | InvalidAlgorithmParameterException | DecoderException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("", e); } } @@ -246,44 +290,34 @@ protected void onDecrypt(final ActionEvent actionEvent) /** * Callback method that can be overwritten to provide specific action for the on encrypt. * - * @param actionEvent the action event + * @param actionEvent + * the action event */ protected void onEncrypt(final ActionEvent actionEvent) { System.out.println("onEncrypt"); - - final CryptModel encryptModel = CryptModel. builder() - .key(publicKey) - .algorithm(KeyPairWithModeAndPaddingAlgorithm.RSA_ECB_OAEPWithSHA256AndMGF1Padding) - .build(); - try { - encryptor = new PublicKeyHexEncryptor(publicKey); - - getEnDecryptPanel().getTxtEncrypted().setText(encryptor.encrypt(getEnDecryptPanel().getTxtToEncrypt().getText())); + getEnDecryptPanel().getTxtEncrypted().setText( + model.getEncryptor().encrypt(getEnDecryptPanel().getTxtToEncrypt().getText())); getEnDecryptPanel().getTxtToEncrypt().setText(""); } catch (InvalidKeyException | NoSuchAlgorithmException | InvalidKeySpecException | NoSuchPaddingException | UnsupportedEncodingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("", e); } catch (final IllegalBlockSizeException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("", e); } catch (final BadPaddingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("", e); } catch (final IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("", e); } } diff --git a/mystic-crypt-ui/src/main/resources/help/Overview.htm b/mystic-crypt-ui/src/main/resources/help/Overview.htm index 972ea95f..ea0df2d0 100644 --- a/mystic-crypt-ui/src/main/resources/help/Overview.htm +++ b/mystic-crypt-ui/src/main/resources/help/Overview.htm @@ -31,28 +31,22 @@ content="JavaHelp Edition"> Overview - +

Overview

-

This application provides a very simple search for finding -duplicate files. It is simple to use. The user have to set only the two -directories which will be compared. You can set five file attributes how -the files are going to be compared.

-

Duplicate Files Finder Version 1.0

+

This application provides a demo what the cryptography library mystic-crypt can do.

+

mystic-crypt demo

+

Key features:

    -
  • Search for files with the same or similar filename
  • -
  • Compare arbitrary files byte by byte
  • -
  • Find duplicate large VIDEO or MP-3 files that shrinking your - harddrives and save money and time
  • -
  • Compare existing files collections and find doublets or even triplets
  • +
  • Encryption with PublicKey and decryption with PrivateKey objects that was generated with openssl

-

In companies administrators can seek the files from the employee for unnecessary file copies and redundant Backups. +

+The target of this parent project is to make encryption and decryption as simple as possible.

-

The comminity edition is free to download. The enterprise edition have more features and -can be purchased online.

+

The community edition is free to download.

diff --git a/pom.xml b/pom.xml index 094dba83..22cbb29e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ de.alpharogroup mvn-java-parent - 2.18.0 + 2.20.0 mystic-crypt - 4.18.0 + 4.19.0 pom 2015 diff --git a/randomizer/pom.xml b/randomizer/pom.xml index 8dab5731..55dd4774 100644 --- a/randomizer/pom.xml +++ b/randomizer/pom.xml @@ -5,7 +5,7 @@ de.alpharogroup mystic-crypt - 4.18.0 + 4.19.0 randomizer