use of javax.swing.JPasswordField in project CIM-Identities by epri-dev.
the class Splash method jButton1ActionPerformed.
// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
this.dispose();
String URL = "jdbc:postgresql://localhost:5432/CIMIdentity";
String LoginID = "postgres";
JPasswordField pwd = new JPasswordField(10);
pwd.addHierarchyListener(new HierarchyListener() {
public void hierarchyChanged(HierarchyEvent e) {
final Component c = e.getComponent();
if (c.isShowing() && (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
Window toplevel = SwingUtilities.getWindowAncestor(c);
toplevel.addWindowFocusListener(new WindowAdapter() {
public void windowGainedFocus(WindowEvent e) {
c.requestFocus();
}
});
}
}
});
int action = JOptionPane.showConfirmDialog(null, pwd, "Enter Password", JOptionPane.OK_CANCEL_OPTION);
if (action < 0)
JOptionPane.showMessageDialog(null, "Cancel, X or escape key selected");
String passw = new String(pwd.getPassword());
Connection c = null;
Statement stmt = null;
Connection cc = null;
try {
c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/", LoginID, passw);
/* Now that we are connected to PostgreSQL, let's create
the database */
stmt = c.createStatement();
String sql = "CREATE DATABASE \"CIMIdentity\";";
stmt.executeUpdate(sql);
stmt.close();
c.close();
System.out.println("Opened database successfully");
stmt = null;
cc = DriverManager.getConnection(URL, LoginID, passw);
stmt = cc.createStatement();
String usql = "CREATE EXTENSION pgcrypto; " + "CREATE TABLE public.\"Identity\" " + "(id_pkey uuid NOT NULL DEFAULT gen_random_uuid(), " + " entry serial NOT NULL, " + "CONSTRAINT id_pkey PRIMARY KEY (id_pkey) )" + " WITH ( OIDS = FALSE); " + " ALTER TABLE public.\"Identity\"" + " OWNER to postgres;" + "CREATE TABLE public.\"IdentifiedObject\"" + "( io_pkey uuid NOT NULL, " + "CONSTRAINT io_pkey PRIMARY KEY (io_pkey), " + "CONSTRAINT io_idkey FOREIGN KEY (io_pkey) " + "REFERENCES public.\"Identity\" (id_pkey) MATCH SIMPLE " + "ON UPDATE CASCADE ON DELETE CASCADE )" + "WITH ( OIDS = FALSE);" + "ALTER TABLE public.\"IdentifiedObject\"" + "OWNER TO postgres;" + "CREATE TABLE public.\"Name\"" + "( n_pkey uuid NOT NULL, " + "n_name character varying NOT NULL, " + "CONSTRAINT n_pkey PRIMARY KEY (n_pkey), " + "CONSTRAINT n_idkey FOREIGN KEY (n_pkey)" + " REFERENCES public.\"Identity\" (id_pkey) MATCH SIMPLE" + " ON UPDATE CASCADE ON DELETE CASCADE" + ") WITH ( OIDS = FALSE );" + " ALTER TABLE public.\"Name\" OWNER TO postgres;" + " CREATE TABLE public.\"NameType\" " + " ( nt_pkey uuid NOT NULL, " + " nt_description character varying NOT NULL, " + " nt_name character varying NOT NULL, " + " CONSTRAINT nt_pkey PRIMARY KEY (nt_pkey), " + " CONSTRAINT nt_nkey FOREIGN KEY (nt_pkey) " + " REFERENCES public.\"Name\" (n_pkey) MATCH SIMPLE " + " ON UPDATE CASCADE ON DELETE CASCADE ) " + " WITH ( OIDS = FALSE ); " + " ALTER TABLE public.\"NameType\" OWNER TO postgres; " + " CREATE TABLE public.\"NameTypeAuthority\"" + " ( nta_pkey uuid NOT NULL, " + " nta_name character varying, " + " nta_description character varying NOT NULL, " + " CONSTRAINT nta_pkey PRIMARY KEY (nta_pkey), " + " CONSTRAINT nta_ntkey FOREIGN KEY (nta_pkey) " + " REFERENCES public.\"NameType\" (nt_pkey) MATCH SIMPLE " + " ON UPDATE CASCADE ON DELETE CASCADE )" + " WITH ( OIDS = FALSE ); " + " ALTER TABLE public.\"NameTypeAuthority\" " + " OWNER TO postgres;";
stmt.executeUpdate(usql);
stmt.close();
c.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getClass().getName() + ": " + e.getMessage());
System.exit(0);
}
JOptionPane.showMessageDialog(null, "Table created successfully!");
}
use of javax.swing.JPasswordField in project cytoscape-impl by cytoscape.
the class PrefsNetwork method makeProxyPanel.
private AntiAliasedPanel makeProxyPanel() {
AntiAliasedPanel panel = new AntiAliasedPanel("Proxy Settings");
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
setSizes(panel, new Dimension(580, 120));
fHost = new JTextField(25);
// new JTextField(5);
fPort = new RangedIntegerTextField(0, 9999, new Dimension(80, 27));
fUsername = new JTextField(15);
fPassword = new JPasswordField(15);
fType = new JComboBox<String>(proxyTypes);
setSizes(fType, new Dimension(100, 27));
components.put("proxy.host", fHost);
components.put("proxy.port", fPort);
components.put("proxy.username", fUsername);
components.put("proxy.password", fPassword);
components.put("proxy.server.type", fType);
JLabel[] labels = new JLabel[5];
Font labelFont = new Font(Font.SANS_SERIF, Font.PLAIN, 10);
for (int i = 0; i < 5; i++) {
labels[i] = new JLabel(strs[i]);
setSizes(labels[i], new Dimension(67, 27));
labels[i].setFont(labelFont);
labels[i].setHorizontalAlignment(SwingConstants.RIGHT);
labels[i].setOpaque(false);
}
Dimension SPACE = new Dimension(20, 20);
HBox lin0 = new HBox(true, false, labels[4], fType, Box.createHorizontalGlue());
HBox lin1 = new HBox(true, true, Box.createRigidArea(SPACE), labels[0], fHost, labels[1], fPort);
HBox lin2 = new HBox(true, true, labels[2], fUsername, labels[3], fPassword);
panel.add(new HBox(lin0));
panel.add(new HBox(lin1));
panel.add(new HBox(lin2));
return panel;
}
use of javax.swing.JPasswordField in project cytoscape-impl by cytoscape.
the class PrefsSecurity method makeRepositoryPanel.
AntiAliasedPanel makeRepositoryPanel() {
AntiAliasedPanel panel = new AntiAliasedPanel("Proxy Settings");
setSizes(panel, new Dimension(580, 120));
fHost = new JTextField(25);
// new JTextField(5);
fPort = new RangedIntegerTextField(0, 9999, new Dimension(80, 27));
fUsername = new JTextField(15);
fPassword = new JPasswordField(15);
components.put("proxy.host", fHost);
components.put("proxy.port", fPort);
components.put("proxy.username", fUsername);
components.put("proxy.password", fPassword);
JLabel[] labels = new JLabel[4];
Font labelFont = new Font(Font.SANS_SERIF, Font.PLAIN, 10);
for (int i = 0; i < 4; i++) {
labels[i] = new JLabel(strs[i]);
setSizes(labels[i], new Dimension(67, 27));
labels[i].setFont(labelFont);
labels[i].setHorizontalAlignment(SwingConstants.RIGHT);
labels[i].setOpaque(false);
}
Dimension SPACE = new Dimension(20, 20);
Box lin1 = Box.createHorizontalBox();
Box lin2 = Box.createHorizontalBox();
lin1.add(new HBox(true, true, Box.createRigidArea(SPACE), new BoxComponent(labels[0], fHost, new BoxComponent(labels[1], fPort))));
lin2.add(new HBox(true, true, new BoxComponent(labels[2], fUsername, new BoxComponent(labels[3], fPassword))));
panel.add(lin1);
panel.add(lin2);
return panel;
}
use of javax.swing.JPasswordField in project cytoscape-impl by cytoscape.
the class AbstractPrefsPanel method makeLabeledPassworldField.
// ---------------------------------
protected Component makeLabeledPassworldField(String prompt, String fld) {
Box line = Box.createHorizontalBox();
JLabel lab = new JLabel(prompt);
setSizes(lab, 150, 30);
line.add(lab);
JPasswordField choices = new JPasswordField();
line.add(choices);
line.setMaximumSize(new Dimension(500, 30));
return line;
}
use of javax.swing.JPasswordField in project compss by bsc-wdc.
the class LfnFileCopy method getPassphrase.
// Ask the user for the password needed to perform grid-proxy-init
private static String getPassphrase() {
JPasswordField pwd = new JPasswordField();
Object[] message = { "grid-proxy-init\nPlease enter your passphrase.", pwd };
JOptionPane.showMessageDialog(null, message, "Grid-Proxy-Init", JOptionPane.QUESTION_MESSAGE);
return new String(pwd.getPassword());
}
Aggregations