本文整理汇总了Java中org.eclipse.equinox.security.storage.StorageException类的典型用法代码示例。如果您正苦于以下问题:Java StorageException类的具体用法?Java StorageException怎么用?Java StorageException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StorageException类属于org.eclipse.equinox.security.storage包,在下文中一共展示了StorageException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performOk
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
@Override
public boolean performOk() {
boolean ok = super.performOk();
if (ok) {
setBoolean(P_EDITOR_MATCHING_BRACKETS_ENABLED, matchingBrackets);
setBoolean(P_EDITOR_HIGHLIGHT_BRACKET_AT_CARET_LOCATION, highlightBracketAtCaretLocation);
setBoolean(P_EDITOR_ENCLOSING_BRACKETS, enclosingBrackets);
if (temporaryCredentials != null) {
ISecurePreferences preferences = SecurePreferencesFactory.getDefault();
ISecurePreferences node = preferences.node(ID_SECURED_CREDENTIALS);
try {
node.put(ID_SECURED_USER_KEY, temporaryCredentials.username, true);
node.put(ID_SECURED_API_KEY, temporaryCredentials.secret, true);
} catch (StorageException e1) {
JenkinsEditorUtil.logError("Wasn't able to store credentials", e1);
return false;
}
}
}
return ok;
}
示例2: populatePasswordField
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
private void populatePasswordField() {
ISecurePreferences hydrographSecureStorageRunDialogHostNode = getSecureStorageHostNode(txtEdgeNode.getText().toLowerCase(),false);
try {
if(hydrographSecureStorageRunDialogHostNode!=null){
String password=hydrographSecureStorageRunDialogHostNode.get(txtUserName.getText(), "");
txtPassword.setText(password);
if(radioPassword.isEnabled() && !txtPassword.isEnabled()){
textPasswordListener.getErrorDecoration().hide();
}
if(!StringUtils.isBlank(password)){
chkbtnSavePassword.setSelection(true);
}else{
chkbtnSavePassword.setSelection(false);
}
}else{
txtPassword.setText("");
}
} catch (StorageException storageException) {
logger.debug("Unable to fetch password from eclipse secure storage " , storageException);;
}
}
示例3: requestCredentials
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
private void requestCredentials(final ISecurePreferences node, String user, String password) {
Credentials credentials = new Credentials(user,password);
IStatus status = new Status(IStatus.ERROR,"org.dawnsci.marketplace.ui","Could not sign in to the marketplace service. Please verify credentials and try again.");
LoginDialog ld = new LoginDialog(this.getSite().getShell(), credentials, status);
this.getSite().getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (ld.open()==0) {
try {
node.put("username", credentials.getUsername(), false);
node.put("password", credentials.getPassword(), true);
} catch (StorageException e) {
e.printStackTrace();
}
}
}
});
}
示例4: getCredentials
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
@Override
public CachedCredentials getCredentials(final URI serverURI) {
final ISecurePreferences node = getSecureStorageNode(serverURI);
if (node != null) {
try {
final String storedUserName = node.get(USER_NAME, ""); //$NON-NLS-1$
final String password = node.get(PASSWORD, ""); //$NON-NLS-1$
if (!StringUtil.isNullOrEmpty(storedUserName) && !StringUtil.isNullOrEmpty(password)) {
log.debug("User name & password credentials created"); //$NON-NLS-1$
return new CachedCredentials(serverURI, storedUserName, password);
}
} catch (final StorageException e) {
log.error("Error reading credentials from the Eclipse secure store", e); //$NON-NLS-1$
}
}
final CachedCredentials credentials = getPlatformCredentialsManager().getCredentials(serverURI);
if (credentials != null) {
final String credentialsType = credentials.isPatCredentials() ? "PAT" //$NON-NLS-1$
: credentials.isUsernamePasswordCredentials() ? "User name & password" : "Unexpected"; //$NON-NLS-1$ //$NON-NLS-2$
log.debug(credentialsType + " credentials created found in the platform credentials manager."); //$NON-NLS-1$
}
return credentials;
}
示例5: isRemembered
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
private boolean isRemembered() {
ISecurePreferences secPrefs = SecurePreferencesFactory.getDefault().node("org.bbaw.bts.app");
ISecurePreferences rememberedMe = secPrefs.node("rememberedMe");
String rememberedUsername = null;
String rememberedPass = null;
try {
rememberedUsername = rememberedMe.get("rememberedUsername", null);
rememberedPass = rememberedMe.get("remembered", null);
} catch (StorageException e1) {
e1.printStackTrace();
}
if (rememberedUsername != null
&& !"".equals(rememberedUsername)
&& rememberedPass != null)
{
return true;
}
else
{
return false;
}
}
示例6: storeCommunityUserInformation
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
/**
* Save the Jaspersoft Community site credentials.
* <p>
*
* They can be used for example to submit new issue to the tracker via REST
* API.
*
* @param user
* the community user
*/
public void storeCommunityUserInformation(CommunityUser user){
if(JaspersoftStudioPlugin.shouldUseSecureStorage()) {
try {
SecureStorageUtils.saveToDefaultSecurePreferences(
CommunityConstants.SECURE_PREFSTORE_PATHNAME, USERNAME_KEY, user.getUsername());
SecureStorageUtils.saveToDefaultSecurePreferences(
CommunityConstants.SECURE_PREFSTORE_PATHNAME, PASSWORD_KEY, user.getPassword());
}
catch (StorageException ex){
logError(Messages.JSSCommunityActivator_CredentialsStoreError, ex);
UIUtils.showError(ex);
}
}
else {
getDefault().getPreferenceStore().putValue(USERNAME_KEY, user.getUsername());
getDefault().getPreferenceStore().putValue(PASSWORD_KEY, user.getPassword());
}
}
示例7: getPassword
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
public char[] getPassword(String authId) {
ISecurePreferences preferences = getSecurePreferences();
if (preferences.nodeExists(authId)) {
try {
ISecurePreferences node = preferences.node(authId);
String password = node.get(PROP_PASSWORD, null);
if (password != null) {
return password.toCharArray();
}
} catch (StorageException e) {
IdeLog.logWarning(CoreIOPlugin.getDefault(), Messages.AuthenticationManager_FailedGetSecurePreference, e);
}
}
if (sessionPasswords.containsKey(authId)) {
return sessionPasswords.get(authId);
}
return null;
}
示例8: addCredentialsToSecureStorage
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
public static void addCredentialsToSecureStorage(SecuritySetup setup) {
ISecurePreferences preferences = SecurePreferencesFactory.getDefault();
ISecurePreferences baseNode = preferences.node(IVY_DE_CREDENTIALS_BASE_NODE);
ISecurePreferences childNode = baseNode.node(setup.getHost());
ISecurePreferences childChildNode = childNode.node(setup.getRealm());
try {
childChildNode.put(HOST_KEY, setup.getHost(), false);
childChildNode.put(REALM_KEY, setup.getRealm(), false);
childChildNode.put(USERNAME_KEY, setup.getUserName(), true);
childChildNode.put(PASSWORD_KEY, setup.getPwd(), true);
childChildNode.flush();
IvyPlugin.logInfo(
"Credentials " + setup.toString() + " added to eclipse secure storage");
} catch (StorageException | IOException e) {
IvyPlugin.logError(e.getMessage(), e);
}
}
示例9: testPutWithStoreOnlyToken
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
@Test
public void testPutWithStoreOnlyToken() throws StorageException {
final DataStore<String, Credentials> dataStore = new SecureStorageDataStore(urlNode);
final Credentials credentials = codenvyClient.newCredentialsBuilder().withPassword(FOO_PASSWORD)
.withToken(codenvyClient.newTokenBuilder(FOO_TOKEN).build())
.storeOnlyToken(true)
.build();
final Credentials storedCredentials = dataStore.put(FOO_USERNAME, credentials);
Assert.assertNull(storedCredentials);
Assert.assertTrue(urlNode.nodeExists(FOO_USERNAME));
Assert.assertNull(urlNode.node(FOO_USERNAME).get(CODENVY_PASSWORD_KEY_NAME, (String)null));
Assert.assertEquals(FOO_TOKEN, urlNode.node(FOO_USERNAME).get(CODENVY_TOKEN_KEY_NAME, (String)null));
}
示例10: testPutOnExitingNode
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
@Test
public void testPutOnExitingNode() throws StorageException {
final DataStore<String, Credentials> dataStore = new SecureStorageDataStore(urlNode);
final Credentials fooCredentials = codenvyClient.newCredentialsBuilder().withUsername(FOO_USERNAME)
.withPassword(FOO_PASSWORD)
.withToken(codenvyClient.newTokenBuilder(FOO_TOKEN).build())
.build();
final Credentials barCredentials = codenvyClient.newCredentialsBuilder().withUsername(BAR_USERNAME)
.withPassword(BAR_PASSWORD)
.withToken(codenvyClient.newTokenBuilder(BAR_TOKEN).build())
.build();
final Credentials storedCredentials = dataStore.put(BAR_USERNAME, fooCredentials);
Assert.assertNotNull(storedCredentials);
Assert.assertEquals(barCredentials, storedCredentials);
Assert.assertEquals(FOO_PASSWORD, urlNode.node(BAR_USERNAME).get(CODENVY_PASSWORD_KEY_NAME, (String)null));
Assert.assertEquals(FOO_TOKEN, urlNode.node(BAR_USERNAME).get(CODENVY_TOKEN_KEY_NAME, (String)null));
}
示例11: get
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
@Override
public Credentials get(String username) {
checkNotNull(username);
try {
if (!urlNode.nodeExists(username)) {
return null;
}
final ISecurePreferences node = urlNode.node(username);
final String password = node.get(CODENVY_PASSWORD_KEY_NAME, null);
final String token = node.get(CODENVY_TOKEN_KEY_NAME, null);
return CodenvyAPI.getClient().newCredentialsBuilder().withUsername(username)
.withPassword(password)
.withToken(CodenvyAPI.getClient().newTokenBuilder(token).build())
.build();
} catch (StorageException e) {
throw new RuntimeException(e);
}
}
示例12: put
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
@Override
public Credentials put(String username, Credentials credentials) {
checkNotNull(username);
checkNotNull(credentials);
try {
final Credentials previousCredentials = get(username);
final ISecurePreferences node = urlNode.node(username);
// a put replace all values
node.remove(CODENVY_PASSWORD_KEY_NAME);
node.remove(CODENVY_TOKEN_KEY_NAME);
if (!credentials.isStoreOnlyToken()) {
node.put(CODENVY_PASSWORD_KEY_NAME, credentials.password(), true);
}
node.put(CODENVY_TOKEN_KEY_NAME, credentials.token().value(), true);
return previousCredentials;
} catch (StorageException e) {
throw new RuntimeException(e);
}
}
示例13: savePasswordToSecureStorage
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
private void savePasswordToSecureStorage(String password) {
ISecurePreferences hydrographSecureStorageRunDialogHostNode = getSecureStorageHostNode(
txtEdgeNode.getText().toLowerCase(), true);
try {
hydrographSecureStorageRunDialogHostNode.put(txtUserName.getText(), password, true);
} catch (StorageException storageException) {
logger.debug("Failed to save the password in secure storage", storageException);
}
}
示例14: disableSecurePreferences
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
private void disableSecurePreferences(StorageException e) {
if (!securePreferencesDisabled.getAndSet(true)) {
CloudFoundryPlugin
.getDefault()
.getLog()
.log(new Status(IStatus.ERROR, CloudFoundryPlugin.PLUGIN_ID, "Unexpected error while accessing secure preferences for server: " + serverId)); //$NON-NLS-1$
}
}
示例15: readProperty
import org.eclipse.equinox.security.storage.StorageException; //导入依赖的package包/类
private String readProperty(String property) {
ISecurePreferences preferences = getSecurePreferences();
if (preferences != null) {
try {
return preferences.get(property, null);
}
catch (StorageException e) {
disableSecurePreferences(e);
}
}
return null;
}