[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[tm-cvs-commit] ddykstal org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core PasswordPersistenceManager.java
|
- From: Eclipse CVS Genie <genie@xxxxxxxxxxx>
- Date: Tue, 13 Mar 2012 02:25:45 +0000
- Delivered-to: tm-cvs-commit@eclipse.org
Update of /cvsroot/tools/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core
In directory dev1:/tmp/cvs-serv5611/src/org/eclipse/rse/core
Modified Files:
PasswordPersistenceManager.java
Log Message:
[225320] Formatting module prior to adding code for secure storage - no code changes.
Index: PasswordPersistenceManager.java
===================================================================
RCS file: /cvsroot/tools/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/PasswordPersistenceManager.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** PasswordPersistenceManager.java 23 Apr 2008 21:07:50 -0000 1.14
--- PasswordPersistenceManager.java 13 Mar 2012 02:25:42 -0000 1.15
***************
*** 39,43 ****
import org.eclipse.rse.internal.core.RSECoreMessages;
-
/**
* PasswordPersistenceManager manages the saving and retrieving of user ID /
--- 39,42 ----
***************
*** 56,60 ****
private static final String SERVER_URL = "file://rse"; //$NON-NLS-1$
! private static final String AUTH_SCHEME = ""; // no authorization scheme specified for apis //$NON-NLS-1$
// Add return codes
--- 55,59 ----
private static final String SERVER_URL = "file://rse"; //$NON-NLS-1$
! private static final String AUTH_SCHEME = ""; // no authorization scheme specified for apis //$NON-NLS-1$
// Add return codes
***************
*** 88,107 ****
* Default System Type
*/
! private static class DefaultSystemType extends AbstractRSESystemType implements IRSESystemType
! {
private static final String DEFAULT_ID = "DEFAULT"; //$NON-NLS-1$
private DefaultSystemType() {
super(DEFAULT_ID, DEFAULT_ID, RSECoreMessages.DefaultSystemType_Label, null, null);
}
public String getId() {
//TODO consider a space character at the beginning to ensure uniqueness
return DEFAULT_ID;
}
public String[] getSubsystemConfigurationIds() {
return null;
}
public Object getAdapter(Class adapter) {
return null;
}
public boolean isEnabled() {
return true;
--- 87,110 ----
* Default System Type
*/
! private static class DefaultSystemType extends AbstractRSESystemType implements IRSESystemType {
private static final String DEFAULT_ID = "DEFAULT"; //$NON-NLS-1$
+
private DefaultSystemType() {
super(DEFAULT_ID, DEFAULT_ID, RSECoreMessages.DefaultSystemType_Label, null, null);
}
+
public String getId() {
//TODO consider a space character at the beginning to ensure uniqueness
return DEFAULT_ID;
}
+
public String[] getSubsystemConfigurationIds() {
return null;
}
+
public Object getAdapter(Class adapter) {
return null;
}
+
public boolean isEnabled() {
return true;
***************
*** 112,122 ****
* Inner class used for storing registered system types
*/
! private class RegisteredSystemType
! {
private IRSESystemType _systemType;
private boolean _userIDCaseSensitive;
! protected RegisteredSystemType(IRSESystemType systemType, boolean caseSensitive)
! {
_systemType = systemType;
_userIDCaseSensitive = caseSensitive;
--- 115,123 ----
* Inner class used for storing registered system types
*/
! private class RegisteredSystemType {
private IRSESystemType _systemType;
private boolean _userIDCaseSensitive;
! protected RegisteredSystemType(IRSESystemType systemType, boolean caseSensitive) {
_systemType = systemType;
_userIDCaseSensitive = caseSensitive;
***************
*** 143,147 ****
* Singleton so private constructor
*/
! private PasswordPersistenceManager(){
String userName = System.getProperty("user.name"); //$NON-NLS-1$
--- 144,148 ----
* Singleton so private constructor
*/
! private PasswordPersistenceManager() {
String userName = System.getProperty("user.name"); //$NON-NLS-1$
***************
*** 156,163 ****
* Retrieve the singleton instance of the PasswordPersistenceManger
*/
! public static final synchronized PasswordPersistenceManager getInstance()
! {
! if (_instance == null)
! {
_instance = new PasswordPersistenceManager();
_instance.initExtensions();
--- 157,162 ----
* Retrieve the singleton instance of the PasswordPersistenceManger
*/
! public static final synchronized PasswordPersistenceManager getInstance() {
! if (_instance == null) {
_instance = new PasswordPersistenceManager();
_instance.initExtensions();
***************
*** 169,174 ****
* initialization - register system types
*/
! private void initExtensions()
! {
IRSESystemType[] sysTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes();
systemTypes = new RegisteredSystemType[sysTypes.length];
--- 168,172 ----
* initialization - register system types
*/
! private void initExtensions() {
IRSESystemType[] sysTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes();
systemTypes = new RegisteredSystemType[sysTypes.length];
***************
*** 183,188 ****
* user ID from the SystemSignonInfo parameter.
*/
! public void remove(SystemSignonInformation info)
! {
remove(info.getSystemType(), info.getHostname(), info.getUserId());
}
--- 181,185 ----
* user ID from the SystemSignonInfo parameter.
*/
! public void remove(SystemSignonInformation info) {
remove(info.getSystemType(), info.getHostname(), info.getUserId());
}
***************
*** 242,247 ****
* and userid.
*/
! public boolean passwordExists(IRSESystemType systemtype, String hostname, String userid)
! {
return passwordExists(systemtype, hostname, userid, true);
--- 239,243 ----
* and userid.
*/
! public boolean passwordExists(IRSESystemType systemtype, String hostname, String userid) {
return passwordExists(systemtype, hostname, userid, true);
***************
*** 257,262 ****
* @param checkDefault Whether or not to check for a default system type if the specified system type is not found.
*/
! public boolean passwordExists(IRSESystemType systemtype, String hname, String userid, boolean checkDefault)
! {
String hostname = hname;//RSEUIPlugin.getQualifiedHostName(hname);
return (find(systemtype, hostname, userid) != null);
--- 253,257 ----
* @param checkDefault Whether or not to check for a default system type if the specified system type is not found.
*/
! public boolean passwordExists(IRSESystemType systemtype, String hname, String userid, boolean checkDefault) {
String hostname = hname;//RSEUIPlugin.getQualifiedHostName(hname);
return (find(systemtype, hostname, userid) != null);
***************
*** 330,340 ****
* Retrieve the password map from the keyring for the specified system type
*/
! private Map getPasswordMap(IRSESystemType systemType)
! {
Map passwords = null;
String systemTypeId = systemType.getId();
! try
! {
URL serverURL = new URL(newURL);
passwords = Platform.getAuthorizationInfo(serverURL, systemTypeId, AUTH_SCHEME);
--- 325,333 ----
* Retrieve the password map from the keyring for the specified system type
*/
! private Map getPasswordMap(IRSESystemType systemType) {
Map passwords = null;
String systemTypeId = systemType.getId();
! try {
URL serverURL = new URL(newURL);
passwords = Platform.getAuthorizationInfo(serverURL, systemTypeId, AUTH_SCHEME);
***************
*** 361,366 ****
}
}
! }
! catch (MalformedURLException e) {
RSECorePlugin.getDefault().getLogger().logError("PasswordPersistenceManager.getPasswordMap", e); //$NON-NLS-1$
}
--- 354,358 ----
}
}
! } catch (MalformedURLException e) {
RSECorePlugin.getDefault().getLogger().logError("PasswordPersistenceManager.getPasswordMap", e); //$NON-NLS-1$
}
***************
*** 372,387 ****
* Retrieve the password map from the keyring for the specified system type
*/
! private void savePasswordMap(String systemTypeId, Map passwords)
! {
! try
! {
URL serverURL = new URL(newURL);
Platform.flushAuthorizationInfo(serverURL, systemTypeId, AUTH_SCHEME);
Platform.addAuthorizationInfo(serverURL, systemTypeId, AUTH_SCHEME, passwords);
! }
! catch (MalformedURLException e) {
RSECorePlugin.getDefault().getLogger().logError("PasswordPersistenceManager.savePasswordMap", e); //$NON-NLS-1$
! }
! catch (CoreException e) {
RSECorePlugin.getDefault().getLogger().logError("PasswordPersistenceManager.savePasswordMap", e); //$NON-NLS-1$
}
--- 364,375 ----
* Retrieve the password map from the keyring for the specified system type
*/
! private void savePasswordMap(String systemTypeId, Map passwords) {
! try {
URL serverURL = new URL(newURL);
Platform.flushAuthorizationInfo(serverURL, systemTypeId, AUTH_SCHEME);
Platform.addAuthorizationInfo(serverURL, systemTypeId, AUTH_SCHEME, passwords);
! } catch (MalformedURLException e) {
RSECorePlugin.getDefault().getLogger().logError("PasswordPersistenceManager.savePasswordMap", e); //$NON-NLS-1$
! } catch (CoreException e) {
RSECorePlugin.getDefault().getLogger().logError("PasswordPersistenceManager.savePasswordMap", e); //$NON-NLS-1$
}
***************
*** 394,448 ****
* specfied in the argument.
*/
! public SystemSignonInformation find(IRSESystemType systemtype, String hostname, String userid)
! {
return find(systemtype, hostname, userid, true);
}
!
! private boolean removePassword(Map passwords, String hostname, String userid)
! {
boolean removed = false;
String password = null;
String passwordKey = getPasswordKey(hostname, userid);
! password =(String) passwords.get(passwordKey);
! if (password != null)
! {
passwords.remove(passwordKey);
removed = true;
! }
! else
! {
String phostname = hostname.toUpperCase();
// DKM - fallback for different case uids, hostnames or qualified/unqualified hostnames
Iterator keys = passwords.keySet().iterator();
! while (keys.hasNext() && password == null)
! {
! String key = (String)keys.next();
! if (key.equalsIgnoreCase(passwordKey))
! {
password = (String) passwords.get(key);
! }
! else
! {
String khostname = getHostnameFromPasswordKey(key).toUpperCase();
String kuid = getUserIdFromPasswordKey(key);
! if (kuid.equalsIgnoreCase(userid))
! {
// uid matches, check if hosts are the same
! if (khostname.startsWith(phostname) || phostname.startsWith(khostname))
! {
String qkhost = RSECorePlugin.getQualifiedHostName(khostname);
String qphost = RSECorePlugin.getQualifiedHostName(phostname);
! if (qkhost.equals(qphost))
! {
! password = (String)passwords.get(key);
}
}
}
}
! if (password != null)
! {
passwords.remove(key);
removed = true;
--- 382,422 ----
* specfied in the argument.
*/
! public SystemSignonInformation find(IRSESystemType systemtype, String hostname, String userid) {
return find(systemtype, hostname, userid, true);
}
! private boolean removePassword(Map passwords, String hostname, String userid) {
boolean removed = false;
String password = null;
String passwordKey = getPasswordKey(hostname, userid);
! password = (String) passwords.get(passwordKey);
! if (password != null) {
passwords.remove(passwordKey);
removed = true;
! } else {
String phostname = hostname.toUpperCase();
// DKM - fallback for different case uids, hostnames or qualified/unqualified hostnames
Iterator keys = passwords.keySet().iterator();
! while (keys.hasNext() && password == null) {
! String key = (String) keys.next();
! if (key.equalsIgnoreCase(passwordKey)) {
password = (String) passwords.get(key);
! } else {
String khostname = getHostnameFromPasswordKey(key).toUpperCase();
String kuid = getUserIdFromPasswordKey(key);
! if (kuid.equalsIgnoreCase(userid)) {
// uid matches, check if hosts are the same
! if (khostname.startsWith(phostname) || phostname.startsWith(khostname)) {
String qkhost = RSECorePlugin.getQualifiedHostName(khostname);
String qphost = RSECorePlugin.getQualifiedHostName(phostname);
! if (qkhost.equals(qphost)) {
! password = (String) passwords.get(key);
}
}
}
}
! if (password != null) {
passwords.remove(key);
removed = true;
***************
*** 455,466 ****
}
! private String getPassword(Map passwords, String hostname, String userid)
! {
String password = null;
String passwordKey = getPasswordKey(hostname, userid);
! password =(String) passwords.get(passwordKey);
! if (password != null)
! return password;
String phostname = hostname.toUpperCase();
--- 429,438 ----
}
! private String getPassword(Map passwords, String hostname, String userid) {
String password = null;
String passwordKey = getPasswordKey(hostname, userid);
! password = (String) passwords.get(passwordKey);
! if (password != null) return password;
String phostname = hostname.toUpperCase();
***************
*** 468,492 ****
// DKM - fallback for different case uids, hostnames or qualified/unqualified hostnames
Iterator keys = passwords.keySet().iterator();
! while (keys.hasNext() && password == null)
! {
! String key = (String)keys.next();
! if (key.equalsIgnoreCase(passwordKey))
! {
password = (String) passwords.get(key);
! }
! else
! {
String khostname = getHostnameFromPasswordKey(key).toUpperCase();
String kuid = getUserIdFromPasswordKey(key);
! if (kuid.equalsIgnoreCase(userid))
! {
// uid matches, check if hosts are the same
! if (khostname.startsWith(phostname) || phostname.startsWith(khostname))
! {
String qkhost = RSECorePlugin.getQualifiedHostName(khostname);
String qphost = RSECorePlugin.getQualifiedHostName(phostname);
! if (qkhost.equals(qphost))
! {
! password = (String)passwords.get(key);
}
}
--- 440,457 ----
// DKM - fallback for different case uids, hostnames or qualified/unqualified hostnames
Iterator keys = passwords.keySet().iterator();
! while (keys.hasNext() && password == null) {
! String key = (String) keys.next();
! if (key.equalsIgnoreCase(passwordKey)) {
password = (String) passwords.get(key);
! } else {
String khostname = getHostnameFromPasswordKey(key).toUpperCase();
String kuid = getUserIdFromPasswordKey(key);
! if (kuid.equalsIgnoreCase(userid)) {
// uid matches, check if hosts are the same
! if (khostname.startsWith(phostname) || phostname.startsWith(khostname)) {
String qkhost = RSECorePlugin.getQualifiedHostName(khostname);
String qphost = RSECorePlugin.getQualifiedHostName(phostname);
! if (qkhost.equals(qphost)) {
! password = (String) passwords.get(key);
}
}
***************
*** 507,516 ****
* @param checkDefault Whether or not to check for a default system type if the specified system type is not found.
*/
! public SystemSignonInformation find(IRSESystemType systemtype, String hname, String userid, boolean checkDefault)
! {
String hostname = hname;//RSEUIPlugin.getQualifiedHostName(hname);
// Convert userid to upper case if required
! if (!isUserIDCaseSensitive(systemtype) && userid != null)
! {
userid = userid.toUpperCase();
}
--- 472,479 ----
* @param checkDefault Whether or not to check for a default system type if the specified system type is not found.
*/
! public SystemSignonInformation find(IRSESystemType systemtype, String hname, String userid, boolean checkDefault) {
String hostname = hname;//RSEUIPlugin.getQualifiedHostName(hname);
// Convert userid to upper case if required
! if (!isUserIDCaseSensitive(systemtype) && userid != null) {
userid = userid.toUpperCase();
}
***************
*** 518,527 ****
Map passwords = getPasswordMap(systemtype);
! if (passwords != null)
! {
String password = getPassword(passwords, hostname, userid);
! if (password != null)
! {
return new SystemSignonInformation(hostname, userid, password, systemtype);
}
--- 481,488 ----
Map passwords = getPasswordMap(systemtype);
! if (passwords != null) {
String password = getPassword(passwords, hostname, userid);
! if (password != null) {
return new SystemSignonInformation(hostname, userid, password, systemtype);
}
***************
*** 529,534 ****
// yantzi: RSE6.2 check for default system type entry with this hostname and user ID
! if (checkDefault && !DEFAULT_SYSTEM_TYPE.equals(systemtype))
! {
return find(DEFAULT_SYSTEM_TYPE, hostname, userid, false);
}
--- 490,494 ----
// yantzi: RSE6.2 check for default system type entry with this hostname and user ID
! if (checkDefault && !DEFAULT_SYSTEM_TYPE.equals(systemtype)) {
return find(DEFAULT_SYSTEM_TYPE, hostname, userid, false);
}
***************
*** 541,546 ****
* userid and hostname in the Map
*/
! private String getPasswordKey(String hname, String userid)
! {
String hostname = hname;//RSEUIPlugin.getQualifiedHostName(hname);
StringBuffer buffer = new StringBuffer(hostname);
--- 501,505 ----
* userid and hostname in the Map
*/
! private String getPasswordKey(String hname, String userid) {
String hostname = hname;//RSEUIPlugin.getQualifiedHostName(hname);
StringBuffer buffer = new StringBuffer(hostname);
***************
*** 550,561 ****
}
! private String getHostnameFromPasswordKey(String passwordKey)
! {
int sepIndex = passwordKey.indexOf("//"); //$NON-NLS-1$
! return passwordKey.substring(0,sepIndex);
}
! private String getUserIdFromPasswordKey(String passwordKey)
! {
int sepIndex = passwordKey.indexOf("//"); //$NON-NLS-1$
return passwordKey.substring(sepIndex + 2, passwordKey.length());
--- 509,518 ----
}
! private String getHostnameFromPasswordKey(String passwordKey) {
int sepIndex = passwordKey.indexOf("//"); //$NON-NLS-1$
! return passwordKey.substring(0, sepIndex);
}
! private String getUserIdFromPasswordKey(String passwordKey) {
int sepIndex = passwordKey.indexOf("//"); //$NON-NLS-1$
return passwordKey.substring(sepIndex + 2, passwordKey.length());
***************
*** 565,576 ****
* Helper method for determining if system type uses case sensitive user IDs
*/
! public boolean isUserIDCaseSensitive(IRSESystemType systemType)
! {
// First find the correct provider
! for (int i = 0; i < systemTypes.length; i++)
! {
! if (systemTypes[i].getSystemType().equals(systemType))
! {
return systemTypes[i].isUserIDCaseSensitive();
}
--- 522,530 ----
* Helper method for determining if system type uses case sensitive user IDs
*/
! public boolean isUserIDCaseSensitive(IRSESystemType systemType) {
// First find the correct provider
! for (int i = 0; i < systemTypes.length; i++) {
! if (systemTypes[i].getSystemType().equals(systemType)) {
return systemTypes[i].isUserIDCaseSensitive();
}
***************
*** 584,589 ****
* Retrieve the list of registered system types
*/
! public IRSESystemType[] getRegisteredSystemTypes()
! {
// yantzi: artemis 6.2, added default system type to list
IRSESystemType[] types = new IRSESystemType[systemTypes.length + 1];
--- 538,542 ----
* Retrieve the list of registered system types
*/
! public IRSESystemType[] getRegisteredSystemTypes() {
// yantzi: artemis 6.2, added default system type to list
IRSESystemType[] types = new IRSESystemType[systemTypes.length + 1];
***************
*** 591,596 ****
types[0] = DEFAULT_SYSTEM_TYPE;
! for (int i = 0; i < systemTypes.length; i++)
! {
types[i + 1] = systemTypes[i].getSystemType();
}
--- 544,548 ----
types[0] = DEFAULT_SYSTEM_TYPE;
! for (int i = 0; i < systemTypes.length; i++) {
types[i + 1] = systemTypes[i].getSystemType();
}
***************
*** 605,610 ****
* without the saved passwords.
*/
! public List getSavedUserIDs()
! {
List savedUserIDs = new ArrayList();
Map passwords;
--- 557,561 ----
* without the saved passwords.
*/
! public List getSavedUserIDs() {
List savedUserIDs = new ArrayList();
Map passwords;
***************
*** 612,628 ****
int separator;
! for (int i = 0; i < systemTypes.length; i++)
! {
passwords = getPasswordMap(systemTypes[i].getSystemType());
! if (passwords != null)
! {
Iterator keys = passwords.keySet().iterator();
! while (keys.hasNext())
! {
key = (String) keys.next();
separator = key.indexOf("//"); //$NON-NLS-1$
! savedUserIDs.add(new SystemSignonInformation(key.substring(0, separator), // hostname
! key.substring(separator + 2), // userid
! systemTypes[i].getSystemType())); // system type
}
}
--- 563,576 ----
int separator;
! for (int i = 0; i < systemTypes.length; i++) {
passwords = getPasswordMap(systemTypes[i].getSystemType());
! if (passwords != null) {
Iterator keys = passwords.keySet().iterator();
! while (keys.hasNext()) {
key = (String) keys.next();
separator = key.indexOf("//"); //$NON-NLS-1$
! savedUserIDs.add(new SystemSignonInformation(key.substring(0, separator), // hostname
! key.substring(separator + 2), // userid
! systemTypes[i].getSystemType())); // system type
}
}
***************
*** 631,644 ****
// yantzi: RSE 6.2 Get DEFAULT system types too
passwords = getPasswordMap(DEFAULT_SYSTEM_TYPE);
! if (passwords != null)
! {
Iterator keys = passwords.keySet().iterator();
! while (keys.hasNext())
! {
key = (String) keys.next();
separator = key.indexOf("//"); //$NON-NLS-1$
! savedUserIDs.add(new SystemSignonInformation(key.substring(0, separator), // hostname
! key.substring(separator + 2), // userid
! DEFAULT_SYSTEM_TYPE)); // system type
}
}
--- 579,590 ----
// yantzi: RSE 6.2 Get DEFAULT system types too
passwords = getPasswordMap(DEFAULT_SYSTEM_TYPE);
! if (passwords != null) {
Iterator keys = passwords.keySet().iterator();
! while (keys.hasNext()) {
key = (String) keys.next();
separator = key.indexOf("//"); //$NON-NLS-1$
! savedUserIDs.add(new SystemSignonInformation(key.substring(0, separator), // hostname
! key.substring(separator + 2), // userid
! DEFAULT_SYSTEM_TYPE)); // system type
}
}