realm

Shiro学习笔记(1)-Shiro简介

时光总嘲笑我的痴心妄想 提交于 2019-11-30 13:16:55
什么是Shiro 简单地来说,Apache Shiro是Java的一个安全框架。 Shiro能实现的功能 (1)主要特性: Authentication: 验证用户身份,通常指登录。 Authorization :控制权限 Session Management :会话管理,用户登录成功后相关信息保存在会话中。可以是Web环境也可以是Java环境。 Cryptography:加密 (2)额外特性: Web Support:提供web应用支持,可以很方便集成到web环境 Caching: 缓存,来保存操作的高效性。 Concurrency: 支持多线程应用 Testing: 支持单元测试 Run As: 允许一个用户假装成另一个用户进行操作 Remember Me : 记住用户的身份信息 Shiro架构 从应用角度查看Shiro是如何工作的 从图片上可以看出来,Shiro有三个重要的概念: Subject: 主体,指的是当前和应用交互的用户,通常是人也可以指第三方服务或者后台进程等系列应用。所有的Subject都会绑定到SecurityManager,所以当我们和Subject进行交互时,其实真正作用的是SecurityManager。 SecurityManager:SecurityManager 是Shiro架构核心,它将所有的内部安全组件组合在一起。它充当一种引导者的角色

Shiro的实现流程

六月ゝ 毕业季﹏ 提交于 2019-11-30 12:27:40
获取当前的 Subject. 调用 SecurityUtils.getSubject(); 测试当前的用户是否已经被认证. 即是否已经登录. 调用 Subject 的 isAuthenticated() 若没有被认证, 则把用户名和密码封装为 UsernamePasswordToken 对象 1). 创建一个表单页面 2). 把请求提交到 SpringMVC 的 Handler 3). 获取用户名和密码. 执行登录: 调用 Subject 的 login(AuthenticationToken) 方法. 自定义 Realm 的方法, 从数据库中获取对应的记录, 返回给 Shiro. 1). 实际上需要继承 org.apache.shiro.realm.AuthenticatingRealm 类 2). 实现 doGetAuthenticationInfo(AuthenticationToken) 方法. 2). 实现 doGetAuthenticationInfo(AuthenticationToken) 方法. 由 shiro 完成对密码的比对. 1).密码的比对: 通过 AuthenticatingRealm 的 credentialsMatcher 属性来进行的密码的比对! 2). 如何把一个字符串加密为 MD5 替换当前 Realm 的 credentialsMatcher

How to completely remove Realm database from iOS?

半世苍凉 提交于 2019-11-30 12:12:43
Now I get error Property types for 'value' property do not match. Old type 'float', new type 'double' How to clear database or migrate is successfully? To completely delete the Realm file from disk and start from scratch, it's simply a matter of using NSFileManager to manually delete it. For example, to delete the default Realm file: NSFileManager.defaultManager().removeItemAtURL(Realm.Configuration.defaultConfiguration.fileURL!) If you want to preserve the Realm file, but completely empty it of objects, you can call deleteAll() to do so: let realm = try! Realm() try! realm.write { realm

Making GSON & Realm play nice

限于喜欢 提交于 2019-11-30 11:24:46
I'm trying to use Realm + GSON. If they would work together well, it would be a match made in heaven. However, when I extend my model objects with "extends RealmObject" I get this: 10-08 17:00:19.578 12492-12492/appwise.be.gsontestproject E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: appwise.be.gsontestproject, PID: 12492 java.lang.StackOverflowError at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:372) at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:376) at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:381) at com.google.gson.internal.$Gson

How to set primary key in Swift for Realm model

坚强是说给别人听的谎言 提交于 2019-11-30 10:45:23
I'm using Realm in a new iOS Swift project. I'm using Xcode 6.0.1 with iOS SDK 8.0 and Realm 0.85.0 I'm trying to use the new Realm primary key feature so I can do an addOrUpdateObject . Here is a sample model: import Foundation import Realm class Foo: RLMObject { dynamic var id = 0 dynamic var title = "" func primaryKey() -> Int { return id } } And how I'm trying to add/update a new object: let foo = Foo() foo.title = titleField.text foo.id = 1 // Get the default Realm let realm = RLMRealm.defaultRealm() // Add to the Realm inside a transaction realm.beginWriteTransaction() realm

Find path for Realm file with Realm React Native to use with Realm Browser

纵饮孤独 提交于 2019-11-30 09:47:02
On iOS, it is possible to inspect the contents of a Realm database by opening the corresponding file with the Realm Browser . The path to that file can be printed by using the following line of code (as noted here ): print(Realm.Configuration.defaultConfiguration.path) Is it possible to do the same when using the React Native version of Realm? Just found the answer myself by digging through the docs : console.log('create db:', db.path) Just in case you can't get the above to work. Here is how I did it: 1) import the file in which you define the schema and create a new realm into a component

Realm `access from incorrect thread` error when using shared code between IntentService and AsyncTask (Android)

人盡茶涼 提交于 2019-11-30 08:38:01
I have some code that downloads a "Current" object's JSON. But this same code needs to be called by an IntentService whenever an alarm goes off (when the app is not running any UI), and also by an AsyncTask while the app is running. However, I got an error saying Realm access from incorrect thread. Realm objects can only be accessed on the thread they were created. However, I do not understand how or why this stack trace got on a different thread. I was able to get rid of the error by copying all the shared code and sticking it directly into DownloadDealService's onHandleIntent method, but it

How to set primary key auto increment in realm android

折月煮酒 提交于 2019-11-30 08:03:08
I want to set primary key auto increment for my table. Here is my Class. I have set primary key but I want it to be auto increment primary key. public class users extends RealmObject { @PrimaryKey private int id; private long icn; private String name; private String email; private String password; private int phone; public String getName() { return name; } public int getId() { return id; } public void setId(int id) { this.id = id; } public long getIcn() { return icn; } public void setIcn(long icn) { this.icn = icn; } public void setName(String name) { this.name = name; } public String getEmail

Is there a realm browser for Linux?

别等时光非礼了梦想. 提交于 2019-11-30 07:32:29
I would like to browse a realm database using a browser. I'm a Linux user and I know the realm browser is only for MacOS. I also have knowledge about Stetho by Facebook and I read about this project https://github.com/uPhyca/stetho-realm too. However I don't want to add unnecessary libraries in my project and I install Google Chrome to browse a database, this is odd for me. So, do you know if there's a realm browser for Linux? Thanks in advance. I am happy to say that my previous answer is now obsolete. Realm Studio ( https://realm.io/products/realm-studio/ ) supports Linux, macOS and Windows.

Share realm between different users on Realm Object Server?

守給你的承諾、 提交于 2019-11-30 07:22:13
Is there currently a way to allow multiple users to access the same Realm? Right now the only way I could find is to use an 'app account' instead of an user account, as proposed in another question . thanks! In general, you can connect to a Realm file at a virtual path. They must be always absolute, so begin with a leading slash / and never carry a file suffix. Realms at a file name with two leading underscores are considered internal state of the Realm Object Server and have special meaning. If a path is prefixed by /~/ (like the home directory), the ~ will be expanded by the ID of the user,