如何在JAVA中将facebook身份验证添加到我的Rest应用程序中



我用jersey创建了一个RESTful应用程序,现在我正试图在我的应用程序中添加一个facebook身份验证接口,但我有点纠结于如何将身份验证连接到我的rest方法。

package service;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import metier.Cours;

@Path("rs")
public class Formation {

@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/FraisAnnuelles/{code}")
public Double FraisInscription(@PathParam(value="code")int code) {
return (Double)(30000+(Math.random()*(30000-25000)));
}

@GET
@Path("/Cours/{code}")
@Produces(MediaType.APPLICATION_XML)
public Cours getCours(@PathParam(value="code")int code) {
return new Cours(code,"web semantique",30);
}

@GET
@Path("/ListeCours")
@Produces(MediaType.APPLICATION_XML)
public List<Cours> getAllCours(){

List<Cours> listeCours=new ArrayList<>();
listeCours.add(new Cours(1,"web semantique",30));
listeCours.add(new Cours(2,"web service",20));
listeCours.add(new Cours(3,"IAD",26));
return listeCours;
}



}

我不确定你是否能做到这一点。用于登录facebook/google/some_identity_provider的协议是OpenID连接。从零开始,这本身就是一个很大的漏洞,但我对你所要求的可行性有一些怀疑的关键因素是,为了使用openid连接成功登录,身份提供者有一个数据库表,其中包含允许登录的URL列表,除非您尝试登录的url与该表中的某个值完全匹配,否则登录尝试将失败。

换言之,为了允许用户登录facebook/googlehttps://myblog.example.com/blog你需要联系facebook/google并询问他们"嘿,facebook/谷歌,你能添加吗https://myblog.example.com/blog到允许从漂亮登录的URL列表&";。我认为这两家公司在允许登录之前都需要你的网站的一些(显著的(最小尺寸,你绝对会随心所欲地接受他们的条款和条件,没有任何谈判的可能性。您可能需要为特权用户付费才能将其用作身份提供者。

最新更新