sso.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <!DOCTYPE html>
  2. <html>
  3. <head lang="en">
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <!--<script src="res/framework/mootools/mootools-core-1.4.5-full-nocompat.js"></script>-->
  7. <!--<script src="res/framework/mootools/mootools-more-1.4.0.1-all_2.js"></script>-->
  8. <script src="res/framework/mootools/mootools-1.6.0.min.js"></script>
  9. <script src="res/common.js?v=0.3.16"></script>
  10. <script>
  11. function getServiceAddress(config, callback){
  12. var host = config.center.host || window.location.host;
  13. var port = config.center.port;
  14. var uri = "";
  15. if (!port || port=="80"){
  16. uri = "http://"+host+"/x_program_center/jaxrs/distribute/assemble/source/{source}";
  17. }else{
  18. uri = "http://"+host+":"+port+"/x_program_center/jaxrs/distribute/assemble/source/{source}";
  19. }
  20. var currenthost = window.location.hostname;
  21. uri = uri.replace(/{source}/g, currenthost);
  22. //var uri = "http://"+layout.config.center+"/x_program_center/jaxrs/distribute/assemble";
  23. MWF.restful("get", uri, null, function(json){
  24. var serviceAddressList = json.data;
  25. var addressObj = serviceAddressList["x_organization_assemble_authentication"];
  26. var address = "http://"+addressObj.host+(addressObj.port==80 ? "" : ":"+addressObj.port)+addressObj.context;
  27. if (callback) callback(address);
  28. }.bind(this));
  29. }
  30. COMMON.setContentPath("/x_desktop");
  31. COMMON.AjaxModule.load("mwf", function(){
  32. MWF.getJSON("res/config/config.json", function(config){
  33. getServiceAddress(config, function(address){
  34. var uri = new URI(window.location.toString());
  35. var xtoken = uri.getData("xtoken");
  36. if (xtoken){
  37. var res = new Request.JSON({
  38. //url: "http://hbxa01.bf.ctc.com:20080/x_organization_assemble_authentication/jaxrs/sso",
  39. url: address+"/jaxrs/sso",
  40. secure: false,
  41. method: "POST",
  42. noCache: true,
  43. withCredentials: true,
  44. onSuccess: function(responseJSON, responseText){
  45. debugger;
  46. window.location = "/";
  47. }.bind(this),
  48. onFailure: function(xhr){
  49. window.location = "/";
  50. }.bind(this),
  51. onError: function(text, error){
  52. window.location = "/";
  53. }.bind(this)
  54. });
  55. res.setHeader("Content-Type", "application/json; charset=utf-8");
  56. var json = {"token": xtoken};
  57. res.send(JSON.encode(json));
  58. }else{
  59. window.location = "/"
  60. }
  61. });
  62. });
  63. // MWF.require("MWF.process.RestActions", function(){
  64. // layout.restActions = new MWF.process.RestActions(Properties.action);
  65. // });
  66. });
  67. </script>
  68. </head>
  69. <body bgcolor="#faebd7" bgcolor="#ffc0cb">
  70. </body>
  71. </html>