public static HttpError CreateError(TokenRequestError Error, object DTO = null) { System.Net.HttpStatusCode Code = System.Net.HttpStatusCode.InternalServerError; switch (Error.error) { case ErrorCodes.invalid_request: case ErrorCodes.invalid_scope: case ErrorCodes.unsupported_response_type: Code = System.Net.HttpStatusCode.BadRequest; break; case ErrorCodes.unauthorized_client: case ErrorCodes.access_denied: Code = System.Net.HttpStatusCode.Forbidden; break; default: Code = System.Net.HttpStatusCode.InternalServerError; break; } return(new HttpError(Code, Error) { Response = DTO }); }
public AuthInfo(TokenRequestError error, bool isldap) { LDAPLogin = isldap; TenantCode = string.Empty; UserName = string.Empty; Roles = new List <string>(); Sites = new List <string>(); DefaultSite = string.Empty; RequestError = error; Token = null; }
public static IAuthInfo RequestLogin(string username, string pwd, string language, string tenantName) { try { TokenClient clt = SecurityHelper.GetTokenClient(); var tk = clt.RequestToken(username, pwd, tenantName, language); IAuthInfo result = new AuthInfo(tk, clt, false); return(result); } catch (TokenRequestException e) { AuthInfo result = null; TokenRequestError error = new TokenRequestError(e.ErrorCode, e.ErrorDescription); result = new AuthInfo(error, false); return(result); } }