Exemple #1
0
        public static void CreateRelyingPartysWithRules(ServiceManagementWrapper acsWrapper)
        {
            var relyingPartyName = "Adatum.SimulatedIssuer.6";

            var ips = new[] { SocialIdentityProviders.WindowsLiveId.DisplayName, SocialIdentityProviders.Google.DisplayName, "Facebook" };

            Console.Write(string.Format("Creating {0} relying party....", relyingPartyName));
            var realmAddress = "https://localhost/Adatum.FederationProvider.6/";
            var replyAddress = "https://localhost/Adatum.FederationProvider.6/Federation.aspx";
            var ruleGroup    = string.Format("Default role group for {0}", relyingPartyName);


            acsWrapper.AddRelyingParty(relyingPartyName, realmAddress, replyAddress, null, null, null, ruleGroup, ips);

            Console.WriteLine("done");


            var relyingParty     = acsWrapper.RetrieveRelyingParties().Single(rp => rp.Name == relyingPartyName);
            var defaultRuleGroup = relyingParty.RelyingPartyRuleGroups.FirstOrDefault();

            acsWrapper.RemoveAllRulesInGroup(defaultRuleGroup.RuleGroup.Name);

            // Social IPs
            CreateGoogleRules(acsWrapper, defaultRuleGroup);
            CreateFacebookRules(acsWrapper, defaultRuleGroup);
            CreateWindowsLiveRules(acsWrapper, defaultRuleGroup);
        }
        private void CreateRelyingParty(string relyingPartyName, string identityProviderName, string ruleGroup, ServiceManagementWrapper acsWrapper)
        {
            // add the relaying party
            var realmAddress      = string.Format("https://localhost/f-shipping.7/{0}", relyingPartyName);
            var replyAddress      = string.Format("https://localhost/f-shipping.7/{0}/FederationResult", relyingPartyName);
            var identityProviders = new string[] { identityProviderName };

            acsWrapper.AddRelyingParty(relyingPartyName, realmAddress, replyAddress, null, null, null, ruleGroup, identityProviders);
        }
        public static void CreateRelyingParty(string relyingPartyName, string[] identityProviders, ServiceManagementWrapper acsWrapper)
        {
            Console.Write(string.Format("Creating {0} relying party....", relyingPartyName));
            var realmAddress = string.Format("https://localhost/f-shipping.7/{0}", relyingPartyName);
            var replyAddress = string.Format("https://localhost/f-shipping.7/{0}/FederationResult", relyingPartyName);
            var ruleGroup    = string.Format("Default role group for {0}", relyingPartyName);

            acsWrapper.AddRelyingParty(relyingPartyName, realmAddress, replyAddress, null, null, null, ruleGroup, identityProviders);
            Console.WriteLine("done");
        }
        public static void CreateEnrollmentRelyingParty(string[] identityProviders, ServiceManagementWrapper acsWrapper)
        {
            Console.Write("Creating f-shipping.Enrollment relying party....");

            var realmAddress = "https://localhost/f-shipping.Enrollment.7";
            var replyAddress = "https://localhost/f-shipping.Enrollment.7/FederationResult";
            var ruleGroup    = "Default rule group for f-Shipping.Enrollment.7";

            acsWrapper.AddRelyingParty("f-Shipping.Enrollment.7", realmAddress, replyAddress, null, null, null, ruleGroup, identityProviders);

            Console.WriteLine("done");
        }
        public ActionResult CreateTenantWithSocialProvider(string OrganizationName, HttpPostedFileBase logoFile)
        {
            string organizationInternalName = SanitizeString(OrganizationName);

            if (this.IsOrganizationNameValid(organizationInternalName))
            {
                var ipName = ClaimHelper.GetCurrentUserClaim(Fabrikam.ClaimTypes.IdentityProvider).Value;
                if (ipName == SocialIdentityProviders.WindowsLiveId.HomeRealm)
                {
                    ipName = SocialIdentityProviders.WindowsLiveId.DisplayName;
                }
                Organization organization = new Organization {
                    Name = organizationInternalName, DisplayName = OrganizationName, HomeRealm = ipName, LogoPath = "~/Content/images/generic-logo.png"
                };

                if (logoFile != null && logoFile.ContentLength > 0)
                {
                    var imageFolderRelativePath = "~/Content/images/";
                    var imageFolderAbsolutePath = Server.MapPath("~/");
                    imageFolderAbsolutePath = string.Concat(imageFolderAbsolutePath, "..\\f-shipping.7\\Content\\images\\");
                    var fileName     = string.Concat(organizationInternalName, "-logo.png");
                    var fileFullPath = string.Concat(imageFolderAbsolutePath, fileName);
                    logoFile.SaveAs(fileFullPath);
                    organization.LogoPath = string.Concat(imageFolderRelativePath, fileName);
                }

                OrganizationRepository organizationRepository = new OrganizationRepository();
                organizationRepository.AddOrganization(organization);
                ServiceManagementWrapper acsWrapper = new ServiceManagementWrapper(acsServiceNamespace, acsUsername, acsPassword);

                var relayingPartyName = organizationInternalName;
                var realmAddress      = string.Format("https://localhost/f-shipping.7/{0}", organizationInternalName);
                var replyAddress      = string.Format("https://localhost/f-shipping.7/{0}/FederationResult", organizationInternalName);
                var ruleGroup         = string.Format("Default role group for {0}", organizationInternalName);
                var socialProviders   = new string[] { ipName };

                acsWrapper.AddRelyingParty(organizationInternalName, realmAddress, replyAddress, null, null, null, ruleGroup, socialProviders);

                var nameIdentifierValue = ClaimHelper.GetCurrentUserClaim(ClaimTypes.NameIdentifier).Value;

                CreateRulesForTenantWithSocialIP(organizationInternalName, ipName, acsWrapper, ruleGroup, nameIdentifierValue);

                return(View("CompleteEnrollment"));
            }
            return(View("EnrollWithSocialProvider", new EnrollmentViewModel {
                ErrorMessage = "Organization name not valid", OrganizationName = OrganizationName
            }));
        }