PasswordParameterpublic class PasswordParameter extends Parameter
Fields Summary |
---|
String | name | org.eclipse.swt.widgets.Text | inputField |
Constructors Summary |
---|
public PasswordParameter(org.eclipse.swt.widgets.Composite composite, String name)
this( composite, name, org.gudy.azureus2.plugins.ui.config.PasswordParameter.ET_SHA1 );
| public PasswordParameter(org.eclipse.swt.widgets.Composite composite, String name, int encoding)
super(name);
this.name = name;
inputField = new Text(composite, SWT.BORDER);
inputField.setEchoChar('*");
byte[] value = COConfigurationManager.getByteParameter(name, "".getBytes());
if(value.length > 0)
inputField.setText("***");
inputField.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
try{
String password_string = inputField.getText();
byte[] password = password_string.getBytes();
byte[] encoded;
if(password.length > 0 ){
if ( encoding == org.gudy.azureus2.plugins.ui.config.PasswordParameter.ET_PLAIN ){
encoded = password;
}else if ( encoding == org.gudy.azureus2.plugins.ui.config.PasswordParameter.ET_SHA1 ){
SHA1Hasher hasher = new SHA1Hasher();
encoded = hasher.calculateHash(password);
}else{
// newly added, might as well go for UTF-8
encoded = MessageDigest.getInstance( "md5").digest( password_string.getBytes( "UTF-8" ));
}
}else{
encoded = password;
}
COConfigurationManager.setParameter(name, encoded);
} catch(Exception e) {
Debug.printStackTrace( e );
}
}
});
|
Methods Summary |
---|
public org.eclipse.swt.widgets.Control | getControl()
return inputField;
| public java.lang.String | getValue()
return inputField.getText();
| public void | setLayoutData(java.lang.Object layoutData)
inputField.setLayoutData(layoutData);
| public void | setValue(java.lang.String value)
Utils.execSWTThread(new AERunnable() {
public void runSupport() {
if (inputField == null || inputField.isDisposed()
|| inputField.getText().equals(value)) {
return;
}
inputField.setText(value);
}
});
if (!COConfigurationManager.getParameter(name).equals(value)) {
COConfigurationManager.setParameter(name, value);
}
| public void | setValue(java.lang.Object value)
if (value instanceof String) {
setValue((String)value);
}
|
|