realm

SpringBoot与Shiro整合权限管理实战

别说谁变了你拦得住时间么 提交于 2019-11-28 12:33:51
SpringBoot与Shiro整合权限管理实战 作者 : Stanley 罗昊 【 转载请注明出处和署名,谢谢! 】 *观看本文章需要有一定SpringBoot整合经验* Shiro框架简介 Apache Shiro是一个强大且易用的Java安全框架,执行身份验证、授权、密码学和会话管理。使用Shiro的易于理解的API,可以快速、轻松地获得任何应用程序, 从最小的移动应用程序到最大的网络和企业应用程序。 分析Shiro的核心API 其实,Shiro的核心类有三个,分别是: 1.Subject:这个类呢,我们称之当前用户的主体,这个用户的主体包含了登陆、注销等等的一些方法,还有一些判断授权的一些方法; 2.SecurityManager:这个名称翻译过来就是,安全管理器的意思; 3.Realm:这个Realm呢其实我们Shiro去链接数据库的一个桥梁,因为,我们的程序需要去操作数据库去获取一些用户的信息,这些操作都需要Realm去完成; 这个三个API呢,都存在一些关系,比如.SecurityManager是需要去关联我们的Realm,Subject是需要把操作交给我们的SecurityManager,总结下来就是,Subject是需要去管理我们的SecurityManager,而SecurityManager去关联我们的Realm;

shiro权限控制配置

眉间皱痕 提交于 2019-11-28 12:27:21
shiro配置流程 web.xml中配置shiro的filter spring中配置shiro的过滤器工厂,指定对不同地址权限控制 , 传入安全管理器 配置安全管理器,传入realm,realm中定义具体授权和认证的流程 配置自定义凭证匹配器,指定token和info的匹配方式。 权限访问的配置 定义所有的权限的String集合 在自定义realm中重写doGetAuthoriaztionInfo(),创建所有权限的String集合, 创建SimpleAuthorizationInfo的对象,调用addStringPermission,添加权限的集合,返回该对象 控制访问指定资源时所需要的权限 a. 用代码校验。 //拿到当前的subject Subject subject = SecurityUtils.getSubject(); //检查是否具有指定权限 subject.checkPermission("部门管理"); b. 在过滤器工厂中配置拦截地址 /system/user/list.do = perms["部门管理"] /system/user/list.do = authc,roles[用户管理] c. 注解实现 @RequiresPermissions("用户管理") 使用shiro标签对视图渲染进行控制 <shiro:hasPermission name="用户管理

How to delete a class from realm file

与世无争的帅哥 提交于 2019-11-28 11:03:40
问题 My default Realm has several classes. I want to completely remove all references and delete all data for one of the classes. How can I do this? When I remove the class from my application, the class is still listed when I open the file in Realm Browser. 回答1: To completely remove a class from your Realm file you'll want to do two things: Remove the class from your application. Have your migration block call Migration.deleteData(_:) to remove all references to the class from the Realm. 来源:

Refreshing multiple Realm instances at once?

▼魔方 西西 提交于 2019-11-28 09:58:14
问题 I'm using a setup in which every Presenter that is a retained Fragment has its own Realm instance. However, this essentially means that these Realms are all on the main thread. Now that also means, if I want to modify the Realm, I either need to do that on the main thread (which is okay for small data sets, but I don't really want to do that with large data sets), or I need to do it on a background thread, and refresh every Realm instance at once (which is possible with a simple event to the

Sharing Realm fields on Android

蓝咒 提交于 2019-11-28 09:39:48
问题 Realm on Android doesn't support model inheritance/polymorphism. So is there any way to share fields on Android? We have 5 models that all share the same synchronization-related fields and code. We use inheritance in our current SQLite models; if we switch to Realm, is our only choice to duplicate the sync fields across each of the 5 model classes? As a workaround, I'm thinking about having those classes implement a Syncable interface with getters and setters for the shared fields, which at

How to save a struct to realm in swift?

南楼画角 提交于 2019-11-28 08:37:15
It is easy to use Realm with classes by inheriting from Object . But how would I save a struct containing several fields to realm in Swift? E.g. struct DataModel { var id = 0 var test = "test" } I know the documentation is clear about supported types. But maybe there is nice workaround or - even better - someone from realm could write about future plans about structs. To save a struct in Realm, means copying the data into a Realm Object . The reason why Realm Objects are classes and not structs is because they are not inert values, but auto-updating objects that represent the persisted data in

What is the most efficient way to store long list of Objects in Realm?

寵の児 提交于 2019-11-28 08:31:16
I'm trying to compare Realm with Snappydb ( This is my repo for those who would like to have a look at benchmark). I guess my way is wrong, as store-to-db time takes super long time in Realm in compare with Sanppydb. Benchmark shows following result. As you can see in the image, Realm is around 100-200 times slower than Snappydb. What I'm doing is creating 10,000 objects first and then storing them into the db. So, in my code I store a Booking object in this way (there is a for loop that iterates 10,000 times): public void storeBooking(final Booking booking) { mRealm.executeTransaction(new

How can I easily delete all objects in a Realm

ε祈祈猫儿з 提交于 2019-11-28 08:05:56
I have the choice of doing a migration, but I would prefer to delete everything in my defaultRealm(). How can I do this easily? realm.deleteObject(object) is the only function along with .deleteObjects. I have tried the following code: Method 1 realm.deleteObjects(RLMObject.objectsInRealm(realm, withPredicate: NSPredicate(value: true))) Method 2 realm.deleteObjects(Dog.allObjectsInRealm(realm)) realm.deleteObjects(Person.allObjectsInRealm(realm)) realm.deleteObjects(Goal.allObjectsInRealm(realm)) realm.deleteObjects(Goals.allObjectsInRealm(realm)) Both fail to prevent the migration exception.

How to delete object from Realm Database Android?

谁说胖子不能爱 提交于 2019-11-28 08:00:19
I want remove all message object from realm those are equal to userid RealmQuery<Message> rowQuery = realm.where(Message.class).equalTo(Message.USER_ID, userId); realm.beginTransaction(); //TODO : here I want to remove all messages where userId is equal to "9789273498708475" realm.commitTransaction(); Christian Melchior In 0.88.3 and below you can do: realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { RealmResults<Message> rows = realm.where(Message.class).equalTo(Message.USER_ID,userId).findAll(); rows.clear(); } }); From 0.89 (next release) this

Realm Cleaning Up Old Objects

[亡魂溺海] 提交于 2019-11-28 07:56:51
问题 I've just started using Realm for caching in my iOS app. The app is a store, with merchandise. As the user browses merchandise, I'm adding the items to the database. However, as these items do not stay available forever, it does not make sense to keep them in the database past a certain point, let's say 24hrs. Is there a preferred way to batch expire objects after an amount of time? Or would it be best to add a date property and query these objects on each app launch? 回答1: There's no default