Search in sources :

Example 36 with ISecurePreferences

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;
}
Also used : ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences)

Example 37 with ISecurePreferences

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));
}
Also used : URIish(org.eclipse.jgit.transport.URIish) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences) Test(org.junit.Test)

Example 38 with ISecurePreferences

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));
}
Also used : URIish(org.eclipse.jgit.transport.URIish) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences) Test(org.junit.Test)

Example 39 with ISecurePreferences

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);
}
Also used : ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences)

Example 40 with ISecurePreferences

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;
}
Also used : ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences)

Aggregations

ISecurePreferences (org.eclipse.equinox.security.storage.ISecurePreferences)46 StorageException (org.eclipse.equinox.security.storage.StorageException)13 Preferences (org.osgi.service.prefs.Preferences)5 IOException (java.io.IOException)4 DBASecureStorage (org.jkiss.dbeaver.model.app.DBASecureStorage)4 BackingStoreException (org.osgi.service.prefs.BackingStoreException)4 ArrayList (java.util.ArrayList)3 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3 MdwSecurityException (com.centurylink.mdw.auth.MdwSecurityException)2 MdwAuthenticator (com.centurylink.mdw.designer.auth.MdwAuthenticator)2 User (com.centurylink.mdw.plugin.User)2 DiscoveryException (com.centurylink.mdw.plugin.designer.DiscoveryException)2 XmlException (org.apache.xmlbeans.XmlException)2 ResourceException (org.eclipse.core.internal.resources.ResourceException)2 CoreException (org.eclipse.core.runtime.CoreException)2 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)2 IDStoreException (org.eclipse.ecf.storage.IDStoreException)2 IIDEntry (org.eclipse.ecf.storage.IIDEntry)2 JavaModelException (org.eclipse.jdt.core.JavaModelException)2