realm

SWIFT - Realm db encryption not working

泪湿孤枕 提交于 2019-11-30 20:51:35
问题 Im trying to encrypt the data stored in the realm database. I followed the Sample Code mentioned on Realm's Swift page. I want to encrypt the data NOT the database file. Below is the code I'm using: var error: NSError? = nil let configuration = Realm.Configuration(encryptionKey: EncryptionManager().getKey()) if let realmE = Realm(configuration: configuration, error: &error) { // Add an object realmE.write { realmE.add(objects, update: T.primaryKey() != nil) } } Where objects is a list of

How do I query RealmObject that have RealmList that contains specified value

浪子不回头ぞ 提交于 2019-11-30 19:19:44
I have a RealmObject (let's say Owner ) and it has RealmList<Cat> . Cat has a property name . How do I query for all the Owner s who have cat with specified name ? I tried: RealmResult<Owner> owners = realm.query(Owner.class) .contains("cats", "Garfield") .findAll(); But it does not work. PS most probably duplicate but cant find. . can be used when query child object/list fields, for your case try below: RealmResult<Owner> owners = realm.query(Owner.class) .contains("cats.name", "Garfield") .findAll(); 来源: https://stackoverflow.com/questions/34924574/how-do-i-query-realmobject-that-have

shiro小记

落花浮王杯 提交于 2019-11-30 19:14:12
今天主要看了shiro的认证,授权功能初步了解了一下,其他的功能用的不多,之后再看。 认证 下面的例子是以继承了AuthenticatingRealm的自定义Realm来实现自定义认证。 认证依赖于方法doGetAuthenticationInfo,需要返回一个AuthenticationInfo,通常返回一个他的子类SimpleAuthenticationInfo,构造方法的第一个参数是用户名,第二个是验证密码,第三个是当前realm的className。 package com.demo.realms; import org.apache.shiro.authc.*; import org.apache.shiro.realm.AuthenticatingRealm; public class MyRealm extends AuthenticatingRealm { @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) { System.out.println("MyRealm认证中---->用户:"+token.getPrincipal()); // 可以从token中获取用户名来从数据库中查询数据 UsernamePasswordToken

How to get a standalone / unmanaged RealmObject using Realm Xamarin

风格不统一 提交于 2019-11-30 19:02:13
Is there a way that when I read an object from Realm that it can become a standalone or unmanaged object? In EF, this is called no tracking. The usage for this would be when I want to implement more business logic on my data objects before they are updated on the persistent data storage. I may want to give the RealmObject to a ViewModel, but when the changes come back from the ViewModel, I want to compare the disconnected object to the object in the datastore to determine what was changed, so If there was a way that I could disconnect the object from Realm when I give it to the ViewModel, then

shiro权限管理(认证和授权)

跟風遠走 提交于 2019-11-30 18:49:34
Shiro介绍 1.shiro介绍:Shirp是apache旗下一个开源框架,它将软件系统的安全认证相关的功能抽取出来,实现用户身份认证,权限授权,加密,会话管理等功能,组成一个通用的安全认证框架。 2.Shiro框架 3.对象: a) Subject:主体,外部应用与subject进行交互,subject记录了当前操作用户,将用户的概念理解为当前操作的主体,可能是通过浏览器请求的用户,也可能是一个运行的程序。Subject在shiro中是一个接口,接口中定义了很多认证授权的相关方法,外部程序通过subject进行认证授权,而subject是通过SecurityManager安全管理器进行认证授权。 b) SecurityManager:安全管理器,对全部的subject进行安全管理,它是shiro的核心,负责对所有的subject进行安全管理。通过SecurityManager可以完成subject的认证,授权等,实质上SecurityManager是通过Authenticator进行认证,通过Authorizer进行授权,通过SessuionManager进行会话管理等。SecurityManager是一个接口,继承了Authenticator,Authorizer,SessionManager三个接口。 c) Authenticator:认证器,对用户身份进行认证

How to install realm as a gradle dependency?

可紊 提交于 2019-11-30 18:43:08
I am completely new to realm. I want to use realm db in my android project. I have gone through the official Realm documentation . I need to set up realm in my android project. For that I have added the gradle dependancy as buildscript { repositories { jcenter() } dependencies { classpath "io.realm:realm-gradle-plugin:0.88.2" } } apply plugin: 'realm-android' This is what they have given in documentation. But this doesn't work for me. It gives error saying Plugin with id 'realm-android' not found . This is my build.gradle file apply plugin: 'com.android.application' apply plugin: 'realm

Detect a realm authentication failure reason in Tomcat

无人久伴 提交于 2019-11-30 18:30:53
问题 I wrote a custom Realm for Tomcat 7. I wrap it in the lockout Realm provided by the default installation of Tomcat. The lockout feature works fine, but in my web.xml, I have <error-page> <error-code>403</error-code> <location>/forbidden.html</location> </error-page> which will direct any users that do not authenticate to the page. However, it also redirects correctly authenticated users to the page if they are locked out. Is there someway I can detect the difference when a user incorrectly

Realm accessed from incorrect thread - again

◇◆丶佛笑我妖孽 提交于 2019-11-30 18:21:24
I noticed many problems with accessing realm object, and I thought that my solution would be solving that. So I have written simple helping method like this: public func write(completion: @escaping (Realm) -> ()) { DispatchQueue(label: "realm").async { if let realm = try? Realm() { try? realm.write { completion(realm) } } } } I thought that completion block will be fine, because everytime I write object or update it, I use this method above. Unfortunately I'm getting error: libc++abi.dylib: terminating with uncaught exception of type realm::IncorrectThreadException: Realm accessed from

Realm - Can't use object after having been deleted

狂风中的少年 提交于 2019-11-30 18:01:06
问题 I have a video player in my app. There is a list of videos in a collection view. If you tap on one of the cells, a new view controller appears to play the selected video. Also, you can cycle through all of the videos from the collection view in this new view controller because the entire list is passed. The problem is: When the user is in the PlayerVC , they can unfavorite a Video . If they do this, I delete the Video object from Realm. However, this causes a: Terminating app due to uncaught

Android Realm initialization in project

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 17:52:27
As seen in the official documentation on how to use Realm // Initialize Realm Realm.init(context); // Get a Realm instance for this thread Realm realm = Realm.getDefaultInstance(); I added dependencie to my project classpath "io.realm:realm-gradle-plugin:2.0.2" I can use this library normally but static method init apparently does not exist . Can someone post an example of how to initialize and save example object to database using this library? There's really not too many tutorials and the usage looks really easy after you manage to fire it up. Realm initialization sets up default