public string CredentialsList(InputCredentialsList inputCredentialsList)
        {
            JsonSerializer serializer  = new JsonSerializer();
            ErrorLogger    errorLogger = new ErrorLogger();
            string         baseURL     = _configuration.GetSection("Transsped").GetSection("BaseURL").Value;

            CredentialsListClient credentialsListClient = new CredentialsListClient(serializer, errorLogger, baseURL);

            Microsoft.Extensions.Primitives.StringValues value;
            string access_token = "";

            if (Request.Headers.TryGetValue("Authorization", out value))
            {
                access_token = value.ToString().Replace("Bearer ", "");
            }
            else
            {
                OutputError error = new OutputError()
                {
                    error             = "invalid_access_token",
                    error_description = "Invalid access_token"
                };
                return(serializer.Serialize(error));
            }
            object response = credentialsListClient.GetCredentialsList(access_token, inputCredentialsList);

            return(serializer.Serialize(response));
        }
Пример #2
0
        public object Credentials(InputCredentialsList inputCredentialsList)
        {
            JsonSerializer serializer  = new JsonSerializer();
            ErrorLogger    errorLogger = new ErrorLogger();
            string         baseURL     = _configuration.GetSection("Transsped").GetSection("BaseURL").Value;

            CredentialsListClient credentialsListClient = new CredentialsListClient(serializer, errorLogger, baseURL);

            Microsoft.Extensions.Primitives.StringValues value;
            string access_token = "";

            if (Request.Headers.TryGetValue("Authorization", out value))
            {
                access_token = value.ToString().Replace("Bearer ", "");
            }
            else
            {
                OutputError error = new OutputError()
                {
                    error             = "invalid_access_token",
                    error_description = "Invalid access_token"
                };
                return(serializer.Serialize(error));
            }
            object response = credentialsListClient.GetCredentialsList(access_token, inputCredentialsList);
            var    credList = serializer.Serialize(response);
            OutputCredentialsList    outputCredentialsList = serializer.Deserialize <OutputCredentialsList>(credList);
            List <OutputCredentials> userCredInfo          = new List <OutputCredentials>();

            if (outputCredentialsList != null && outputCredentialsList.credentialIDs != null)
            {
                foreach (var credID in outputCredentialsList.credentialIDs)
                {
                    InputCredentialsInfo inputCredentialsInfo = new InputCredentialsInfo()
                    {
                        credentialID = credID
                    };

                    CredentialsInfoClient credentialsInfoClient = new CredentialsInfoClient(serializer, errorLogger, baseURL);
                    var credInfoResponse = serializer.Serialize(credentialsInfoClient.GetCredentialsInfo(access_token, inputCredentialsInfo));
                    if (!credInfoResponse.Contains("error"))
                    {
                        OutputCredentialsInfo outputCredentialsInfo = serializer.Deserialize <OutputCredentialsInfo>(credInfoResponse);
                        OutputCredentials     tempOutputCred        = new OutputCredentials();
                        tempOutputCred.credentialID = credID;
                        tempOutputCred.authMode     = outputCredentialsInfo.authMode;
                        tempOutputCred.cert         = outputCredentialsInfo.cert;
                        tempOutputCred.description  = outputCredentialsInfo.description;
                        tempOutputCred.key          = outputCredentialsInfo.key;
                        tempOutputCred.lang         = outputCredentialsInfo.lang;
                        tempOutputCred.multisign    = outputCredentialsInfo.multisign;
                        tempOutputCred.OTP          = outputCredentialsInfo.OTP;
                        tempOutputCred.PIN          = outputCredentialsInfo.PIN;
                        tempOutputCred.SCAL         = outputCredentialsInfo.SCAL;

                        userCredInfo.Add(tempOutputCred);
                    }
                }
            }
            //pentru fiecare id din lista de credentiale sa returnez tot certificatul
            return(userCredInfo);
        }