sso.html 3.2 KB
Newer Older
NoSubject's avatar
NoSubject 已提交
1
<!DOCTYPE html>
R
roo00 已提交
2 3
<html lang="zh-CN">
<head>
NoSubject's avatar
NoSubject 已提交
4 5 6
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta charset="UTF-8">
    <title></title>
R
roo00 已提交
7
    <script src="../o2_core/o2.min.js"></script>
NoSubject's avatar
NoSubject 已提交
8
    <script src="js/sso.min.js"></script>
NoSubject's avatar
NoSubject 已提交
9
    <script>
NoSubject's avatar
NoSubject 已提交
10 11
        o2.addReady(function(){
            o2.JSON.get("res/config/config.json", function(config){
12 13 14
                if (config.proxyCenterEnable){
                    if (o2.typeOf(config.center)==="array"){
                        config.center.forEach(function(c){
NoSubject's avatar
NoSubject 已提交
15
                            c.port = window.location.port || 80;
16 17
                        })
                    }else{
NoSubject's avatar
NoSubject 已提交
18
                        config.port = window.location.port || 80;
19 20
                    }
                }
NoSubject's avatar
NoSubject 已提交
21 22
                if (!window.layout) window.layout = {};
                window.layout.config = config;
NoSubject's avatar
NoSubject 已提交
23
                getServiceAddress(config, function(address){
24 25 26 27 28
                    var locate = window.location;
                    var protocol = locate.protocol;
                    var addressObj = layout.serviceAddressList["x_organization_assemble_authentication"];
                    var address = protocol+"//"+addressObj.host+(addressObj.port==80 ? "" : ":"+addressObj.port)+addressObj.context;

NoSubject's avatar
NoSubject 已提交
29 30 31
                    var uri = new URI(window.location.toString());
                    var xtoken = uri.getData("xtoken");
                    var client = uri.getData("client");
NoSubject's avatar
NoSubject 已提交
32
                    var redirect = uri.getData("redirect");
NoSubject's avatar
NoSubject 已提交
33 34 35
                    if (xtoken){
                        var res = new Request.JSON({
                            //url: "http://hbxa01.bf.ctc.com:20080/x_organization_assemble_authentication/jaxrs/sso",
NoSubject's avatar
NoSubject 已提交
36
                            url: o2.filterUrl(address+"/jaxrs/sso"),
NoSubject's avatar
NoSubject 已提交
37 38 39 40 41
                            secure: false,
                            method: "POST",
                            noCache: true,
                            withCredentials: true,
                            onSuccess: function(responseJSON, responseText){
NoSubject's avatar
NoSubject 已提交
42 43 44 45 46
                                if (redirect){
                                    window.location = redirect;
                                }else{
                                    window.location = "/";
                                }
NoSubject's avatar
NoSubject 已提交
47 48 49 50 51 52 53 54 55
                            }.bind(this),
                            onFailure: function(xhr){
                                window.location = "/";
                            }.bind(this),
                            onError: function(text, error){
                                window.location = "/";
                            }.bind(this)
                        });
                        res.setHeader("Content-Type", "application/json; charset=utf-8");
56
                        var json = {"token": encodeURIComponent(xtoken), "client": client};
NoSubject's avatar
NoSubject 已提交
57 58 59

                        res.send(JSON.encode(json));
                    }else{
NoSubject's avatar
NoSubject 已提交
60 61 62 63 64
                        if (redirect){
                            window.location = redirect;
                        }else{
                            window.location = "/";
                        }
NoSubject's avatar
NoSubject 已提交
65 66 67 68 69 70 71 72 73 74
                    }
                });
            });

        });
    </script>
</head>
<body bgcolor="#faebd7" bgcolor="#ffc0cb">

</body>
R
roo00 已提交
75
</html>