private static bool IsRequired(SFSessionProperty sessionProperty, SFSessionProperties properties) { if (sessionProperty.Equals(SFSessionProperty.PASSWORD)) { var authenticatorDefined = properties.TryGetValue(SFSessionProperty.AUTHENTICATOR, out var authenticator); // External browser, jwt and oauth don't require a password for authenticating return(!(authenticatorDefined && (authenticator.Equals(ExternalBrowserAuthenticator.AUTH_NAME, StringComparison.OrdinalIgnoreCase) || authenticator.Equals(KeyPairAuthenticator.AUTH_NAME, StringComparison.OrdinalIgnoreCase) || authenticator.Equals(OAuthAuthenticator.AUTH_NAME, StringComparison.OrdinalIgnoreCase)))); } else if (sessionProperty.Equals(SFSessionProperty.USER)) { var authenticatorDefined = properties.TryGetValue(SFSessionProperty.AUTHENTICATOR, out var authenticator); // Oauth don't require a username for authenticating return(!(authenticatorDefined && ( authenticator.Equals(OAuthAuthenticator.AUTH_NAME, StringComparison.OrdinalIgnoreCase)))); } else { return(sessionProperty.GetAttribute <SFSessionPropertyAttr>().required); } }
internal Uri BuildLoginUrl() { var queryParams = new Dictionary <string, string>(); string warehouseValue; string dbValue; string schemaValue; string roleName; queryParams[RestParams.SF_QUERY_WAREHOUSE] = properties.TryGetValue(SFSessionProperty.WAREHOUSE, out warehouseValue) ? warehouseValue : ""; queryParams[RestParams.SF_QUERY_DB] = properties.TryGetValue(SFSessionProperty.DB, out dbValue) ? dbValue : ""; queryParams[RestParams.SF_QUERY_SCHEMA] = properties.TryGetValue(SFSessionProperty.SCHEMA, out schemaValue) ? schemaValue : ""; queryParams[RestParams.SF_QUERY_ROLE] = properties.TryGetValue(SFSessionProperty.ROLE, out roleName) ? roleName : ""; queryParams[RestParams.SF_QUERY_REQUEST_ID] = Guid.NewGuid().ToString(); var loginUrl = BuildUri(RestPath.SF_LOGIN_PATH, queryParams); return(loginUrl); }