realm

30分钟学会如何使用Shiro

余生长醉 提交于 2019-11-30 07:00:44
一、架构 要学习如何使用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,其实不然

composite primary key realm/swift

允我心安 提交于 2019-11-30 06:38:59
I'm new to swift and realm. I want to make a composite primary key and when I'm trying something like this : class DbLocation : Object { dynamic var id = 0 dynamic var tourId = 0 dynamic var uuid : String { return "\(id)\(tourId)" } override static func primaryKey() -> String? { return "uuid" } } I'm getting this error : 'Primary key property 'uuid' does not exist on object 'DbLocation' Anyone can help me out with an example how to create a composite primary key ? This should give you the answer: class DbLocation: Object { dynamic var id = 0 dynamic var tourId = 0 func setCompoundID(id: Int) {

在 Web 项目中应用 Apache Shiro

天大地大妈咪最大 提交于 2019-11-30 06:37:56
用户权限模型 在揭开 Shiro 面纱之前,我们需要认知用户权限模型。本文所提到用户权限模型,指的是用来表达用户信息及用户权限信息的数据模型。即能证明“你是谁?”、“你能访问多少受保护资源?”。为实现一个较为灵活的用户权限数据模型,通常把用户信息单独用一个实体表示,用户权限信息用两个实体表示。 用户信息用 LoginAccount 表示,最简单的用户信息可能只包含用户名 loginName 及密码 password 两个属性。实际应用中可能会包含用户是否被禁用,用户信息是否过期等信息。 用户权限信息用 Role 与 Permission 表示,Role 与 Permission 之间构成多对多关系。Permission 可以理解为对一个资源的操作,Role 可以简单理解为 Permission 的集合。 用户信息与 Role 之间构成多对多关系。表示同一个用户可以拥有多个 Role,一个 Role 可以被多个用户所拥有。 图 1. 用户权限模型 回页首 认证与授权 Shiro 认证与授权处理过程 被 Shiro 保护的资源,才会经过认证与授权过程。使用 Shiro 对 URL 进行保护可以参见“与 Spring 集成”章节。 用户访问受 Shiro 保护的 URL;例如 http://host/security/action.do。 Shiro 首先检查用户是否已经通过认证

Realm object has been deleted or invalidated

北城以北 提交于 2019-11-30 06:28:46
问题 When I start my app, I perform an API call to see whether there's new data available. The data is stored in my local Realm database, and some of it is displayed in the initial table view controller. Once the API call is finished, I check if some conditions are met that require me to delete a bunch of the previous data from the database and then create new objects. However, when I delete the old data, my app crashes with the following exception: 2015-08-06 11:56:32.057 MSUapp[19754:172864] ***

Realm VS Room in Android [closed]

狂风中的少年 提交于 2019-11-30 06:02:28
I'm building an app and I need to use a database in it. I'm considering using Room as it's new and hot right now. But I've heard a lot of great stuff about Realm too. Can someone point out the possible advantages of using each? I did my research and read the docs but I have no experience to understand it myself Room docs Realm docs EDIT : It's been some time and and I can point out another reason to use Room. Although you can use Realm and Transformations to tie things up with LiveData but with Room you can directly return LiveData (and also RXJava types using a plugin) for the DB, which will

K8s 从懵圈到熟练 – 镜像拉取这件小事

主宰稳场 提交于 2019-11-30 06:00:04
作者 | 声东 阿里云售后技术专家 导读 :相比 K8s 集群的其他功能,私有镜像的自动拉取,看起来可能是比较简单的。而镜像拉取失败,大多数情况下都和权限有关。所以,在处理相关问题的时候,我们往往会轻松的说:这问题很简单,肯定是权限问题。但实际的情况是,我们经常为一个问题,花了多个人的时间却找不到原因。这主要还是我们对镜像拉取,特别是私有镜像自动拉取的原理理解不深。这篇文章,作者将带领大家讨论下相关原理。 顺序上来说,私有镜像自动拉取会首先通过阿里云 Acr credential helper 组件,再经过 K8s 集群的 API Server 和 kubelet 组件,最后到 docker 容器运行时。但是我的叙述,会从后往前,从最基本的 docker 镜像拉取说起。 镜像拉取这件小事 为了讨论方便,我们来设想一个场景。很多人会使用网盘来存放一些文件,像照片,文档之类。当我们存取文件的时候,我们需要给网盘提供账户密码,这样网盘服务就能验证我们的身份。这时,我们是文件资源的所有者,而网盘则扮演着资源服务器的角色。账户密码作为认证方式,保证只有我们自己可以存取自己的文件。 这个场景足够简单,但很快我们就遇到新需求:我们需要使用一个在线制作相册的应用。按正常的使用流程,我们需要把网盘的照片下载到本地,然后再把照片上传到电子相册。这个过程是比较很繁琐的。我们能想到的优化方法是,让相册应用

Proper way to get Realm object by its primary key in Android Java

偶尔善良 提交于 2019-11-30 05:07:34
I wonder if there's a proper way to retrieve an object given its primary key in Realm for Android. I know the method objectForPrimaryKey does exists in Swift but there seems to be no such counterpart in Realm for Android. I really think that doing realm.where(EventInfo.class).equalTo("id", eventInfo.id).findFirst(); looks like a lot of waste (at least it is not wrist-friendly). Am I missing some method? I'm Currently using Realm 1.0.1 This is why I have a Realm repository like this one (which I wrote) public class CalendarEventRepositoryImpl extends LongRealmRepositoryImpl<CalendarEvent>

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

老子叫甜甜 提交于 2019-11-30 04:28:35
问题 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. 回答1: . can be used when query child object/list fields, for your case try below: RealmResult<Owner> owners = realm.query(Owner.class) .contains("cats.name",

Bundle prebuilt Realm files from Xamarin

℡╲_俬逩灬. 提交于 2019-11-30 04:02:47
I've seen a few SO posts detailing how you bundle prebuilt Realm files with iOS (Obj-c/swift) and Android (Java), but I can't find any information on bundling with Xamarin from a PCL or shared project; is this possible? I believe it would require a per-project *.realm file (e.g. copied from a single source at compile time) due to the nuances of how files are distributed in each platform, but that's a small price to pay to be able to access prebuilt data from shared code on both platforms. My objective is to avoid an initial download process when launching the App for the first time. You can

Realm Migration doesn't work

和自甴很熟 提交于 2019-11-30 04:01:47
let config = Realm.Configuration( // Set the new schema version. This must be greater than the previously used // version (if you've never set a schema version before, the version is 0). schemaVersion: 1, // Set the block which will be called automatically when opening a Realm with // a schema version lower than the one set above migrationBlock: { migration, oldSchemaVersion in // We haven’t migrated anything yet, so oldSchemaVersion == 0 if (oldSchemaVersion < 1) { // Nothing to do! // Realm will automatically detect new properties and removed properties // And will update the schema on disk