📄 configsectionsecurity.java
字号:
}
}
{
this$1 = 6.this;
me = cryptomanagerkeylistener;
handler = cryptohandler;
super();
}
});
}
public void keyLockStatusChanged(CryptoHandler cryptohandler)
{
}
{
this$0 = ConfigSectionSecurity.this;
public_key_value = label;
crypt_man = cryptomanager;
crypto_group = group;
super();
}
});
new Label(crypto_group, 0);
gridData = new GridData();
gridData.horizontalSpan = 3;
final BooleanParameter manage_keys = new BooleanParameter(crypto_group, "crypto.keys.system.managed.temp", "ConfigView.section.security.system.managed");
manage_keys.setLayoutData(gridData);
CryptoManager crypto_man = CryptoManagerFactory.getSingleton();
final CryptoHandler ecc_handler = crypto_man.getECCHandler();
manage_keys.setSelected(ecc_handler.getDefaultPasswordHandlerType() == 2);
manage_keys.addChangeListener(new ParameterChangeAdapter() {
final CryptoHandler val$ecc_handler;
final BooleanParameter val$manage_keys;
final ConfigSectionSecurity this$0;
public void parameterChanged(Parameter p, boolean caused_internally)
{
boolean existing_value = ecc_handler.getDefaultPasswordHandlerType() == 2;
if (existing_value == manage_keys.isSelected())
return;
String error = null;
int new_type = manage_keys.isSelected() ? 2 : 1;
try
{
ecc_handler.setDefaultPasswordHandlerType(new_type);
error = null;
}
catch (CryptoManagerPasswordException e)
{
if (e.wasIncorrect())
error = MessageText.getString("ConfigView.section.security.unlockkey.error");
else
if (existing_value || !ecc_handler.isUnlocked())
error = MessageText.getString("Torrent.create.progress.cancelled");
else
error = MessageText.getString("ConfigView.section.security.vuze.login");
}
catch (Throwable e)
{
error = Debug.getNestedExceptionMessage(e);
}
if (error != null)
Utils.openMessageBox(manage_keys.getControl().getShell(), 33, MessageText.getString("ConfigView.section.security.op.error.title"), MessageText.getString("ConfigView.section.security.op.error", new String[] {
error
}));
boolean new_value = ecc_handler.getDefaultPasswordHandlerType() == 2;
if (new_value != manage_keys.isSelected())
manage_keys.setSelected(new_value);
}
{
this$0 = ConfigSectionSecurity.this;
ecc_handler = cryptohandler;
manage_keys = booleanparameter;
super();
}
});
Label reset_key_label = new Label(crypto_group, 0);
Messages.setLanguageText(reset_key_label, "ConfigView.section.security.resetkey");
Button reset_key_button = new Button(crypto_group, 8);
Messages.setLanguageText(reset_key_button, "ConfigView.section.security.clearpasswords.button");
reset_key_button.addListener(13, new Listener() {
final Composite val$parent;
final CryptoManager val$crypt_man;
final ConfigSectionSecurity this$0;
public void handleEvent(Event event)
{
if (Utils.openMessageBox(parent.getShell(), 296, 256, MessageText.getString("ConfigView.section.security.resetkey.warning.title"), MessageText.getString("ConfigView.section.security.resetkey.warning")) == 32)
try
{
crypt_man.getECCHandler().resetKeys("Manual key reset");
}
catch (Throwable e)
{
Utils.openMessageBox(parent.getShell(), 33, MessageText.getString("ConfigView.section.security.resetkey.error.title"), getError(e));
}
}
{
this$0 = ConfigSectionSecurity.this;
parent = composite;
crypt_man = cryptomanager;
super();
}
});
new Label(crypto_group, 0);
Label priv_key_label = new Label(crypto_group, 0);
Messages.setLanguageText(priv_key_label, "ConfigView.section.security.unlockkey");
Button priv_key_button = new Button(crypto_group, 8);
Messages.setLanguageText(priv_key_button, "ConfigView.section.security.unlockkey.button");
priv_key_button.addListener(13, new Listener() {
final CryptoManager val$crypt_man;
final Composite val$parent;
final ConfigSectionSecurity this$0;
public void handleEvent(Event event)
{
try
{
crypt_man.getECCHandler().getEncryptedPrivateKey("Manual unlock");
}
catch (Throwable e)
{
Utils.openMessageBox(parent.getShell(), 33, MessageText.getString("ConfigView.section.security.resetkey.error.title"), getError(e));
}
}
{
this$0 = ConfigSectionSecurity.this;
crypt_man = cryptomanager;
parent = composite;
super();
}
});
new Label(crypto_group, 0);
Label backup_keys_label = new Label(crypto_group, 0);
Messages.setLanguageText(backup_keys_label, "ConfigView.section.security.backupkeys");
final Button backup_keys_button = new Button(crypto_group, 8);
Messages.setLanguageText(backup_keys_button, "ConfigView.section.security.backupkeys.button");
backup_keys_button.addListener(13, new Listener() {
final Button val$backup_keys_button;
final CryptoManager val$crypt_man;
final ConfigSectionSecurity this$0;
public void handleEvent(Event event)
{
FileDialog dialog = new FileDialog(backup_keys_button.getShell(), 0x10000);
String target = dialog.open();
if (target != null)
try
{
String keys = crypt_man.getECCHandler().exportKeys();
PrintWriter pw = new PrintWriter(new FileWriter(target));
pw.println(keys);
pw.close();
}
catch (Throwable e)
{
Utils.openMessageBox(backup_keys_button.getShell(), 33, MessageText.getString("ConfigView.section.security.op.error.title"), MessageText.getString("ConfigView.section.security.op.error", new String[] {
getError(e)
}));
}
}
{
this$0 = ConfigSectionSecurity.this;
backup_keys_button = button;
crypt_man = cryptomanager;
super();
}
});
new Label(crypto_group, 0);
Label restore_keys_label = new Label(crypto_group, 0);
Messages.setLanguageText(restore_keys_label, "ConfigView.section.security.restorekeys");
Button restore_keys_button = new Button(crypto_group, 8);
Messages.setLanguageText(restore_keys_button, "ConfigView.section.security.restorekeys.button");
restore_keys_button.addListener(13, new Listener() {
final Button val$backup_keys_button;
final CryptoManager val$crypt_man;
final ConfigSectionSecurity this$0;
public void handleEvent(Event event)
{
FileDialog dialog = new FileDialog(backup_keys_button.getShell(), 0x10000);
String target = dialog.open();
if (target != null)
try
{
LineNumberReader reader = new LineNumberReader(new FileReader(target));
String str = "";
do
{
String line = reader.readLine();
if (line == null)
break;
str = (new StringBuilder()).append(str).append(line).append("\r\n").toString();
} while (true);
boolean restart = crypt_man.getECCHandler().importKeys(str);
if (restart)
{
Utils.openMessageBox(backup_keys_button.getShell(), 34, MessageText.getString("ConfigView.section.security.restart.title"), MessageText.getString("ConfigView.section.security.restart.msg"));
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null)
uiFunctions.dispose(true, false);
}
}
catch (Throwable e)
{
Utils.openMessageBox(backup_keys_button.getShell(), 33, MessageText.getString("ConfigView.section.security.op.error.title"), MessageText.getString("ConfigView.section.security.op.error", new String[] {
getError(e)
}));
}
}
{
this$0 = ConfigSectionSecurity.this;
backup_keys_button = button;
crypt_man = cryptomanager;
super();
}
});
new Label(crypto_group, 0);
}
return gSecurity;
}
protected String getError(Throwable e)
{
String error;
if (e instanceof CryptoManagerPasswordException)
{
if (((CryptoManagerPasswordException)e).wasIncorrect())
{
error = MessageText.getString("ConfigView.section.security.unlockkey.error");
} else
{
CryptoManager crypto_man = CryptoManagerFactory.getSingleton();
CryptoHandler ecc_handler = crypto_man.getECCHandler();
if (ecc_handler.getDefaultPasswordHandlerType() == 2)
error = MessageText.getString("ConfigView.section.security.nopw_v");
else
error = MessageText.getString("ConfigView.section.security.nopw");
}
} else
{
error = (new StringBuilder()).append(MessageText.getString("ConfigView.section.security.resetkey.error")).append(": ").append(Debug.getNestedExceptionMessage(e)).toString();
}
return error;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -