Please tell me how to use Keychain API in MOE.
Here is my code. But I get “errSecParam(-50)” error code when “Security.SecItemCopyMatching” is executed.
NSMutableDictionary query = NSMutableDictionary.dictionary();
query.setObjectForKey(Security.kSecClassGenericPassword(), Security.kSecClass().toString());
query.setObjectForKey(“loginID”, Security.kSecAttrAccount().toString());
query.setObjectForKey(kCFBooleanTrue(), Security.kSecReturnData().toString());
CFDictionaryRef cf = ObjCRuntime.cast(query, CFDictionaryRef.class);
CFRetain(cf);
Ptr passwordPtr = null;
int err = Security.SecItemCopyMatching(cf, passwordPtr);
CFRelease(cf);
byte[] passphrase = null;
if(err != Enums.errSecSuccess){
System.out.println(“fail-” + err);
}else{
NSData password = ((NSData)passwordPtr);
passphrase = passwordPtr.getBytePtr().toByteArray((int)password.length());
}