realm

JFianl整合Shiro

假如想象 提交于 2019-12-01 11:42:30
原文: https://michaelzx.github.io/2016/jfinal-shiro-integration/ 入门必看 英文好的可以直接看 官网教程 ,英文不好的可以看下开涛的博客《 跟我学Shiro 》系列 在看教程之前,最好了解想一些shiro的概念: Apache Shiro Terminology 自己入门时踩的坑 一开始的时候,我自己搞了一个JFinal的全局 Interceptor ,用来做 Shiro 的权限判断。原因是一开始不了解Shiro,不知道运用 Shiro 的 Filter ,理所当然地从 JFinal 的层面进行思考。 当然,在 JFinal 的 Interceptor 中也是可以做一些权限的判断的,不过顺序上面先要经过 Shiro 的 Filter ,然后才会到 JFinal 的 Filter ,真正进入 JFinal 。 现成方案 可以直接拿来用,可以做参考,我在实践的时候,也参考了不少 JFinalShiroPlugin 项目地址: http://git.oschina.net/myaniu/jfinalshiroplugin JFinal_Authority 项目地址: http://git.oschina.net/jayqqaa12/JFinal_Authority Dreampie/jfinal-shiro 项目地址:

Realm's Swift module compiled with Swift 3.0 cannot be imported in Swift 3.0.1

六眼飞鱼酱① 提交于 2019-12-01 11:12:23
问题 I just started using Realm 2.0.4 yesterday with Xcode 8 and it worked fine. Today I updated to Xcode 8.1 and it no longer will compile. I get an error saying "Module compiled with Swift 3.0 cannot be imported in Swift 3.0.1." How can I fix this? I have deleted Realm.framework and RealmSwift.framework from the embedded framework table and dropped in the 3.0.1 version, but the issue persists. I have deleted the DerivedData folder and it didn't work. What do I do? I am not using CocoaPods or

way to purge all but one object types (models) in a realm

和自甴很熟 提交于 2019-12-01 10:56:50
问题 I want to realm.delete() all but one model in my realm. Is there any way to do this without listing all of them? Maybe a way to loop through all the types currently existing in a realm? 回答1: You can access the types from your Realm configuration, filter them to exclude the one you want to keep than delete each object of each type that you don't want to keep. let typeToBeKept = MyObjectClass.self realm.configuration.objectTypes?.filter{$0 != typeToBeKept}.forEach{ type in try! realm.write {

how can I re-order the Realm table using tableview in swift

心不动则不痛 提交于 2019-12-01 10:41:16
问题 I want to re-order my list of Favourites in a tableview in swift using Realm as the datasource. The following code works, however, it creates a list of Favourites twice. I am struggling to delete the data in order to be able to re-load the Favourites in the right order. Here is the code: //MARK:REORDER list override func tableView(tableView: UITableView, var moveRowAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath) { let favouritesR = realm.objects

Realm String greaterThan

佐手、 提交于 2019-12-01 10:30:40
Is there any way to find all (or just the next) RealmObject s with Strings lexicographically greater than the target? Something like MyEntry next = realm.where(MyEntry.class) .greaterThan("name", current) .findAllSorted("name") .first(); which did not work, because greaterThan is not implemented for String s. As a non-db-workaround, you can use List<MyEntry> l = realm.where(MyEntry.class) .findAllSorted("name"); int pos = l.indexOf(entryWithName); MyEntry next = l.get((pos+1)%l.size()); This does the searching outside of the db. Possibly not as well-performing, and not as readable, but it

How to Show Preload data to RecyclerView using Realm

吃可爱长大的小学妹 提交于 2019-12-01 10:08:23
问题 In my App I am using Realm as local database. I am using recyclerview widget to show these data. Now initiallay I want to show some preload data in recycler view which would be stored in realm as well. then I will implement add, edit, delete method. But I am having fatal error while trying to run this app. I am very new in Realm. I cannot identify which problem is this. I have Solved this problem with the help of answer code. here is the solution for this. Solved Code And My Activity Class is

Shiro

删除回忆录丶 提交于 2019-12-01 10:01:37
一、架构 要学习如何使用Shiro必须先从它的架构谈起,作为一款安全框架Shiro的设计相当精妙。Shiro的应用不依赖任何容器,它也可以在JavaSE下使用。但是最常用的环境还是JavaEE。下面以用户登录为例: (1)使用用户的登录信息创建令牌 UsernamePasswordToken token = new UsernamePasswordToken(username, password); token可以理解为用户令牌,登录的过程被抽象为Shiro验证令牌是否具有合法身份以及相关权限。 (2)执行登陆动作 SecurityUtils.setSecurityManager(securityManager); // 注入SecurityManager Subject subject = SecurityUtils.getSubject(); // 获取Subject单例对象 subject.login(token); // 登陆 Shiro的核心部分是SecurityManager,它负责安全认证与授权。Shiro本身已经实现了所有的细节,用户可以完全把它当做一个黑盒来使用。SecurityUtils对象,本质上就是一个工厂类似Spring中的ApplicationContext。Subject是初学者比较难于理解的对象,很多人以为它可以等同于User,其实不然

Android Kotlin Realm Proper Way of Query+ Return Unmanaged Items on Bg Thread

偶尔善良 提交于 2019-12-01 09:45:45
问题 What is the proper way of querying and returning an unmanaged result of items with realm, everything in the background thread?. I'm using somethibf like this: return Observable.just(1) .subscribeOn(Schedulers.io()) .map { val realm = Realm.getDefaultInstance() val results = realm.where(ItemRealm::class.java) .equalTo("sent", false).findAll() realm to results } .map { val (realm, results) = it val unManagedResults = realm.copyFromRealm(results) realm.close() unManagedResults } } And then

Shiro第二章Authentication

旧街凉风 提交于 2019-12-01 08:20:41
authentication认证 认证(Authentication):身份验证的过程--也就是证明一个用户的真实身份。为了证明用户身份,需要提供系统理解和相信的身份信息和证据。 需要通过向 Shiro 提供用户的身份(principals)和证明(credentials )来判定是否和系统所要求的匹配。 Principals(身份) 是Subject的“标识属性”,可以是任何与Subject相关的标识 Credentials(证明) 通常是只有 Subject 知道的机密内容,用来证明他们真正拥有所需的身份,一些简单的证书例子如密码、指纹、眼底扫描和X.509证书等 Authenticating Subjects Subject 验证的过程可以有效地划分分以下三个步骤: 1.收集 Subject 提交的身份和证明; //最常用的情况是 username/password 对: UsernamePasswordToken token = new UsernamePasswordToken(username, password); //”Remember Me” 功能是内建的 token.setRememberMe(true); 2.向 Authentication 提交身份和证明; Subject currentUser = SecurityUtils.getSubject();

Shiro入门1

◇◆丶佛笑我妖孽 提交于 2019-12-01 07:48:51
1、Shiro是什么? Apache Shiro 是 Java 的一个安全框架。 2.Shiro一些基本概念 3.Shiro结合数据库。 RBAC的概念 Roles base access controll 基于角色的权限控制 或者 Resources base access controll 基于资源的权限控制 通俗来说,你得获得对应的资源或者权限才能够进行访问 表结构 最简单的权限控制,是建立在 “用户” —— ”角色“ —— “权限” 之间的关系。 其中用户和角色之间是多对多关系,角色和权限是多对多关系。 在进行表的设计时,可以考虑在用户、角色、权限三张表的基础上,再建立 用户-角色表,角色-权限表来维护他们之间的关系。 所以,最简单的RBAC需要五张表来实现。 4.编码,通过数据库的设计实现最简单的权限控制 SQL: 1 DROP DATABASE IF EXISTS shiro; 2 CREATE DATABASE shiro DEFAULT CHARACTER SET utf8; 3 USE shiro; 4 5 drop table if exists user; 6 drop table if exists role; 7 drop table if exists permission; 8 drop table if exists user_role; 9