Пример #1
0
        public static void Test()
        {
            var idp = new IdP(idpPrincipal);
            var rp  = new RP(rpPrincipal);

            var aliceIdP = Channel.GenerateNew(idpPrincipal);
            var aliceRP  = Channel.GenerateNew(rpPrincipal);

            var idpReq = new SignInIdPReq {
                username   = "******",
                password   = "******",
                SVX_sender = aliceIdP
            };
            var rpReq = SVX_Ops.Call(idp.SignInIdP, idpReq);

            // Imagine the SignInRPReq was signed by the IdP.
            SVX_Ops.TransferForTesting(rpReq, idpPrincipal, aliceRP);

            var conc = SVX_Ops.Call(rp.SignInRP, rpReq);

            SVX_Ops.Certify(conc, rp.LoginSafety);
        }
Пример #2
0
            public SignInRPReq SignInIdP(SignInIdPReq req)
            {
                if (req.password != "password:" + req.username)
                {
                    throw new ArgumentException();
                }
                var userPrincipal = IdPUserPrincipal(req.username);

                // If this line is commented out, the check for whether it's OK
                // to send the secret to the client would fail, but this example
                // doesn't use export/import.
                VProgram_API.AssumeActsFor(req.SVX_sender, userPrincipal);
                var ssoSecretParams = new SSOSecretParams {
                    username = req.username
                };
                var resp = new SignInRPReq {
                    username  = req.username,
                    ssoSecret = ssoSecretGenerator.Generate(ssoSecretParams, SVX_Principal)
                };

                ssoSecretGenerator.Verify(ssoSecretParams, resp.ssoSecret);
                return(resp);
            }