use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class DPolicyInformationChooser method okPressed.
private void okPressed() {
ASN1ObjectIdentifier policyIdentifer = joiPolicyIdentifier.getObjectId();
if (policyIdentifer == null) {
JOptionPane.showMessageDialog(this, res.getString("DPolicyInformationChooser.PolicyIdentifierValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
List<PolicyQualifierInfo> policyQualifierInfo = jpqPolicyQualifiers.getPolicyQualifierInfo();
if (policyQualifierInfo.size() > 0) {
ASN1EncodableVector policyQualifiersVec = new ASN1EncodableVector();
for (PolicyQualifierInfo policyQualInfo : policyQualifierInfo) {
try {
policyQualifiersVec.add(policyQualInfo);
} catch (Exception ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
return;
}
}
DERSequence policyQualifiersSeq = new DERSequence(policyQualifiersVec);
policyInformation = new PolicyInformation(policyIdentifer, policyQualifiersSeq);
} else {
policyInformation = new PolicyInformation(policyIdentifer);
}
closeDialog();
}
use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class JPolicyQualifierInfo method editSelectedPolicQualifier.
private void editSelectedPolicQualifier() {
int selectedRow = jtPolicyQualifierInfo.getSelectedRow();
if (selectedRow != -1) {
PolicyQualifierInfo policyQualInfo = (PolicyQualifierInfo) jtPolicyQualifierInfo.getValueAt(selectedRow, 0);
Container container = getTopLevelAncestor();
try {
DPolicyQualifierInfoChooser dPolicyQualifierInfoChooser = null;
if (container instanceof JDialog) {
dPolicyQualifierInfoChooser = new DPolicyQualifierInfoChooser((JDialog) container, title, policyQualInfo);
dPolicyQualifierInfoChooser.setLocationRelativeTo(container);
dPolicyQualifierInfoChooser.setVisible(true);
} else if (container instanceof JFrame) {
dPolicyQualifierInfoChooser = new DPolicyQualifierInfoChooser((JFrame) container, title, policyQualInfo);
dPolicyQualifierInfoChooser.setLocationRelativeTo(container);
dPolicyQualifierInfoChooser.setVisible(true);
}
PolicyQualifierInfo newPolicyQualifierInfo = dPolicyQualifierInfoChooser.getPolicyQualifierInfo();
if (newPolicyQualifierInfo == null) {
return;
}
policyQualifierInfo.remove(policyQualInfo);
policyQualifierInfo.add(newPolicyQualifierInfo);
populate();
selectPolicyQualifierInfoInTable(newPolicyQualifierInfo);
} catch (IOException ex) {
DError dError = null;
if (container instanceof JDialog) {
dError = new DError((JDialog) container, ex);
} else {
dError = new DError((JFrame) container, ex);
}
dError.setLocationRelativeTo(container);
dError.setVisible(true);
}
}
}
use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class DGeneralNameChooser method okPressed.
private void okPressed() {
try {
GeneralName newGeneralName = null;
if (jrbDirectoryName.isSelected()) {
X500Name directoryName = jdnDirectoryName.getDistinguishedName();
if (directoryName == null) {
JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.DirectoryNameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
newGeneralName = new GeneralName(GeneralName.directoryName, directoryName);
} else if (jrbDnsName.isSelected()) {
String dnsName = jtfDnsName.getText().trim();
if (dnsName.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.DnsNameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
newGeneralName = new GeneralName(GeneralName.dNSName, new DERIA5String(dnsName));
} else if (jrbIpAddress.isSelected()) {
String ipAddress = jtfIpAddress.getText().trim();
if (ipAddress.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.IpAddressValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
if (!IPAddress.isValid(ipAddress)) {
JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.NotAValidIP.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
newGeneralName = new GeneralName(GeneralName.iPAddress, ipAddress);
} else if (jrbRegisteredId.isSelected()) {
ASN1ObjectIdentifier registeredId = joiRegisteredId.getObjectId();
if (registeredId == null) {
JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.RegisteredIdValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
newGeneralName = new GeneralName(GeneralName.registeredID, registeredId);
} else if (jrbRfc822Name.isSelected()) {
String rfc822Name = jtfRfc822Name.getText().trim();
if (rfc822Name.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.Rfc822NameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
newGeneralName = new GeneralName(GeneralName.rfc822Name, new DERIA5String(rfc822Name));
} else if (jrbUniformResourceIdentifier.isSelected()) {
String uniformResourceIdentifier = jtfUniformResourceIdentifier.getText().trim();
if (uniformResourceIdentifier.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.UniformResourceIdentifierValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
newGeneralName = new GeneralName(GeneralName.uniformResourceIdentifier, new DERIA5String(uniformResourceIdentifier));
} else if (jrbPrincipalName.isSelected()) {
String upnString = jtfPrincipalName.getText().trim();
if (upnString.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.PrincipalNameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
ASN1EncodableVector asn1Vector = new ASN1EncodableVector();
asn1Vector.add(new ASN1ObjectIdentifier(GeneralNameUtil.UPN_OID));
asn1Vector.add(new DERTaggedObject(true, 0, new DERUTF8String(upnString)));
newGeneralName = new GeneralName(GeneralName.otherName, new DERSequence(asn1Vector));
}
generalName = newGeneralName;
} catch (Exception ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
return;
}
closeDialog();
}
use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class KSE method main.
/**
* Start the KeyStore Explorer application. Takes one optional argument -
* the location of a KeyStore file to open upon startup.
*
* @param args
* the command line arguments
*/
public static void main(String[] args) {
try {
// To take affect these must be set before the splash screen is instantiated
if (OperatingSystem.isMacOs()) {
setAppleSystemProperties();
} else if (OperatingSystem.isWindows7() || OperatingSystem.isWindows8() || OperatingSystem.isWindows10()) {
String appId = props.getString("KSE.AppUserModelId");
Shell32 shell32 = (Shell32) Native.loadLibrary("shell32", Shell32.class);
shell32.SetCurrentProcessExplicitAppUserModelID(new WString(appId)).longValue();
} else if (OperatingSystem.isLinux()) {
fixAppClassName();
}
setInstallDirProperty();
SplashScreen splash = SplashScreen.getSplashScreen();
updateSplashMessage(splash, res.getString("KSE.LoadingApplicationSettings.splash.message"));
ApplicationSettings applicationSettings = ApplicationSettings.getInstance();
setCurrentDirectory(applicationSettings);
updateSplashMessage(splash, res.getString("KSE.InitializingSecurity.splash.message"));
initialiseSecurity();
// list of files to open after start
List<File> parameterFiles = new ArrayList<File>();
for (String arg : args) {
File parameterFile = new File(arg);
if (parameterFile.exists()) {
parameterFiles.add(parameterFile);
}
}
// Create application GUI on the event handler thread
updateSplashMessage(splash, res.getString("KSE.CreatingApplicationGui.splash.message"));
SwingUtilities.invokeLater(new CreateApplicationGui(applicationSettings, splash, parameterFiles));
} catch (Throwable t) {
DError dError = new DError(new JFrame(), t);
dError.setLocationRelativeTo(null);
dError.setVisible(true);
System.exit(1);
}
}
use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class JObjectId method editObjectId.
private void editObjectId() {
Container container = getTopLevelAncestor();
try {
DObjectIdChooser dObjectIdChooser = null;
if (container instanceof JDialog) {
dObjectIdChooser = new DObjectIdChooser((JDialog) container, title, objectId);
dObjectIdChooser.setLocationRelativeTo(container);
dObjectIdChooser.setVisible(true);
} else if (container instanceof JFrame) {
dObjectIdChooser = new DObjectIdChooser((JFrame) container, title, objectId);
dObjectIdChooser.setLocationRelativeTo(container);
dObjectIdChooser.setVisible(true);
}
ASN1ObjectIdentifier newObjectId = dObjectIdChooser.getObjectId();
if (newObjectId == null) {
return;
}
setObjectId(newObjectId);
} catch (InvalidObjectIdException ex) {
DError dError = null;
if (container instanceof JDialog) {
dError = new DError((JDialog) container, ex);
} else {
dError = new DError((JFrame) container, ex);
}
dError.setLocationRelativeTo(container);
dError.setVisible(true);
}
}
Aggregations