草庐IT

delegating

全部标签

php - Laravel 5 和委托(delegate)。如何同时保存用户和附加角色

有没有人在Laravel5中尝试过EntrustforUserRoles&Permissions?我想同时添加和保存用户并附加角色。这是我的代码$role=Role::where('name','=','admin')->first();$user=newUser();$user->name=Input::get('name');$user->email=Input::get('email');$user->password=Hash::make(Input::get('password'));if($user->save()){$user->attachRole($role);ret

php - Laravel - 如何获得特定用户的委托(delegate)角色

我正在使用Laravel和ZizacoEntrust做一个小项目。以管理员身份登录时,我想查看特定用户的所有角色。找了半天也没找到。。。我该如何使用Entrust或使用SQL查询? 最佳答案 在你的用户类中添加publicfunctionroles(){return$this->belongsToMany('Role','assigned_roles');}然后就可以获取特定用户的所有角色$user=User::with('roles')->find(1);$roles=$user->roles;

java - 如何在自定义安全领域 (Glassfish) 中使用自定义委托(delegate)人?

我关注了instructions为我的glassfish创建自定义安全领域。一切正常,用户已正确验证。然而,问题如下:用户凭据以字符串形式加密realm解密这个字符串并对数据库执行身份验证(有效)不是使用解密的值作为securityContext中的主体,而是使用加密的字符串已传递。我已经尝试覆盖commit()方法以替换_userPrincipal或使用getSubject().getPrincipals().add(newPrincipalImpl("user")附加我自己的实现)。两者都没有按预期工作。基本上问题很简单:如何在glassfish的自定义安全领域中设置我自己的主体,

java - 为什么在java中加载类时委托(delegate)

如javase7文档所述TheClassLoaderclassusesadelegationmodeltosearchforclassesandresources.EachinstanceofClassLoaderhasanassociatedparentclassloader.Whenrequestedtofindaclassorresource,aClassLoaderinstancewilldelegatethesearchfortheclassorresourcetoitsparentclassloaderbeforeattemptingtofindtheclassorreso

java - Kotlin:如何在 Java 中使用委托(delegate)属性?

我知道您不能在Java中使用委托(delegate)属性语法,也不会像在Kotlin中那样享受“覆盖”set/get运算符的便利,但我仍然想使用现有的属性委托(delegate)在Java中。例如,一个简单的int委托(delegate):classIntDelegate{operatorfungetValue(thisRef:Any?,property:KProperty)=0}当然,在Kotlin中我们可以这样使用它:valxbyIntDelegate()但是我们如何在Java中以某种形式使用IntDelegate呢?这是开始,我相信:finalIntDelegatex=newIn

java - 检查单元测试是否委托(delegate)了所有方法

假设我有以下类(class)publicabstractclassFoo{publicintbar(){//implementation}publicabstractintbar2();}和一个基类,使为此类编写装饰器变得更容易publicclassFooWrapper{privatefinalFoodelegate;protectedFooWrapper(Foodelegate){this.delegate=delegate;}@Overridepublicintbar(){returndelegate.bar()}@Overridepublicintbar2(){returndel

java - 使用 Guice 将委托(delegate)人注入(inject) RESTEasy 中的资源方法

我正在使用RESTEasy和Guice开发RESTAPI,目前我正在尝试通过使用类似于Dropwizard中的@Auth的注释来合并基本身份验证。与@Path("hello")publicclassHelloResource{@GET@Produces("application/json")publicStringhello(@AuthfinalPrincipalprincipal){returnprincipal.getUsername();}}hello资源调用应该被一些代码拦截,这些代码使用授权HTTP请求header中传递的凭据执行基本身份验证,并成功将主体注入(inject)

java - 如何按类类型委托(delegate)给服务?

我有不同的类类型,根据某些情况,我想委托(delegate)给可以处理这些类类型的适当服务。例子:我有几个类如下。classStudent;classProf;...对于每个类都有一个服务,实现:interfaceIPersonService{voidrun();}我有一个mode是根据某些条件找到的:enumPersonType{STUDENT,PROF;}当我委托(delegate)时:@AutowiredprivateStudentServicestudentService;@AutowiredprivateProfServiceprofService;//@parammodea

java - 将哈希函数委托(delegate)给 hibernate 中未初始化的委托(delegate)会导致更改哈希代码

我对使用hibernate委托(delegate)给未初始化对象的hashCode()有问题。我的数据模型如下所示(以下代码经过高度修剪以强调问题并因此损坏,请勿复制!):classCompound{@FetchType.EAGERSetparts=newHashSet();StringsomeUniqueName;publicinthashCode(){finalintprime=31;intresult=1;result=prime*result+((getSomeUniqueName()==null)?0:getSomeUniqueName().hashCode());retur

java - Spring:委托(delegate)给自定义代理包装器进行接口(interface)注入(inject)

在一个非常大的遗留应用程序中,我有一些接口(interface)和类不实现这些接口(interface)。接口(interface)是基于类生成的,所以签名相同(除了接口(interface)在上面添加了另一个异常(exception))并且名称相似(因此很容易从接口(interface)名称中找到类名)。为了实现接口(interface),我们进行了一系列处理和记录调用,但基本上使用java.lang.reflect.Proxy委托(delegate)给类。简化后看起来像这样://ThiswillcreateaproxyandinvokehandlerthatcallsHelloWo