use of org.eclipse.equinox.security.storage.ISecurePreferences in project generator by mybatis.
the class LauncherUtils method getUserId.
public static String getUserId(ILaunchConfiguration configuration) {
boolean secure = getBooleanOrFalse(configuration, GeneratorLaunchConstants.ATTR_SQL_SCRIPT_SECURE_CREDENTIALS);
String userId;
if (secure) {
ISecurePreferences node = getSecurePreferencesNode();
// $NON-NLS-1$
userId = getTextOrBlank(node, "user");
} else {
userId = getTextOrBlank(configuration, GeneratorLaunchConstants.ATTR_SQL_SCRIPT_USERID);
}
return userId;
}
use of org.eclipse.equinox.security.storage.ISecurePreferences in project egit by eclipse.
the class EGitSecureStoreTest method testPutUserAndPasswordURIContainingUserAndPass.
@Test
public void testPutUserAndPasswordURIContainingUserAndPass() throws Exception {
URIish uri = new URIish("http://user:pass@testRepo.example.com/testrepo");
UserPasswordCredentials credentials = new UserPasswordCredentials("agitter", "letmein");
store.putCredentials(uri, credentials);
ISecurePreferences node = secureStoreForTest.node(EGitSecureStore.calcNodePath(uri).toString());
assertEquals("agitter", node.get("user", null));
assertTrue(node.isEncrypted("password"));
assertEquals("letmein", node.get("password", null));
}
use of org.eclipse.equinox.security.storage.ISecurePreferences in project egit by eclipse.
the class EGitSecureStoreTest method testPutUserAndPassword.
@Test
public void testPutUserAndPassword() throws Exception {
URIish uri = new URIish("http://testRepo.example.com/testrepo");
UserPasswordCredentials credentials = new UserPasswordCredentials("agitter", "letmein");
store.putCredentials(uri, credentials);
ISecurePreferences node = secureStoreForTest.node(EGitSecureStore.calcNodePath(uri).toString());
assertEquals("agitter", node.get("user", null));
assertTrue(node.isEncrypted("password"));
assertEquals("letmein", node.get("password", null));
}
use of org.eclipse.equinox.security.storage.ISecurePreferences in project egit by eclipse.
the class EGitSecureStore method getCredentials.
/**
* Retrieves credentials stored for the given URI from the secure store
*
* @param uri
* @return credentials
* @throws StorageException
*/
public UserPasswordCredentials getCredentials(URIish uri) throws StorageException {
String pathName = calcNodePath(uri);
if (!preferences.nodeExists(pathName))
return null;
ISecurePreferences node = preferences.node(pathName);
// $NON-NLS-1$
String user = node.get(USER, "");
// $NON-NLS-1$
String password = node.get(PASSWORD, "");
if (uri.getUser() != null && !user.equals(uri.getUser()))
return null;
return new UserPasswordCredentials(user, password);
}
use of org.eclipse.equinox.security.storage.ISecurePreferences in project ecf by eclipse.
the class ContainerStore method retrieve.
/* (non-Javadoc)
* @see org.eclipse.ecf.storage.IContainerStore#retrieve(org.eclipse.ecf.storage.IIDEntry)
*/
public IContainerEntry retrieve(IIDEntry idEntry) {
Assert.isNotNull(idEntry);
ISecurePreferences pref = idEntry.getPreferences();
String[] names = pref.childrenNames();
IContainerEntry result = null;
for (int k = 0; k < names.length; k++) {
if (names[k].equals(CONTAINER_NODE_NAME))
result = new ContainerEntry(idEntry);
}
return result;
}
Aggregations