SAML 2.0 Authenticator.
Inheritance: WebRedirectAuthenticator
コード例 #1
0
ファイル: MainActivity.cs プロジェクト: Xipas/Symplified.Auth
		public void LoginWithIdentityProvider (object sender, EventArgs e)
		{
			XmlDocument xDoc = new XmlDocument ();
			xDoc.PreserveWhitespace = true;
			xDoc.Load (Assets.Open ("idp.symplified.net.metadata.xml"));

			Saml20MetadataDocument idpMetadata = new Saml20MetadataDocument (xDoc);

			Saml20Authenticator authenticator = new Saml20Authenticator (
				"Symplified.Auth.Android.Sample",
				idpMetadata
			);

			authenticator.Completed += (s, ee) => {
				if (!ee.IsAuthenticated) {
					this.authenticationStatus.Text = "Not authorized";
				}
				else {
					SamlAccount authenticatedAccount = (SamlAccount)ee.Account;
					this.authenticationStatus.Text = String.Format ("Subject: {0}", authenticatedAccount.Assertion.Subject.Value);
				}
			};

			var intent = authenticator.GetUI (this);
			StartActivityForResult (intent, 42);
		}
コード例 #2
0
ファイル: AppDelegate.cs プロジェクト: Xipas/Symplified.Auth
		public void PerformSalesforceOAuthSaml2Grant ()
		{
			XmlDocument xDoc = new XmlDocument ();
			xDoc.PreserveWhitespace = true;
			xDoc.Load ("salesforce-oauthsaml2-idp-metadata.xml");

			Saml20MetadataDocument idpMetadata = new Saml20MetadataDocument (xDoc);

			Saml20Authenticator authenticator = new Saml20Authenticator (
				"Symplified.Auth.iOS.Sample",
				idpMetadata
				);

			authenticator.Completed += (s, e) => {
				loginViewController.DismissViewController (true, null);

				if (!e.IsAuthenticated) {
					samlLoginStatusStringElement.Caption = "Not authorized";
					samlLoginStatusStringElement.GetActiveCell ().BackgroundColor = UIColor.Red;
				}
				else {
					SamlAccount authenticatedAccount = (SamlAccount)e.Account;
					samlLoginStatusStringElement.Caption = authenticatedAccount.Assertion.Subject.Value;
					samlLoginStatusStringElement.GetActiveCell ().BackgroundColor = UIColor.Green;

					authenticatedAccount.GetBearerAssertionAuthorizationGrant (
						new Uri ("https://login.salesforce.com/services/oauth2/token")
						).ContinueWith (t => {
						if (!t.IsFaulted) {
							accessTokenStringElement.Caption = t.Result ["access_token"];
							scopeStringElement.Caption = t.Result ["scope"];

							BeginInvokeOnMainThread (delegate {
								loginViewController.ReloadData ();
								ListSalesforceResources (t.Result ["instance_url"], t.Result ["access_token"]);
							});
						}
						else {
							Console.WriteLine ("error");
						}
					});
				}

				loginViewController.ReloadData ();
			};

			UIViewController vc = authenticator.GetUI ();
			loginViewController.PresentViewController (vc, true, null);
		}
コード例 #3
0
ファイル: AppDelegate.cs プロジェクト: Xipas/Symplified.Auth
		public void LoginWithIdentityProvider ()
		{
			XmlDocument xDoc = new XmlDocument ();
			xDoc.PreserveWhitespace = true;
			xDoc.Load ("idp.symplified.net.metadata.xml");

			Saml20MetadataDocument idpMetadata = new Saml20MetadataDocument (xDoc);

			Saml20Authenticator authenticator = new Saml20Authenticator (
				"Symplified.Auth.iOS.Sample",
				idpMetadata
				);

			authenticator.Completed += (s, e) => {
				loginViewController.DismissViewController (true, null);

				if (!e.IsAuthenticated) {
					samlLoginStatusStringElement.Caption = "Not authorized";
					samlLoginStatusStringElement.GetActiveCell ().BackgroundColor = UIColor.Red;
				}
				else {
					SamlAccount authenticatedAccount = (SamlAccount)e.Account;

					samlLoginStatusStringElement.Caption = String.Format ("Name: {0}", authenticatedAccount.Assertion.Subject.Value);
					samlLoginStatusStringElement.GetActiveCell ().BackgroundColor = UIColor.Green;
				}

				loginViewController.ReloadData ();
			};

			vc = authenticator.GetUI ();
			loginViewController.PresentViewController (vc, true, null);
		}