本文整理汇总了Java中com.rapidminer.tools.cipher.CipherTools类的典型用法代码示例。如果您正苦于以下问题:Java CipherTools类的具体用法?Java CipherTools怎么用?Java CipherTools使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CipherTools类属于com.rapidminer.tools.cipher包,在下文中一共展示了CipherTools类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FieldConnectionEntry
import com.rapidminer.tools.cipher.CipherTools; //导入依赖的package包/类
public FieldConnectionEntry(Element element, Key key) throws CipherException {
this.name = XMLTools.getTagContents(element, "name");
this.host = XMLTools.getTagContents(element, "host");
this.port = XMLTools.getTagContents(element, "port");
this.database = XMLTools.getTagContents(element, "database");
this.user = XMLTools.getTagContents(element, "user");
this.password = CipherTools.decrypt(XMLTools.getTagContents(element, "password"), key).toCharArray();
String system = XMLTools.getTagContents(element, "system");
if (system != null) {
properties = DatabaseService.getJDBCProperties(system);
}
try {
Element propertiesElement = XMLTools.getChildElement(element, "properties", true);
Properties props = new Properties();
for (Element singlePropElement : XMLTools.getChildElements(propertiesElement)) {
props.put(singlePropElement.getTagName(), singlePropElement.getTextContent());
}
this.connectionProperties = props;
} catch (XMLException e) {
// old connections may not yet have properties element
this.connectionProperties = new Properties();
}
}
示例2: toXML
import com.rapidminer.tools.cipher.CipherTools; //导入依赖的package包/类
public Element toXML(Document doc, Key key, String replacementForLocalhost) throws CipherException {
Element element = doc.createElement("field-entry");
XMLTools.setTagContents(element, "name", this.name);
if(this.properties != null) {
XMLTools.setTagContents(element, "system", this.properties.getName());
}
String host = this.host;
if(replacementForLocalhost != null) {
host = host.replace("localhost", replacementForLocalhost);
}
XMLTools.setTagContents(element, "host", host);
XMLTools.setTagContents(element, "port", this.port);
XMLTools.setTagContents(element, "database", this.database);
XMLTools.setTagContents(element, "property", this.property);
XMLTools.setTagContents(element, "user", this.user);
XMLTools.setTagContents(element, "password", CipherTools.encrypt(new String(this.password), key));
Element propertiesElement = doc.createElement("properties");
element.appendChild(propertiesElement);
Iterator var7 = this.connectionProperties.keySet().iterator();
while(var7.hasNext()) {
Object propKey = var7.next();
Element singlePropElement = doc.createElement(String.valueOf(propKey));
singlePropElement.setTextContent(String.valueOf(this.connectionProperties.get(propKey)));
propertiesElement.appendChild(singlePropElement);
}
return element;
}
示例3: FieldConnectionEntry
import com.rapidminer.tools.cipher.CipherTools; //导入依赖的package包/类
public FieldConnectionEntry(Element element, Key key) throws CipherException {
this.name = XMLTools.getTagContents(element, "name");
this.host = XMLTools.getTagContents(element, "host");
this.port = XMLTools.getTagContents(element, "port");
this.database = XMLTools.getTagContents(element, "database");
this.property = XMLTools.getTagContents(element, "property");
this.user = XMLTools.getTagContents(element, "user");
this.password = CipherTools.decrypt(XMLTools.getTagContents(element, "password"), key).toCharArray();
String system = XMLTools.getTagContents(element, "system");
if(system != null) {
this.properties = DatabaseService.getJDBCProperties(system);
}
try {
Element e = XMLTools.getChildElement(element, "properties", true);
Properties props = new Properties();
Iterator var6 = XMLTools.getChildElements(e).iterator();
while(var6.hasNext()) {
Element singlePropElement = (Element)var6.next();
props.put(singlePropElement.getTagName(), singlePropElement.getTextContent());
}
this.connectionProperties = props;
} catch (XMLException var8) {
this.connectionProperties = new Properties();
}
}
示例4: getAuthentication
import com.rapidminer.tools.cipher.CipherTools; //导入依赖的package包/类
@Override
public PasswordAuthentication getAuthentication(URL url) throws PasswordInputCanceledException {
if (url.getProtocol().equals(protocol)) {
String username = ParameterService.getParameterValue(protocol + ".proxyUsername");
String password = ParameterService.getParameterValue(protocol + ".proxyPassword");
// password is stored encrypted, try to decrypt password
if (password != null && CipherTools.isKeyAvailable()) {
try {
password = CipherTools.decrypt(password);
} catch (CipherException e) {
// password is in plaintext
}
}
if (username == null || username.isEmpty() || password == null) { // empty
// passwords
// possibly
// valid!
PasswordAuthentication passwordAuthentication = PasswordDialog.getPasswordAuthentication("proxy for "
+ url.toString(), true, false);
if (passwordAuthentication == null) {
return null;
}
ParameterService.setParameterValue(protocol + ".proxyUsername", passwordAuthentication.getUserName());
ParameterService.setParameterValue(protocol + ".proxyPassword",
new String(passwordAuthentication.getPassword()));
ParameterService.saveParameters();
return passwordAuthentication;
}
return new PasswordAuthentication(username, password.toCharArray());
}
return null;
}
示例5: encryptPassword
import com.rapidminer.tools.cipher.CipherTools; //导入依赖的package包/类
private String encryptPassword(String value) {
if (CipherTools.isKeyAvailable()) {
try {
return CipherTools.encrypt(value);
} catch (CipherException e) {
LogService.getRoot().log(Level.SEVERE,
"com.rapidminer.parameter.ParameterTypePassword.encrypting_password_error");
return value;
}
} else {
return value;
}
}
示例6: decryptPassword
import com.rapidminer.tools.cipher.CipherTools; //导入依赖的package包/类
private String decryptPassword(String value) {
if (CipherTools.isKeyAvailable()) {
try {
return CipherTools.decrypt(value);
} catch (CipherException e) {
LogService.getRoot().log(Level.FINE,
"com.rapidminer.parameter.ParameterTypePassword.password_looks_like_unencrypted_plain_text");
}
}
return value;
}
示例7: getAuthentication
import com.rapidminer.tools.cipher.CipherTools; //导入依赖的package包/类
public PasswordAuthentication getAuthentication(URL url, String i18n, boolean forceRefresh)
throws PasswordInputCanceledException {
if (protocol.equals(SOCKS) || url.getProtocol().equals(protocol)) {
// password is stored encrypted, try to decrypt password
if (password != null && CipherTools.isKeyAvailable()) {
try {
password = CipherTools.decrypt(password);
} catch (CipherException e) {
// password is in plaintext
}
}
if (username == null || username.isEmpty() || password == null) { // empty
// passwords
// possibly
// valid!
String proxyType = protocol.toUpperCase();
String proxyID = I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.auth.proxy.id", proxyType);
String proxyURL = getProxyAddress().toString().replaceAll("/", "");
String authMessage = getAuthMessage();
PasswordAuthentication passwordAuthentication = PasswordDialog.getPasswordAuthentication(proxyID,
proxyURL, forceRefresh, true, i18n, proxyType, proxyURL, authMessage);
if (passwordAuthentication == null) {
return null;
}
username = passwordAuthentication.getUserName();
password = new String(passwordAuthentication.getPassword());
// Verify Settings
passwordAuthentication = verify(url, passwordAuthentication);
return passwordAuthentication;
}
return new PasswordAuthentication(username, password.toCharArray());
}
return null;
}
示例8: encryptPassword
import com.rapidminer.tools.cipher.CipherTools; //导入依赖的package包/类
private String encryptPassword(String value) {
if (CipherTools.isKeyAvailable()) {
try {
return CipherTools.encrypt(value);
} catch (CipherException e) {
//LogService.getGlobal().logError("Cannot encrypt password, using non-encrypted password!");
LogService.getRoot().log(Level.SEVERE, "com.rapidminer.parameter.ParameterTypePassword.encrypting_password_error");
return value;
}
} else {
return value;
}
}
示例9: decryptPassword
import com.rapidminer.tools.cipher.CipherTools; //导入依赖的package包/类
private String decryptPassword(String value) {
if (CipherTools.isKeyAvailable()) {
try {
return CipherTools.decrypt(value);
} catch (CipherException e) {
//LogService.getRoot().warning("Password in XML file looks like unencrypted plain text.");
LogService.getRoot().log(Level.WARNING, "com.rapidminer.parameter.ParameterTypePassword.password_looks_like_unencrypted_plain_text");
}
}
return value;
}
示例10: toXMLString
import com.rapidminer.tools.cipher.CipherTools; //导入依赖的package包/类
@Override
public String toXMLString(String value) {
try {
return CipherTools.encrypt(value);
} catch (CipherException e) {
//LogService.getGlobal().logError("Cannot encrypt password, using non-encrypted password in XML!");
LogService.getRoot().log(Level.SEVERE, "com.rapidminer.parameter.ParameterTypePassword.encrypting_password_error");
return value;
}
}
示例11: toXML
import com.rapidminer.tools.cipher.CipherTools; //导入依赖的package包/类
public Element toXML(Document doc, Key key, String replacementForLocalhost) throws CipherException {
Element element = doc.createElement(XML_TAG_NAME);
XMLTools.setTagContents(element, "name", name);
if (properties != null) {
XMLTools.setTagContents(element, "system", properties.getName());
}
String host = this.host;
if (replacementForLocalhost != null) {
host = host.replace("localhost", replacementForLocalhost);
}
XMLTools.setTagContents(element, "host", host);
XMLTools.setTagContents(element, "port", port);
XMLTools.setTagContents(element, "database", database);
XMLTools.setTagContents(element, "user", user);
XMLTools.setTagContents(element, "password", CipherTools.encrypt(new String(password), key));
// add connection properties
Element propertiesElement = doc.createElement("properties");
element.appendChild(propertiesElement);
for (Object propKey : connectionProperties.keySet()) {
Element singlePropElement = doc.createElement(String.valueOf(propKey));
singlePropElement.setTextContent(String.valueOf(connectionProperties.get(propKey)));
propertiesElement.appendChild(singlePropElement);
}
return element;
}