use of org.freeplane.core.ui.components.EnterPasswordDialog in project freeplane by freeplane.
the class SignedScriptHandler method signScript.
public String signScript(final String pScript) {
final ScriptContents content = new ScriptContents(pScript);
final EnterPasswordDialog pwdDialog = new EnterPasswordDialog(UITools.getCurrentFrame(), false);
pwdDialog.setModal(true);
pwdDialog.setVisible(true);
if (pwdDialog.getResult() == EnterPasswordDialog.CANCEL) {
return content.mScript;
}
final char[] password = pwdDialog.getPassword().toString().toCharArray();
initializeKeystore(password);
try {
final Signature instance = Signature.getInstance("SHA1withDSA");
String keyName = FREEPLANE_SCRIPT_KEY_NAME;
final ResourceController resourceController = ResourceController.getResourceController();
String propertyKeyName = resourceController.getProperty(ScriptingPermissions.RESOURCES_SCRIPT_USER_KEY_NAME_FOR_SIGNING);
if (propertyKeyName == null || propertyKeyName.trim().length() == 0) {
resourceController.setProperty(ScriptingPermissions.RESOURCES_SCRIPT_USER_KEY_NAME_FOR_SIGNING, FREEPLANE_SCRIPT_KEY_NAME);
propertyKeyName = keyName;
}
if (content.mKeyName != null) {
keyName = content.mKeyName;
} else {
content.mKeyName = propertyKeyName;
keyName = content.mKeyName;
}
instance.initSign((PrivateKey) SignedScriptHandler.mKeyStore.getKey(keyName, password));
instance.update(content.mScript.getBytes());
final byte[] signature = instance.sign();
content.mSignature = DesEncrypter.toBase64(signature);
return content.toString();
} catch (final Exception e) {
if (!(e instanceof KeyStoreException))
LogUtils.severe(e);
UITools.errorMessage(e.getLocalizedMessage());
}
return content.mScript;
}
use of org.freeplane.core.ui.components.EnterPasswordDialog in project freeplane by freeplane.
the class EncryptedMap method getUsersPassword.
/**
* @param e
*/
private StringBuilder getUsersPassword() {
final EnterPasswordDialog pwdDialog = new EnterPasswordDialog(UITools.getCurrentFrame(), true);
pwdDialog.setModal(true);
pwdDialog.show();
if (pwdDialog.getResult() == EnterPasswordDialog.CANCEL) {
return null;
}
final StringBuilder password = pwdDialog.getPassword();
return password;
}
use of org.freeplane.core.ui.components.EnterPasswordDialog in project freeplane by freeplane.
the class SwingPasswordStrategy method getPasswordImpl.
private StringBuilder getPasswordImpl(boolean withConfirmation) {
final EnterPasswordDialog pwdDialog = new EnterPasswordDialog(UITools.getCurrentFrame(), withConfirmation);
pwdDialog.setModal(true);
pwdDialog.setVisible(true);
if (pwdDialog.getResult() == EnterPasswordDialog.CANCEL) {
isCancelled = true;
return null;
}
return pwdDialog.getPassword();
}
Aggregations