sso.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 (config.proxyCenterEnable){
  13. if (o2.typeOf(config.center)==="array"){
  14. config.center.forEach(function(c){
  15. c.port = window.location.port || 80;
  16. })
  17. }else{
  18. config.port = window.location.port || 80;
  19. }
  20. }
  21. if (!window.layout) window.layout = {};
  22. window.layout.config = config;
  23. getServiceAddress(config, function(address){
  24. var locate = window.location;
  25. var protocol = locate.protocol;
  26. var addressObj = layout.serviceAddressList["x_organization_assemble_authentication"];
  27. var address = protocol+"//"+addressObj.host+(addressObj.port==80 ? "" : ":"+addressObj.port)+addressObj.context;
  28. var uri = new URI(window.location.toString());
  29. var xtoken = uri.getData("xtoken");
  30. var client = uri.getData("client");
  31. var redirect = uri.getData("redirect");
  32. if (xtoken){
  33. var res = new Request.JSON({
  34. //url: "http://hbxa01.bf.ctc.com:20080/x_organization_assemble_authentication/jaxrs/sso",
  35. url: o2.filterUrl(address+"/jaxrs/sso"),
  36. secure: false,
  37. method: "POST",
  38. noCache: true,
  39. withCredentials: true,
  40. onSuccess: function(responseJSON, responseText){
  41. if (redirect){
  42. window.location = redirect;
  43. }else{
  44. window.location = "/";
  45. }
  46. }.bind(this),
  47. onFailure: function(xhr){
  48. window.location = "/";
  49. }.bind(this),
  50. onError: function(text, error){
  51. window.location = "/";
  52. }.bind(this)
  53. });
  54. res.setHeader("Content-Type", "application/json; charset=utf-8");
  55. var json = {"token": encodeURIComponent(xtoken), "client": client};
  56. res.send(JSON.encode(json));
  57. }else{
  58. if (redirect){
  59. window.location = redirect;
  60. }else{
  61. window.location = "/";
  62. }
  63. }
  64. });
  65. });
  66. });
  67. </script>
  68. </head>
  69. <body bgcolor="#faebd7" bgcolor="#ffc0cb">
  70. </body>
  71. </html>