sso.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  5. <meta charset="UTF-8">
  6. <title></title>
  7. <script src="../o2_core/o2.min.js"></script>
  8. <script src="js/sso.min.js"></script>
  9. <script>
  10. o2.addReady(function(){
  11. o2.JSON.get("res/config/config.json", function(config){
  12. if (!window.layout) window.layout = {};
  13. window.layout.config = config;
  14. getServiceAddress(config, function(address){
  15. var locate = window.location;
  16. var protocol = locate.protocol;
  17. var addressObj = layout.serviceAddressList["x_organization_assemble_authentication"];
  18. var address = protocol+"//"+addressObj.host+(addressObj.port==80 ? "" : ":"+addressObj.port)+addressObj.context;
  19. var uri = new URI(window.location.toString());
  20. var xtoken = uri.getData("xtoken");
  21. var client = uri.getData("client");
  22. var redirect = uri.getData("redirect");
  23. if (xtoken){
  24. var res = new Request.JSON({
  25. //url: "http://hbxa01.bf.ctc.com:20080/x_organization_assemble_authentication/jaxrs/sso",
  26. url: o2.filterUrl(address+"/jaxrs/sso"),
  27. secure: false,
  28. method: "POST",
  29. noCache: true,
  30. withCredentials: true,
  31. onSuccess: function(responseJSON, responseText){
  32. if (redirect){
  33. window.location = redirect;
  34. }else{
  35. window.location = "/";
  36. }
  37. }.bind(this),
  38. onFailure: function(xhr){
  39. window.location = "/";
  40. }.bind(this),
  41. onError: function(text, error){
  42. window.location = "/";
  43. }.bind(this)
  44. });
  45. res.setHeader("Content-Type", "application/json; charset=utf-8");
  46. var json = {"token": encodeURIComponent(xtoken), "client": client};
  47. res.send(JSON.encode(json));
  48. }else{
  49. if (redirect){
  50. window.location = redirect;
  51. }else{
  52. window.location = "/";
  53. }
  54. }
  55. });
  56. });
  57. });
  58. </script>
  59. </head>
  60. <body bgcolor="#faebd7" bgcolor="#ffc0cb">
  61. </body>
  62. </html>