private RallyRestApi.AuthenticationResult PerformAuthenticationCheckAgainstIdp(out string errorMessage)
{
if (!IsUiSupported)
throw new InvalidProgramException("This method is only supported by UI enabled Authentication Managers.");
errorMessage = String.Empty;
WebProxy proxy = GetProxy(out errorMessage);
if (!String.IsNullOrWhiteSpace(errorMessage))
return RallyRestApi.AuthenticationResult.NotAuthorized;
if (String.IsNullOrWhiteSpace(LoginDetails.IdpServer))
errorMessage = LoginFailureServerEmpty;
Uri serverUri = null;
try
{
serverUri = new Uri(LoginDetails.IdpServer);
}
catch
{
errorMessage = "Bad URI format for CA Agile Central Server";
}
try
{
if (String.IsNullOrWhiteSpace(errorMessage))
{
Api.CreateIdpAuthentication(serverUri, proxy);
OpenSsoPage(Api.ConnectionInfo.IdpServer);
}
}
catch (RallyUnavailableException)
{
errorMessage = "CA Agile Central is currently unavailable.";
}
catch (WebException e)
{
if (e.Response is HttpWebResponse)
{
if ((((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.BadGateway) ||
(((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.BadRequest))
{
errorMessage = LoginFailureBadServer;
}
else if (((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.ProxyAuthenticationRequired)
{
errorMessage = LoginFailureProxyCredentials;
}
else if (((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.Unauthorized)
{
errorMessage = LoginFailureCredentials;
}
else
errorMessage = LoginFailureUnknown;
}
else if ((e is WebException) &&
(((WebException)e).Status == WebExceptionStatus.ConnectFailure))
{
errorMessage = LoginFailureBadConnection;
}
else
errorMessage = LoginFailureUnknown;
}
UpdateAuthenticationState();
return Api.AuthenticationState;
}
#endregion