当前位置: 首页>>代码示例>>Java>>正文


Java Keyring.save方法代码示例

本文整理汇总了Java中org.netbeans.api.keyring.Keyring.save方法的典型用法代码示例。如果您正苦于以下问题:Java Keyring.save方法的具体用法?Java Keyring.save怎么用?Java Keyring.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.api.keyring.Keyring的用法示例。


在下文中一共展示了Keyring.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAdminPassword

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
public synchronized String getAdminPassword() {
    // read old settings
    String pwd = NbPreferences.forModule(MySQLOptions.class).get("adminpwd", null); // NOI18N
    // don't store a password anymore
    NbPreferences.forModule(MySQLOptions.class).remove("adminpwd"); // NOI18N
    if (pwd != null) {
        // store using Keyring API
        Keyring.save(MySQLOptions.class.getName(), pwd.toCharArray(), NbBundle.getMessage(MySQLOptions.class, "MySQLOptions_AdminPassword")); // NOI18N
    }
    if ( isSavePassword() ) {
        LOGGER.log(Level.FINE, "Reading a Admin Password from Keyring.");
        char[] chars = Keyring.read(MySQLOptions.class.getName());
        adminPassword = chars == null ? "" : String.copyValueOf(chars);
    }
    return adminPassword;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:MySQLOptions.java

示例2: setAdminPassword

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
public synchronized void setAdminPassword(String adminPassword) {
    // 'null' is a valid password, but if we save as null
    // it will actually clear the property.  So convert it to
    // an empty string.
    if ( adminPassword == null ) {
        adminPassword = "";
    }
    
    // Cache password for this session whether we save it or not.
    this.adminPassword = adminPassword;
    
    if ( isSavePassword() ) {
        LOGGER.log(Level.FINE, "Storing a Admin Password to Keyring.");
        Keyring.save(MySQLOptions.class.getName(), adminPassword.toCharArray(), NbBundle.getMessage(MySQLOptions.class, "MySQLOptions_AdminPassword")); // NOI18N
    } else {
        LOGGER.log(Level.FINE, "Removing a Admin Password from Keyring.");
        Keyring.delete(MySQLOptions.class.getName());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:MySQLOptions.java

示例3: setSavePassword

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
public void setSavePassword(boolean savePassword) {
    putProperty(PROP_SAVEPWD, savePassword);
    
    // Clear the password from the persistent file if saving
    // passwords is turned off; save the password to the persistent
    // file if saving passwords is turned on
    if (adminPassword == null) {
        // nothing for save
        return ;
    }
    if ( ! savePassword ) {
        clearAdminPassword();
    } else {
        LOGGER.log(Level.FINE, "Storing a Admin Password to Keyring.");
        Keyring.save(MySQLOptions.class.getName(), adminPassword.toCharArray(), NbBundle.getMessage(MySQLOptions.class, "MySQLOptions_AdminPassword")); // NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:MySQLOptions.java

示例4: save

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
/**
 * Saves password for a key constructed from keyPrefix and key
 * @param keyPrefix key prefix for each versioning system
 * @param key will be hashed and used with keyPrefix as a key for the keyring
 * @param password password, value will be nulled. If <code>null</code> the old record will be permanently deleted
 * @param description can be null
 */
public static void save (String keyPrefix, String key, char[] password, String description) {
    String hashedKey = getKeyringKeyHashed(keyPrefix, key);
    if (password == null) {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.log(Level.FINE, "Deleting password for {0}:{1}", new String[] {keyPrefix, key}); //NOI18N
        }
        Keyring.delete(getKeyringKey(keyPrefix, key));
        Keyring.delete(hashedKey);
        NULL_HASHED_RECORDS.add(hashedKey);
    } else {
        if (description == null) {
            description = key;
        }
        if (LOG.isLoggable(Level.FINE)) {
            LOG.log(Level.FINE, "Saving password for {0}:{1}", new String[] {keyPrefix, key}); //NOI18N
            if (PRINT_PASSWORDS) {
                LOG.log(Level.FINEST, "Saving password: \"{0}\"", new String(password)); //NOI18N
            }
        }
        Keyring.save(getKeyringKey(keyPrefix, key), password, description);
        Keyring.delete(hashedKey);
        NULL_HASHED_RECORDS.remove(hashedKey);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:KeyringSupport.java

示例5: storeSettings

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
public void storeSettings() {
    if (rememberPasswd.isSelected()) {
        Keyring.save(hash + KEY_STORE_PASSWORD, keystorePassword.getPassword(), "NBANDROID Project Keystore Password");
        Keyring.save(hash + KEY_PASSWORD, keyPassword.getPassword(), "NBANDROID Project Keystore Key Password");
    } else {
        Keyring.delete(hash + KEY_STORE_PASSWORD);
        Keyring.delete(hash + KEY_PASSWORD);
    }
    NbPreferences.forModule(KeystoreSelector.class).put(hash + KEY_STORE_PATH, path.getText());
    NbPreferences.forModule(KeystoreSelector.class).put(hash + KEY_ALIAS, alias.getText());
    NbPreferences.forModule(KeystoreSelector.class).putBoolean(hash + APK_V1, v1.isSelected());
    NbPreferences.forModule(KeystoreSelector.class).putBoolean(hash + APK_V2, v2.isSelected());
    NbPreferences.forModule(KeystoreSelector.class).putBoolean(hash + APK_RELEASE, release.isSelected());
    NbPreferences.forModule(KeystoreSelector.class).putBoolean(hash + APK_DEBUG, debug.isSelected());
    NbPreferences.forModule(KeystoreSelector.class).putBoolean(hash + REMEMBER_PASSWORDS, rememberPasswd.isSelected());
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:17,代码来源:KeystoreSelector.java

示例6: saveNBPassword

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
/**
 * Saves the given value as a netbeans.org password
 * Shouldn't be called in awt
 * @param password
 */
public static void saveNBPassword(char[] password) {
    if(password == null) {
        Keyring.delete(NB_BUGZILLA_PASSWORD);
    } else {
        Keyring.save(
            NB_BUGZILLA_PASSWORD,
            password,
            NbBundle.getMessage(
                NBBugzillaUtils.class,
                "NBRepositorySupport.password_keyring_description"));       // NOI18N

    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:NBBugzillaUtils.java

示例7: migrateRecord

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
private static char[] migrateRecord (String keyPrefix, String key) {
    String hashedKey = getKeyringKeyHashed(keyPrefix, key);
    if (NULL_HASHED_RECORDS.contains(hashedKey)) {
        return null;
    }
    char[] password = Keyring.read(hashedKey);
    if (password != null) {
        String fullKey = getKeyringKey(keyPrefix, key);
        Keyring.save(fullKey, password.clone(), fullKey);
        Keyring.delete(hashedKey);
    }
    // the record is not present, do not try to migrate next time
    NULL_HASHED_RECORDS.add(hashedKey);
    return password;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:KeyringSupport.java

示例8: testReplaceHashedKeyOldRecord

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
public void testReplaceHashedKeyOldRecord () throws Exception {
    String fullKey = KeyringSupport.getKeyringKeyHashed(prefix, key);
    char[] password = "password".toCharArray();
    Keyring.save(fullKey, password.clone(), "test record");
    
    // old key exists
    Assert.assertArrayEquals(password, Keyring.read(fullKey));
    // old key can be obtained back
    Assert.assertArrayEquals(password, KeyringSupport.read(prefix, key));
    // old key should be no longer present
    assertNull(Keyring.read(fullKey));
    // new key should be present
    Assert.assertArrayEquals(password, Keyring.read(KeyringSupport.getKeyringKey(prefix, key)));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:KeyringSupportTest.java

示例9: put

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
/**
 * Update password in memory. If user selected "remember password" option
 * before password is updated in Keyring.
 *
 * @param execEnv
 * @param password
 */
private void put(ExecutionEnvironment execEnv, char[] password) {
    String key = ExecutionEnvironmentFactory.toUniqueID(execEnv);
    if (keepPasswordsInMemory) {
        char[] old;
        if (password != null) {
            old = cache.put(key, Arrays.copyOf(password, password.length));
            Logger.getInstance().log(Level.FINEST, "PasswordManager.put({0}, non-null) stored password in memory", execEnv); // NOI18N
        } else {
            Logger.getInstance().log(Level.FINEST, "PasswordManager.put({0}, null) cleared password from memory", execEnv); // NOI18N
            old = cache.put(key, null);
        }
        if (old != null) {
            Arrays.fill(old, 'x');
        }
    }
    boolean store = NbPreferences.forModule(PasswordManager.class).getBoolean(STORE_PREFIX + key, false);
    if (store) {
        keyringIsActivated = true;
        if (password == null) {
            Keyring.delete(KEY_PREFIX + key);
        } else {
            Keyring.save(KEY_PREFIX + key, password,
                    NbBundle.getMessage(PasswordManager.class, "PasswordManagerPasswordFor", execEnv.getDisplayName())); // NOI18N
        }
        Logger.getInstance().log(Level.FINEST, "PasswordManager.put({0}, non-null) stored password in keyring", execEnv); // NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:PasswordManager.java

示例10: store

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
@NonNull
@Override
void store(@NonNull final Map<String,String> props) {
    super.store(props);
    Keyring.save(
        RemotePlatformProvider.createPropertyName(
            props.get(RemotePlatform.PLAT_PROP_ANT_NAME),
            PLAT_PROP_AUTH_PASSWD),
        getPassword().toCharArray(),
        null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ConnectionMethod.java

示例11: storePassword

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
public static void storePassword(final String key, final char[] pwd) {
    Parameters.notNull("key", key);
    Parameters.notNull("pwd", pwd);

    LOGGER.log(Level.FINE, "Storing password for {0}", key);
    Keyring.save(key,
            pwd,
            NbBundle.getMessage(DatabaseConnectionConvertor.class,
                "DatabaseConnectionConvertor.password_description", key)); //NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:DatabaseConnection.java

示例12: savePassword

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
public static void savePassword(char[] password, String prefix, String user, String url) throws MissingResourceException {
    if (password != null && password.length != 0) {                  
        Keyring.save(getPasswordKey(prefix, user, url), password, NbBundle.getMessage(BugtrackingUtil.class, "password_keyring_description", url)); // NOI18N
    } else {
        Keyring.delete(getPasswordKey(prefix, user, url));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:BugtrackingUtil.java

示例13: authorize

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
@Messages({
    "FormLogin.log_in=Log in to Hudson",
    "# {0} - server location", "# {1} - user name", "FormLogin.password_description=Password for {1} on {0}"
})
@Override
public String[] authorize(URL home) {
    FormLogin panel = new FormLogin();
    String server = HudsonManager.simplifyServerLocation(home.toString(), true);
    String username = loginPrefs().get(server, null);
    if (username != null) {
        panel.userField.setText(username);
        char[] savedPassword = Keyring.read(server);
        if (savedPassword != null) {
            panel.passField.setText(new String(savedPassword));
        }
    }
    panel.locationField.setText(home.toString());
    DialogDescriptor dd = new DialogDescriptor(panel, Bundle.FormLogin_log_in());
    if (DialogDisplayer.getDefault().notify(dd) != NotifyDescriptor.OK_OPTION) {
        return null;
    }
    username = panel.userField.getText();
    loginPrefs().put(server, username);
    String password = new String(panel.passField.getPassword());
    panel.passField.setText("");
    Keyring.save(server, password.toCharArray(), Bundle.FormLogin_password_description(home, username));
    return new String[] {username, password};
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:FormLogin.java

示例14: reqPassword

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings(
        value="PZLA_PREFER_ZERO_LENGTH_ARRAYS",
        justification="Returning null means user cancelled")
public char[] reqPassword(Resource<?> rsrc) {
    if(cancelled)
        return null;
    
    String key = "ssh://" + rsrc.getDetail().toString();
    char[] pwd = Keyring.read(key);
    
    if((pwd == null) || (counter > 0)) {
        PasswordAskerForm form = this.promptForPassword(rsrc);
        if(form != null) {
            pwd = form.getInputPassword();
            if(form.shouldSavePassword())
                Keyring.save(key, pwd.clone(), "Alidron credential for " + key);
        }
    }
    
    if(pwd != null)
        counter++;
    else
        cancelled = true;
    
    return pwd;
}
 
开发者ID:Alidron,项目名称:designer,代码行数:28,代码来源:PasswordAsker.java

示例15: setAuthenticationPassword

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
public static void setAuthenticationPassword(char[] password) {
    Keyring.save(ProxySettings.PROXY_AUTHENTICATION_PASSWORD, password,
            // XXX consider including getHttpHost and/or getHttpsHost
            NbBundle.getMessage(ProxySettings.class, "ProxySettings.password.description"));    // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:ProxySettings.java


注:本文中的org.netbeans.api.keyring.Keyring.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。