rename to MacOsKeychainLibrary

This commit is contained in:
Vladimir Krivosheev
2016-08-05 19:24:25 +02:00
parent 6109235646
commit 1afcda86c7
2 changed files with 6 additions and 6 deletions
@@ -25,9 +25,9 @@ val isOSXCredentialsStoreSupported: Boolean
// http://developer.apple.com/mac/library/DOCUMENTATION/Security/Reference/keychainservices/Reference/reference.html
// It is very, very important to use CFRelease/SecKeychainItemFreeContent You must do it, otherwise you can get "An invalid record was encountered."
interface OSXKeychainLibrary : com.sun.jna.Library {
interface MacOsKeychainLibrary : com.sun.jna.Library {
companion object {
private val LIBRARY = com.sun.jna.Native.loadLibrary("Security", OSXKeychainLibrary::class.java) as OSXKeychainLibrary
private val LIBRARY = com.sun.jna.Native.loadLibrary("Security", MacOsKeychainLibrary::class.java) as MacOsKeychainLibrary
fun saveGenericPassword(serviceName: ByteArray, accountName: String, password: CharArray) {
saveGenericPassword(serviceName, accountName, Charsets.UTF_8.encode(CharBuffer.wrap(password)))
@@ -15,7 +15,7 @@
*/
package org.jetbrains.keychain
import com.intellij.ide.passwordSafe.OSXKeychainLibrary
import com.intellij.ide.passwordSafe.MacOsKeychainLibrary
import com.intellij.openapi.util.PasswordUtil
import gnu.trove.THashMap
@@ -39,7 +39,7 @@ class OsXCredentialsStore(serviceName: String) : CredentialsStore {
return credentials
}
val data = OSXKeychainLibrary.findGenericPassword(getServiceName(sshKeyFile), accountName) ?: return null
val data = MacOsKeychainLibrary.findGenericPassword(getServiceName(sshKeyFile), accountName) ?: return null
if (sshKeyFile == null) {
val separatorIndex = data.indexOf('@')
if (separatorIndex > 0) {
@@ -73,12 +73,12 @@ class OsXCredentialsStore(serviceName: String) : CredentialsStore {
}
val data = if (sshKeyFile == null) "${PasswordUtil.encodePassword(credentials.id)}@${PasswordUtil.encodePassword(credentials.token)}" else credentials.token!!
OSXKeychainLibrary.saveGenericPassword(getServiceName(sshKeyFile), accountName, data)
MacOsKeychainLibrary.saveGenericPassword(getServiceName(sshKeyFile), accountName, data)
}
override fun reset(host: String) {
if (accountToCredentials.remove(host) != null) {
OSXKeychainLibrary.deleteGenericPassword(serviceName, host)
MacOsKeychainLibrary.deleteGenericPassword(serviceName, host)
}
}
}