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


Java Keyring.read方法代码示例

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


在下文中一共展示了Keyring.read方法的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: restorePassword

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
private void restorePassword() {
    if (this.connectionFileName == null) {
        LOGGER.log(Level.FINE, "No connectionFileName for {0}", this);
        pwd = "";
        rpwd = false;
        return ;
    }
    final String key = this.connectionFileName;
    // If the password was saved, then it means the user checked
    // the box to say the password should be remembered.
    char[] chars = Keyring.read(key);
    if (chars != null) {
        LOGGER.log(Level.FINE, "A password read for {0}", key);
        pwd = String.valueOf(chars);
        rpwd = true;
    } else {
        LOGGER.log(Level.FINE, "No password read for {0}", key);
        pwd = "";
        rpwd = false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:DatabaseConnection.java

示例3: read

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
/**
 * Returns a stored password for the 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. If set to <code>null</code> only keyPrefix is used as the final key
 * @return stored password or null
 */
public static char[] read (String keyPrefix, String key) {
    char[] retval = Keyring.read(getKeyringKey(keyPrefix, key));
    if (retval == null) {
        retval = migrateRecord(keyPrefix, key);
    }
    if (LOG.isLoggable(Level.FINE)) {
        if (retval == null) {
            LOG.log(Level.FINE, "No password for {0}:{1}", new String[] {keyPrefix, key}); //NOI18N
        } else if (PRINT_PASSWORDS) {
            LOG.log(Level.FINEST, "Getting password: {0}:{1} -- \"{2}\"", new Object[] { keyPrefix, key, new String(retval) }); //NOI18N
        }
    }
    return retval;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:KeyringSupport.java

示例4: 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

示例5: getAuthenticationPassword

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
public static char[] getAuthenticationPassword () {
    String old = getPreferences().get(PROXY_AUTHENTICATION_PASSWORD, null);
    if (old != null) {
        getPreferences().remove(PROXY_AUTHENTICATION_PASSWORD);
        setAuthenticationPassword(old.toCharArray());
    }
    char[] pwd = Keyring.read(PROXY_AUTHENTICATION_PASSWORD);
    return pwd != null ? pwd : new char[0];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ProxySettings.java

示例6: NbAuthenticatorPanel

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
/** Creates new form AuthenticatorPanel */
public NbAuthenticatorPanel(String realmName) {
    this.realmName = realmName;
    initComponents();
    prefs = NbPreferences.forModule(NbAuthenticatorPanel.class).node("authentication"); // NOI18N
    keyringKey = "authentication." + realmName; // NOI18N
    String username = prefs.get(realmName, null);
    if (username != null) {
        userName.setText(username);
        char[] pwd = Keyring.read(keyringKey);
        if (pwd != null) {
            password.setText(new String(pwd));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:NbAuthenticatorPanel.java

示例7: getPassword

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
/**
 *
 * @param execEnv
 * @return password from memory or from Keyring if user selected "remember
 * password" in previous IDE invocation
 */
public char[] getPassword(ExecutionEnvironment execEnv) {
    String key = ExecutionEnvironmentFactory.toUniqueID(execEnv);
    if (keepPasswordsInMemory) {
        char[] cachedPassword = cache.get(key);
        if (cachedPassword != null) {
            Logger.getInstance().log(Level.FINEST, "PasswordManager.get({0}) found password in memory", execEnv); // NOI18N
            return cachedPassword;
        }
    }
    boolean stored = NbPreferences.forModule(PasswordManager.class).getBoolean(STORE_PREFIX + key, false);
    if (stored) {
        keyringIsActivated = true;
        char[] keyringPassword = Keyring.read(KEY_PREFIX + key);
        if (keepPasswordsInMemory && keyringPassword != null) {
            char[] old = cache.put(key, Arrays.copyOf(keyringPassword, keyringPassword.length));
            if (old != null) {
                Arrays.fill(old, 'x');
            }
        }
        Logger.getInstance().log(Level.FINEST, "PasswordManager.get({0}) found password in keyring", execEnv); // NOI18N
        return keyringPassword;
    }

    Logger.getInstance().log(Level.FINEST, "PasswordManager.get({0}) failed to find password", execEnv); // NOI18N
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:PasswordManager.java

示例8: create

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
@NonNull
@Override
Authentification create(@NonNull final Map<String,String> props) {
    String user = props.get(PLAT_PROP_AUTH_USER);
    if (user == null) {
        throw new IllegalStateException("No user"); //NOI18N
    }
    char[] passwd = Keyring.read(RemotePlatformProvider.createPropertyName(
        props.get(RemotePlatform.PLAT_PROP_ANT_NAME),
        Password.PLAT_PROP_AUTH_PASSWD));
    final String passwdStr;
    if (passwd == null) {
        LOG.log(
            Level.WARNING,
            "No password for: {0} for platform: {1}",   //NOI18N
            new Object[]{
                user,
                props.get(RemotePlatform.PLAT_PROP_ANT_NAME)
            });
        passwdStr = ""; //NOI18N
    } else {
        passwdStr = String.valueOf(passwd);
    }
    return new Password(
        user,
        passwdStr);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:ConnectionMethod.java

示例9: 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

示例10: KeystoreSelector

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
/**
 * Creates new form KeystoreSelector
 */
public KeystoreSelector(Project project) {
    initComponents();
    hash = "ANDROID_" + project.getProjectDirectory().getPath().hashCode();
    char[] keystorePasswd = Keyring.read(hash + KEY_STORE_PASSWORD);
    char[] keyPasswd = Keyring.read(hash + KEY_PASSWORD);
    if (keystorePasswd != null) {
        keystorePassword.setText(new String(keystorePasswd));
    }
    if (keyPasswd != null) {
        keyPassword.setText(new String(keyPasswd));
    }
    path.setText(NbPreferences.forModule(KeystoreSelector.class).get(hash + KEY_STORE_PATH, ""));
    alias.setText(NbPreferences.forModule(KeystoreSelector.class).get(hash + KEY_ALIAS, ""));
    v1.setSelected(NbPreferences.forModule(KeystoreSelector.class).getBoolean(hash + APK_V1, true));
    v2.setSelected(NbPreferences.forModule(KeystoreSelector.class).getBoolean(hash + APK_V2, true));
    release.setSelected(NbPreferences.forModule(KeystoreSelector.class).getBoolean(hash + APK_RELEASE, true));
    debug.setSelected(NbPreferences.forModule(KeystoreSelector.class).getBoolean(hash + APK_DEBUG, false));
    rememberPasswd.setSelected(NbPreferences.forModule(KeystoreSelector.class).getBoolean(hash + REMEMBER_PASSWORDS, true));
    path.addKeyListener(this);
    alias.addKeyListener(this);
    keystorePassword.addKeyListener(this);
    keyPassword.addKeyListener(this);
    v1.addActionListener(keyEmulatorListener);
    v2.addActionListener(keyEmulatorListener);
    debug.addActionListener(keyEmulatorListener);
    release.addActionListener(keyEmulatorListener);
    keyReleased(null);
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:32,代码来源:KeystoreSelector.java

示例11: getKeyringValue

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
private String getKeyringValue(String key) {
    String toReturn = "";
    char[] keyValue = Keyring.read(key);
    if (keyValue != null) {
        toReturn = new String(keyValue);
    }
    return toReturn;
}
 
开发者ID:fundacionjala,项目名称:oblivion-netbeans-plugin,代码行数:9,代码来源:FileSystemCredentialStorage.java

示例12: loadValue

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
@Override
public String loadValue(String value) {
    final char[] readValue = Keyring.read(value);
    if (readValue == null) {
        return "";
    }
    return String.valueOf(readValue);
}
 
开发者ID:massimozappino,项目名称:tagmycode-netbeans,代码行数:9,代码来源:PasswordKeyChain.java

示例13: 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

示例14: getNBPassword

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
private static char[] getNBPassword() {
    return Keyring.read(NB_BUGZILLA_PASSWORD);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:RepositoryRegistry.java

示例15: forbidden

import org.netbeans.api.keyring.Keyring; //导入方法依赖的package包/类
@Messages({"# {0} - server location", "# {1} - user name", "APITokenConnectionAuthenticator.password_description=API token for {1} on {0}"})
@org.netbeans.api.annotations.common.SuppressWarnings("DM_DEFAULT_ENCODING")
@Override public URLConnection forbidden(URLConnection conn, URL home) {
    String version = conn.getHeaderField("X-Jenkins");
    if (version == null) {
        if (conn.getHeaderField("X-Hudson") == null) {
            LOG.log(Level.FINE, "neither Hudson nor Jenkins headers on {0}, assuming might be Jenkins", home);
        } else {
            LOG.log(Level.FINE, "disabled on non-Jenkins server {0}", home);
            return null;
        }
    } else if (new HudsonVersion(version).compareTo(new HudsonVersion("1.426")) < 0) {
        LOG.log(Level.FINE, "disabled on old ({0}) Jenkins server {1}", new Object[] {version, home});
        return null;
    } else {
        LOG.log(Level.FINE, "enabled on {0}", home);
    }
    APITokenConnectionAuthenticator panel = new APITokenConnectionAuthenticator();
    String server = HudsonManager.simplifyServerLocation(home.toString(), true);
    String key = "tok." + server;
    String username = FormLogin.loginPrefs().get(server, null);
    if (username != null) {
        panel.userField.setText(username);
        char[] savedToken = Keyring.read(key);
        if (savedToken != null) {
            panel.tokField.setText(new String(savedToken));
        }
    }
    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();
    LOG.log(Level.FINE, "trying token for {0} on {1}", new Object[] {username, home});
    FormLogin.loginPrefs().put(server, username);
    String token = new String(panel.tokField.getPassword());
    panel.tokField.setText("");
    Keyring.save(key, token.toCharArray(), Bundle.APITokenConnectionAuthenticator_password_description(home, username));
    BASIC_AUTH.put(home.toString(), new Base64(0).encodeToString((username + ':' + token).getBytes()).trim());
    try {
        return conn.getURL().openConnection();
    } catch (IOException x) {
        LOG.log(Level.FINE, null, x);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:48,代码来源:APITokenConnectionAuthenticator.java


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