新泽西请求进行认证 [英] Jersey-request for authentication

查看:158
本文介绍了新泽西请求进行认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Glassfish工作的JavaEE 6 Web应用程序,这个应用程序已经具备了JSF的前端,并拥有认证机制((使用CDI和基于注解的安全性),所以有一个登录界面,用户输入用户名密码,preSS登录按钮和Java EE认证过程就开始了。

I have a working JavaEE 6 web application on Glassfish, this application already has a JSF frontend and has its authentication mechanism((Using CDI and annotation based security) So there is a login screen, user enters username password, press login button and Java EE authentication process begins.

现在我要还揭露我的一些服务类的REST服务的(我会用大概新泽西州),所以它也可以从移动设备到达。但让我担心的是登录的部分。

Now I want to "also" expose some of my service classes as a REST service (I will use Jersey probably), so it can also be reached from a mobile device. But what worries me is the login part.

我将使用完全相同的现有身份验证但现在我想我的应用程序将获得此证书由REST请求而不是从登录屏幕。然后继续使用已经存在现有的验证方法(从数据库校验用户名密码,,等)

I will use the exact same existing authentication But now I want my application will get this credentials from a Rest Request but not from the login screen. And then continue using the existing validation methods which already exists(check username password from DB,,etc)

我有点迷路了我怎么能做到这一点,我想我需要使用这些过滤器来拦截请求,并得到用户名密码,但不知道如何和哪一个?或者,我不需要这样的事?

I kinda got lost how can I do this, I think I need to use one of these filters to intercept the request and get the username password but not sure how and which one? Or I dont need anything like this?

推荐答案

您可以保护REST服务可以保护REST服务以同样的方式,例如:

You can protect the REST service the same way you protect the REST service, for example:

@Path("/foo")
@RolesAllowed({"admin", "customer"})
public class Foo {

@GET
@Produces("text/plain")
@RolesAllows("admin")
public void adminOnly() {}

public void adminOrCustomer() {}

}

我猜你已经有角色和映射他们,所以只需使用你得到了相同的角色,应用服务器将处理剩下的事情。

I guess you already have roles and mappings for them so just use the same roles you got, the application server will take care of the rest.

这篇关于新泽西请求进行认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆