internal SsoOrganization(SsoUser user) { _user = user; }
internal bool ProcessSignIn() { if (PlatformHelper.GetParam("wa") == "wsignin1.0") { string messageStr = PlatformHelper.GetParam("wresult"); SignInMessage message = new SignInMessage(messageStr); DateTime notOnOrAfter = message.Verify(_callbackApi.Realm, _callbackApi.MaxClockSkewSeconds, _callbackApi.Cache); SsoUser user = new SsoUser(message); PlatformHelper.AddSessionCookie("_rmunify_user", "true"); if (!string.IsNullOrEmpty(user.Organization.Id)) { if (!string.IsNullOrEmpty(user.Organization.AppEstablishmentKey)) { if (user.Organization.IsSsoConnector) { if (!_callbackApi.IsOrganizationLicensed(user.Organization.AppEstablishmentKey, user.Organization, RmUnifyCallbackApi.Source.SingleSignOn)) { throw new RmUnifySsoException(RmUnifySsoException.ERRORCODES_NOLICENCE, "No licence found for school with establishment key: " + user.Organization.AppEstablishmentKey); } } _callbackApi.UpdateLinkedOrganization(user.Organization.AppEstablishmentKey, user.Organization, RmUnifyCallbackApi.Source.SingleSignOn); } else { if (user.Organization.IsSsoConnector) { throw new RmUnifySsoException(RmUnifySsoException.ERRORCODES_INVALIDAPPESTABLISHMENTKEY, "Invalid AppEstablishmentKey in SSO Connector"); } _callbackApi.CreateOrUpdateOrganization(user.Organization, RmUnifyCallbackApi.Source.SingleSignOn); } } if (!string.IsNullOrEmpty(user.AppUserId)) { if (string.IsNullOrEmpty(user.Organization.AppEstablishmentKey)) { throw new RmUnifySsoException(RmUnifySsoException.ERRORCODES_INVALIDAPPESTABLISHMENTKEY, "Invalid AppEstablishmentKey for linked user"); } _callbackApi.UpdateLinkedUser(user.AppUserId, user.Organization.AppEstablishmentKey, user, RmUnifyCallbackApi.Source.SingleSignOn); } else { if (string.IsNullOrEmpty(user.Id)) { throw new RmUnifySsoException(RmUnifySsoException.ERRORCODES_MISSINGATTRIBUTES, "No user ID (IdentityGuid or PersistentId) provided by RM Unify"); } _callbackApi.CreateOrUpdateUser(user, RmUnifyCallbackApi.Source.SingleSignOn); } PlatformHelper.AddSessionCookie("_rmunify_user", "true"); string returnUrl = PlatformHelper.GetParam("wctx"); try { if (!string.IsNullOrEmpty(user.AppUserId)) { _callbackApi.DoLoginForLinkedUser(user.AppUserId, user.Organization.AppEstablishmentKey, user, notOnOrAfter, returnUrl); } else { _callbackApi.DoLogin(user, notOnOrAfter, returnUrl); } } catch { try { PlatformHelper.DeleteCookie("_rmunify_user"); } catch { } throw; } return true; } return false; }