1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 18:55:38 +02:00

Merge remote-tracking branch 'origin/master' into dwd-useractions-source-split

This commit is contained in:
David Dykstal 2013-01-22 22:15:08 -06:00
commit 69fb04eb93
15 changed files with 215 additions and 170 deletions

View file

@ -445,10 +445,6 @@
</execution>
</executions>
</plugin>
<!-- </plugins>
</pluginManagement>
<pluginManagement>
<plugins>-->
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
@ -465,7 +461,7 @@
</dependency>
</dependencies>
<product>org.eclipse.sdk.ide</product>
<argLine>-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m</argLine>
<argLine>-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m -Drse.enableSecureStoreAccess=false -Dorg.eclipse.swt.browser.UseWebKitGTK=true</argLine>
</configuration>
</plugin>
<plugin>

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.rse.core;singleton:=true
Bundle-Version: 3.3.1.qualifier
Bundle-Version: 3.3.2.qualifier
Bundle-Activator: org.eclipse.rse.core.RSECorePlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,

View file

@ -10,6 +10,6 @@
</parent>
<groupId>org.eclipse.tm</groupId>
<artifactId>org.eclipse.rse.core</artifactId>
<version>3.3.1.qualifier</version>
<version>3.3.2.qualifier</version>
<packaging>eclipse-plugin</packaging>
</project>

View file

@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2002, 2012 IBM Corporation and others. All rights reserved.
* Copyright (c) 2002, 2013 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@ -20,6 +20,7 @@
* Martin Oberhuber (Wind River) - [cleanup] Add API "since" Javadoc tags
* David Dykstal (IBM) - [210474] Deny save password function missing
* David Dykstal (IBM) - [225320] Use equinox secure storage for passwords
* David Dykstal (IBM) - [379787] Fix secure storage usage in org.eclipse.rse.tests
********************************************************************************/
package org.eclipse.rse.core;
@ -48,6 +49,13 @@ import org.osgi.framework.Bundle;
/**
* PasswordPersistenceManager manages the saving and retrieving of user IDs /
* passwords to Equinox secure storage for registered system types.
* <p>
* A PasswordPersistenceManager is sensitive to the "rse.enableSecureStoreAccess" property.
* If absent it defaults to <code>true</code>.
* If present then the value must be <code>true</code> to enable access to the secure store.
* The following code disables access to the secure store.
* <p>
* <code>System.setProperty("rse.enableSecureStoreAccess", "false");</code>
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients. Use
@ -382,7 +390,8 @@ public class PasswordPersistenceManager {
/**
* Returns the preferences node that matches the system type.
* It will not return null but will create the node if it does not exist.
* It will only return null if secure store access is disallowed.
* If secure store access is allowed it will create the node if it does not exist.
* If the node does not previous exist then an attempt will be made
* to migrate the values from the old map form to this newly created node
* of the secure preferences tree.
@ -390,14 +399,17 @@ public class PasswordPersistenceManager {
* @return the matching secure preferences node.
*/
private ISecurePreferences getNode(IRSESystemType systemType) {
String id = systemType.getId();
ISecurePreferences preferences = SecurePreferencesFactory.getDefault();
ISecurePreferences rseNode = preferences.node("org.eclipse.rse.core.security"); //$NON-NLS-1$
ISecurePreferences systemTypeNode = null;
if (!rseNode.nodeExists(id)) {
migrateMap(rseNode, id);
String enableSecureStoreAccess = System.getProperty("rse.enableSecureStoreAccess", "true"); //$NON-NLS-1$//$NON-NLS-2$
if (enableSecureStoreAccess.equals("true")) { //$NON-NLS-1$
String id = systemType.getId();
ISecurePreferences preferences = SecurePreferencesFactory.getDefault();
ISecurePreferences rseNode = preferences.node("org.eclipse.rse.core.security"); //$NON-NLS-1$
if (!rseNode.nodeExists(id)) {
migrateMap(rseNode, id);
}
systemTypeNode = rseNode.node(id);
}
systemTypeNode = rseNode.node(id);
return systemTypeNode;
}
@ -473,20 +485,24 @@ public class PasswordPersistenceManager {
* @return the number of passwords removed.
*/
private int removePassword(IRSESystemType systemType, String hostName, String userId) {
int result = 0;
ISecurePreferences passwords = getNode(systemType);
boolean respectCase = isUserIDCaseSensitive(systemType);
String keys[] = getMatchingKeys(passwords.keys(), hostName, userId, respectCase, false);
if (keys.length == 0) {
keys = getMatchingKeys(passwords.keys(), hostName, userId, respectCase, true);
if (passwords != null) {
boolean respectCase = isUserIDCaseSensitive(systemType);
String keys[] = getMatchingKeys(passwords.keys(), hostName, userId, respectCase, false);
if (keys.length == 0) {
keys = getMatchingKeys(passwords.keys(), hostName, userId, respectCase, true);
}
for (int i = 0; i < keys.length; i++) {
String key = keys[i];
basicRemove(passwords, key);
}
if (keys.length > 0) {
basicSave(passwords);
}
result = keys.length;
}
for (int i = 0; i < keys.length; i++) {
String key = keys[i];
basicRemove(passwords, key);
}
if (keys.length > 0) {
basicSave(passwords);
}
return keys.length;
return result;
}
/**
@ -502,14 +518,16 @@ public class PasswordPersistenceManager {
private String findPassword(IRSESystemType systemType, String hostName, String userId) {
String password = null;
ISecurePreferences passwords = getNode(systemType);
boolean respectCase = isUserIDCaseSensitive(systemType);
String keys[] = getMatchingKeys(passwords.keys(), hostName, userId, respectCase, false);
if (keys.length == 0) {
keys = getMatchingKeys(passwords.keys(), hostName, userId, respectCase, true);
}
if (keys.length > 0) {
String key = keys[0];
password = basicGet(passwords, key);
if (passwords != null) {
boolean respectCase = isUserIDCaseSensitive(systemType);
String keys[] = getMatchingKeys(passwords.keys(), hostName, userId, respectCase, false);
if (keys.length == 0) {
keys = getMatchingKeys(passwords.keys(), hostName, userId, respectCase, true);
}
if (keys.length > 0) {
String key = keys[0];
password = basicGet(passwords, key);
}
}
return password;
}
@ -522,12 +540,18 @@ public class PasswordPersistenceManager {
* @param hostName the name of the host we are examining for a password.
* @param userId the user id to find passwords for.
* @param password the password to save for this entry.
* @return RC_OK if the password was updated, RC_DENIED if the password was not updated.
*/
private void updatePassword(IRSESystemType systemType, String hostName, String userId, String password) {
private int updatePassword(IRSESystemType systemType, String hostName, String userId, String password) {
int result = RC_DENIED;
ISecurePreferences passwords = getNode(systemType);
String key = getKey(hostName, userId);
basicPut(passwords, key, password);
basicSave(passwords);
if (passwords != null) {
String key = getKey(hostName, userId);
basicPut(passwords, key, password);
basicSave(passwords);
result = RC_OK;
}
return result;
}
/**
@ -551,8 +575,9 @@ public class PasswordPersistenceManager {
* @param info The signon information to store
* @param overwrite Whether to overwrite any existing entry
* @return
* RC_OK if the password was successfully stored
* RC_ALREADY_EXISTS if the password already exists and overwrite was false
* RC_OK if the password was successfully stored
* RC_ALREADY_EXISTS if the password already exists and overwrite was false
* RC_DENIED if passwords may not be saved for this system type and host
*/
public int add(SystemSignonInformation info, boolean overwrite) {
return add(info, overwrite, false);
@ -587,7 +612,7 @@ public class PasswordPersistenceManager {
}
String oldPassword = findPassword(systemType, hostName, userId);
if (oldPassword == null || (overwrite && !newPassword.equals(oldPassword))) {
updatePassword(systemType, hostName, userId, newPassword);
result = updatePassword(systemType, hostName, userId, newPassword);
} else if (oldPassword != null) {
result = RC_ALREADY_EXISTS;
}
@ -629,7 +654,7 @@ public class PasswordPersistenceManager {
* @param systemType the IRSESystemType instance to find a password for.
* @param hostName the name of the host we are examining for a password.
* @param userId the user id to find passwords for.
* @return the {@link SystemSignonInformation} for the specified criteria.
* @return the {@link SystemSignonInformation} for the specified criteria or null if no such password can be found.
*/
public SystemSignonInformation find(IRSESystemType systemType, String hostName, String userId) {
return find(systemType, hostName, userId, true);
@ -644,7 +669,7 @@ public class PasswordPersistenceManager {
* @param hostName the name of the host we are examining for a password.
* @param userId the user id to find passwords for.
* @param checkDefault true if the default system type should be checked if the specified system type is not found
* @return the {@link SystemSignonInformation} for the specified criteria.
* @return the {@link SystemSignonInformation} for the specified criteria or null if no such password can be found.
*/
public SystemSignonInformation find(IRSESystemType systemType, String hostName, String userId, boolean checkDefault) {
SystemSignonInformation result = null;
@ -729,13 +754,15 @@ public class PasswordPersistenceManager {
for (int i = 0; i < systemTypes.length; i++) {
IRSESystemType systemType = systemTypes[i];
ISecurePreferences node = getNode(systemType);
String[] keys = node.keys();
for (int j = 0; j < keys.length; j++) {
String key = keys[j];
String hostName = getHostNameFromKey(key);
String userId = getUserIdFromKey(key);
SystemSignonInformation info = new SystemSignonInformation(hostName, userId, systemType);
savedUserIDs.add(info);
if (node != null) {
String[] keys = node.keys();
for (int j = 0; j < keys.length; j++) {
String key = keys[j];
String hostName = getHostNameFromKey(key);
String userId = getUserIdFromKey(key);
SystemSignonInformation info = new SystemSignonInformation(hostName, userId, systemType);
savedUserIDs.add(info);
}
}
}
return savedUserIDs;

View file

@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2007, 2010 IBM Corporation and others. All rights reserved.
* Copyright (c) 2007, 2012 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@ -12,6 +12,7 @@
* David Dykstal (IBM) - [210474] Deny save password function missing
* David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception
* David McKnight (IBM) [323648] SSH Terminals subsystem should re-use user id and password for the Files subsystem
* David McKnight (IBM) [398234] Connect from host doesn't always propagate id/password to multiple contained connector services
********************************************************************************/
package org.eclipse.rse.core.subsystems;
@ -122,14 +123,34 @@ public abstract class AuthenticatingConnectorService extends AbstractConnectorSe
* @see org.eclipse.rse.core.subsystems.IConnectorService#setPassword(java.lang.String, java.lang.String, boolean, boolean)
*/
public final void setPassword(String userId, String password, boolean persist, boolean propagate) {
if (getPrimarySubSystem().forceUserIdToUpperCase()) {
ISubSystem ss = getPrimarySubSystem();
if (ss.forceUserIdToUpperCase()) {
userId = userId.toUpperCase();
}
String myUserId = credentialsProvider.getUserId();
IHost host = getHost();
if (host.compareUserIds(userId, myUserId)) {
credentialsProvider.setPassword(password);
}
else {
String hostName = host.getHostName();
SystemSignonInformation existingSignon = null;
// check if there are any uid credentials saved here - if not, then use the new userID/password
List signonsWithIDs = PasswordPersistenceManager.getInstance().getSavedUserIDs();
for (int i = 0 ; i < signonsWithIDs.size() && existingSignon != null; i++){
SystemSignonInformation signon = (SystemSignonInformation)signonsWithIDs.get(i);
if (hostName.equals(signon.getHostname())){
existingSignon = signon;
}
}
if (existingSignon == null){
// update with propagated id/password
credentialsProvider.setUserId(userId);
credentialsProvider.setPassword(password);
}
}
if (sharesCredentials() && propagate) {
updatePasswordForOtherSystemsInConnection(userId, password, persist);
}

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.rse.ui;singleton:=true
Bundle-Version: 3.3.2.qualifier
Bundle-Version: 3.3.3.qualifier
Bundle-Activator: org.eclipse.rse.ui.RSEUIPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2011 IBM Corporation and others.
* Copyright (c) 2002, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -15,13 +15,16 @@
* David McKnight (IBM) - [331986] Sort in Remote System Details view shows wrong results
* David McKnight (IBM) - [355467] The result of sorting resources that contains null blank cells is not correct in Remote System Details view.
* David McKnight (IBM) - [357587] Custom sorter is changed to SystemTableViewSorter
* David McKnight (IBM) - [398306] table sorting of RSE table views inconsistent with Eclipse
*******************************************************************************/
package org.eclipse.rse.internal.ui.view;
import java.util.Comparator;
import java.util.Date;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.util.Policy;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
@ -44,14 +47,16 @@ public class SystemTableViewSorter extends ViewerSorter
private StructuredViewer _view;
private SystemTableViewColumnManager _columnManager;
private Comparator _comparator;
public SystemTableViewSorter(int columnNumber, StructuredViewer view, SystemTableViewColumnManager columnManager)
{
super();
_reverseSort = false;
_reverseSort = true; // reverse sort means ascending order
_columnNumber = columnNumber;
_view = view;
_columnManager = columnManager;
_comparator = Policy.getComparator();
}
public void setColumnNumber(int columnNumber){
@ -112,12 +117,7 @@ public class SystemTableViewSorter extends ViewerSorter
return 1;
}
if (n1 instanceof String)
{
return ((String) n1).compareTo((String) n2);
}
else if (n1 instanceof Date)
if (n1 instanceof Date)
{
return ((Date) n1).compareTo((Date) n2);
}
@ -131,7 +131,7 @@ public class SystemTableViewSorter extends ViewerSorter
}
else
{
return collator.compare(n1, n2);
return _comparator.compare(n1, n2);
}
}
catch (Exception e)

View file

@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved.
* Copyright (c) 2002, 2013 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@ -17,6 +17,7 @@
* David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
* David McKnight (IBM) - [234924] [ftp][dnd][Refresh] Copy/Paste file from Package Explorer doesn't refresh folder
* David McKnight (IBM) - [248339] [dnd][encodings] Cannot drag&drop / copy&paste files or folders with turkish or arabic names
* David McKnight (IBM) - [398324] cross systems folder transfer breaks due to scoping rule
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -243,57 +244,7 @@ extends ViewerDropAdapter
target = getViewer().getInput();
}
List rulesList = new ArrayList();
int j = 0;
for (int i = 0; i < srcObjects.size(); i++)
{
if (srcObjects.get(i) instanceof ISchedulingRule)
{
rulesList.add(srcObjects.get(i));
j++;
}
/** FIXME - can't be coupled with IRemoteFile
else if (srcObjects.get(i) instanceof IRemoteFile)
{
rulesList.add(new RemoteFileSchedulingRule((IRemoteFile)srcObjects.get(i)));
j++;
}
*/
}
/*
if (target instanceof ISchedulingRule)
{
rulesList.add(target);
j++;
}
*/
/** FIXME - can't be coupled with IRemoteFile
else if (target instanceof IRemoteFile)
{
rulesList.add(new RemoteFileSchedulingRule((IRemoteFile)target));
}
else if (target instanceof IAdaptable)
{
ISystemDragDropAdapter targetAdapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
if (targetAdapter != null)
{
ISubSystem targetSubSystem = targetAdapter.getSubSystem(target);
rulesList.add(targetSubSystem);
j++;
}
}
*/
MultiRule rule = null;
ISchedulingRule[] rules = (ISchedulingRule[])rulesList.toArray(new ISchedulingRule[rulesList.size()]);
if (j > 0) rule = new MultiRule(rules);
SystemDNDTransferRunnable runnable = new SystemDNDTransferRunnable(target, srcObjects, getViewer(), _sourceType);
// DKM - rules are causing problems at the moment
runnable.setRule(rule);
SystemDNDTransferRunnable runnable = new SystemDNDTransferRunnable(target, srcObjects, getViewer(), _sourceType);
if (target instanceof SystemScratchpad)
{
runnable.run(new NullProgressMonitor());

View file

@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2002, 2011 IBM Corporation and others. All rights reserved.
* Copyright (c) 2002, 2013 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@ -16,6 +16,7 @@
* Kenya Ishimoto (IBM) - [241197] Paste action causes IllegalArgumentException at Resource.copy
* Zhou Renjian (Kortide) - [282241] "Paste" is enabled on file system when text is in clipboard
* David McKnight (IBM) - [330398] RSE leaks SWT resources
* David McKnight (IBM) - [398324] cross systems folder transfer breaks due to scoping rule
********************************************************************************/
package org.eclipse.rse.ui.actions;
@ -101,35 +102,6 @@ public class SystemPasteFromClipboardAction extends SystemBaseAction implements
{
// do the transfer
SystemDNDTransferRunnable runnable = new SystemDNDTransferRunnable(target, (ArrayList)srcObjects, getViewer(), _srcType);
if (target instanceof IAdaptable)
{
ISystemDragDropAdapter targetAdapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
if (targetAdapter != null)
{
List rulesList = new ArrayList();
if (target instanceof ISchedulingRule) {
rulesList.add(target);
}
int j = 0;
for (int i = 0; i < srcObjects.size(); i++)
{
if (srcObjects.get(i) instanceof ISchedulingRule)
{
rulesList.add(srcObjects.get(i));
j++;
}
}
if (rulesList.size() > 0)
{
ISchedulingRule[] rules = (ISchedulingRule[])rulesList.toArray(new ISchedulingRule[rulesList.size()]);
MultiRule rule = new MultiRule(rules);
runnable.setRule(rule);
}
}
}
runnable.schedule();
RSEUIPlugin.getTheSystemRegistryUI().clearRunnableContext();
}

View file

@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2002, 2012 IBM Corporation and others. All rights reserved.
* Copyright (c) 2002, 2013 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@ -32,6 +32,7 @@
* David McKnight (IBM) - [357587] Custom sorter is changed to SystemTableViewSorter
* David McKnight (IBM) - [363392] system table views shows open view actions when they shouldn't
* David McKnight (IBM) - [388947] column sort icon issue with Remote Systems Details view
* David McKnight (IBM) - [398306] table sorting of RSE table views inconsistent with Eclipse
********************************************************************************/
package org.eclipse.rse.ui.view;
@ -206,6 +207,7 @@ public class SystemTableView
{
_upI = RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_MOVEUP_ID);
_downI = RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_MOVEDOWN_ID);
}
@ -230,19 +232,19 @@ public class SystemTableView
if (oldSorter != null)
{
if (column == oldSorter.getColumnNumber()){
oldSorter.setReversed(!oldSorter.isReversed());
if (tcolumn.getImage() == _upI)
{
tcolumn.setImage(_downI);
boolean isReversed = !oldSorter.isReversed();
oldSorter.setReversed(isReversed);
if (isReversed) {
tcolumn.setImage(_downI);
}
else
{
tcolumn.setImage(_upI);
else {
tcolumn.setImage(_upI);
}
}
else {
oldSorter.setColumnNumber(column);
tcolumn.setImage(_downI);
oldSorter.setReversed(false);
tcolumn.setImage(_upI);
}
}
else

View file

@ -10,6 +10,6 @@
</parent>
<groupId>org.eclipse.tm</groupId>
<artifactId>org.eclipse.rse.ui</artifactId>
<version>3.3.2.qualifier</version>
<version>3.3.3.qualifier</version>
<packaging>eclipse-plugin</packaging>
</project>

View file

@ -11,8 +11,8 @@
<groupId>org.eclipse.tm</groupId>
<artifactId>org.eclipse.rse.tests</artifactId>
<version>3.4.1.qualifier</version>
<packaging>eclipse-plugin</packaging>
<!-- <packaging>eclipse-test-plugin</packaging>
<!-- <packaging>eclipse-plugin</packaging> -->
<packaging>eclipse-test-plugin</packaging>
<build>
<plugins>
<plugin>
@ -27,9 +27,9 @@
<product>org.eclipse.sdk.ide</product>
<testFailureIgnore>true</testFailureIgnore>
<failIfNoTests>false</failIfNoTests>
<argLine>-Drse.enableSecureStoreAccess=false</argLine>
</configuration>
</plugin>
</plugins>
</build>
-->
</project>

View file

@ -9,6 +9,7 @@
# IBM Corporation - initial API and implementation
# Uwe Stieber (Wind River) - Rework test data location & connection management
# Martin Oberhuber (Wind River) - [240729] More flexible disabling of testcases
# David McKnight (IBM) - [398849] [junit-tests] need to disable problemmatic tests
###############################################################################
#
@ -41,6 +42,12 @@ RSENewConnectionWizardTestCase.testRestrictToSystemType=true
HostMoveTest.*=false
RSEFileStoreTest.testDeleteSpecialCases=false
RSEFileStoreTest.testBrokenSymlink=false
RSEFileStoreTest.testModifyNonExisting=false
ScpFileSubsystemTestCase.testScpAccessToRemoteHost=false
#
# The following section controls enablement of test cases by target or client platform.
# Uncomment a line to disable running unit tests on the specified target connection.

View file

@ -1,15 +1,18 @@
/********************************************************************************
* Copyright (c) 2008, 2012 IBM Corporation and others. All rights reserved.
* Copyright (c) 2008, 2013 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* David Dykstal (IBM) - [210474] Deny save password function missing
* David Dykstal (IBM) - [379787] Fix secure storage usage in org.eclipse.rse.tests
********************************************************************************/
package org.eclipse.rse.tests.core.passwords;
import java.util.List;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.PasswordPersistenceManager;
import org.eclipse.rse.core.RSEPreferencesManager;
@ -28,6 +31,7 @@ public class PasswordsTest extends RSECoreTestCase {
*/
protected void setUp() throws Exception {
super.setUp();
// System.setProperty("rse.enableSecureStoreAccess", "false");
}
/* (non-Javadoc)
@ -39,8 +43,8 @@ public class PasswordsTest extends RSECoreTestCase {
public void testAddRemove() {
//-test-author-:DavidDykstal
if (isTestDisabled())
return;
if (isTestDisabled()) return;
if ("false".equals(System.getProperty("rse.enableSecureStoreAccess"))) return;
IRSESystemType systemType = RSECoreRegistry.getInstance().getSystemType(IRSESystemType.SYSTEMTYPE_UNIX_ID);
IRSESystemType defaultSystemType = PasswordPersistenceManager.DEFAULT_SYSTEM_TYPE;
String hostAddress = "somesystem.mycompany.com";
@ -93,8 +97,8 @@ public class PasswordsTest extends RSECoreTestCase {
public void testSaveDenial() {
//-test-author-:DavidDykstal
if (isTestDisabled())
return;
if (isTestDisabled()) return;
if ("false".equals(System.getProperty("rse.enableSecureStoreAccess"))) return;
IRSESystemType systemType = RSECoreRegistry.getInstance().getSystemType(IRSESystemType.SYSTEMTYPE_UNIX_ID);
String hostAddress = "somesystem.mycompany.com";
boolean deny = RSEPreferencesManager.getDenyPasswordSave(systemType, hostAddress);
@ -136,8 +140,8 @@ public class PasswordsTest extends RSECoreTestCase {
public void testMigration() {
//-test-author-:DavidDykstal
if (isTestDisabled())
return;
if (isTestDisabled()) return;
if ("false".equals(System.getProperty("rse.enableSecureStoreAccess"))) return;
// Setup
IRSESystemType systemType = RSECoreRegistry.getInstance().getSystemType(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
@ -167,11 +171,11 @@ public class PasswordsTest extends RSECoreTestCase {
}
}
public void testAliasing() {
//-test-author-:DavidDykstal
if (isTestDisabled())
return;
if (isTestDisabled()) return;
if ("false".equals(System.getProperty("rse.enableSecureStoreAccess"))) return;
IRSESystemType systemType = RSECoreRegistry.getInstance().getSystemType(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
PasswordPersistenceManager ppm = PasswordPersistenceManager.getInstance();
ppm.add(new SystemSignonInformation("LOUDHOST.mycompany.com", "thatguy", "abc", systemType), true, false);
@ -187,13 +191,69 @@ public class PasswordsTest extends RSECoreTestCase {
}
public void testBadArgs() {
if (isTestDisabled())
return;
if (isTestDisabled()) return;
if ("false".equals(System.getProperty("rse.enableSecureStoreAccess"))) return;
IRSESystemType systemType = RSECoreRegistry.getInstance().getSystemType(IRSESystemType.SYSTEMTYPE_LOCAL_ID);
PasswordPersistenceManager ppm = PasswordPersistenceManager.getInstance();
ppm.add(new SystemSignonInformation("myhost.mycompany.com", "me", "password", systemType), true, false);
SystemSignonInformation info = ppm.find(systemType, "myhost.mycompany.com", null);
assertNull(info);
}
public void testDisabledSecureStore() {
//-test-author-:DavidDykstal
if (isTestDisabled()) return;
String key = "rse.enableSecureStoreAccess";
String valueOnEntry = System.getProperty(key);
System.setProperty(key, "false");
PasswordPersistenceManager ppm = PasswordPersistenceManager.getInstance();
IRSESystemType systemType = RSECoreRegistry.getInstance().getSystemType(IRSESystemType.SYSTEMTYPE_UNIX_ID);
String hostAddress = "somesystem.mycompany.com";
String password = "password";
String userId = "me";
SystemSignonInformation info = new SystemSignonInformation(hostAddress, userId, password, systemType);
// try saving and retrieving a password
int result = ppm.add(info, true);
assertEquals("result of first add was not RC_DENIED", PasswordPersistenceManager.RC_DENIED, result);
result = ppm.add(info, true, true);
assertEquals("result of second add was not RC_DENIED", PasswordPersistenceManager.RC_DENIED, result);
SystemSignonInformation returnedInfo = ppm.find(systemType, hostAddress, userId);
assertNull("signon info was found and should not be", returnedInfo);
// test passwords for existence
assertFalse("found signon information where none should exist (1)", ppm.passwordExists(systemType, hostAddress, userId));
assertFalse("found signon information where none should exist (2)", ppm.passwordExists(systemType, hostAddress, userId, false));
assertFalse("found signon information where none should exist (3)", ppm.passwordExists(systemType, hostAddress, userId, true));
// try finding password info
returnedInfo = ppm.find(systemType, hostAddress, userId);
assertNull("signon info was found and should not be (1)", returnedInfo);
returnedInfo = ppm.find(systemType, hostAddress, userId, false);
assertNull("signon info was found but should not be (2)", returnedInfo);
returnedInfo = ppm.find(systemType, hostAddress, userId, true);
assertNull("signon info was found but should not be (3)", returnedInfo);
// try removal
ppm.remove(info);
ppm.remove(systemType, hostAddress, userId);
assertEquals("passwords were removed but none should be (2)", 0, ppm.remove(systemType, hostAddress));
// get system types
IRSESystemType[] systemTypes = ppm.getRegisteredSystemTypes();
assertNotNull("returned system types is null", systemTypes);
assertTrue("no system types were found", systemTypes.length > 0);
// get saved user ids
@SuppressWarnings("rawtypes")
List userInfo = ppm.getSavedUserIDs();
assertTrue("user info was found where none should exist", userInfo.size() == 0);
if (valueOnEntry == null) {
System.clearProperty(key);
} else {
System.setProperty(key, valueOnEntry);
}
}
}

View file

@ -164,4 +164,13 @@ public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase {
if (ftpService.isConnected()) ftpService.disconnect();
}
/* (non-Javadoc)
* @see org.eclipse.rse.tests.core.RSECoreTestCase#isTestDisabled()
*/
@Override
protected boolean isTestDisabled() {
// TODO AD:turn this test back on when we figure out why it stopped working headlessly
return true;
}
}