コード例 #1
0
        public string GetCredentialsAuthorize(InputCredentialsAuthorize inputCredentialsAuthorize)
        {
            JsonSerializer serializer  = new JsonSerializer();
            ErrorLogger    errorLogger = new ErrorLogger();
            string         baseURL     = _configuration.GetSection("Transsped").GetSection("BaseURL").Value;

            CredentialsAuthorizeClient credentialsAuthorizeClient = new CredentialsAuthorizeClient(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 = credentialsAuthorizeClient.GetCredentialsAuthorize(access_token, inputCredentialsAuthorize);

            return(serializer.Serialize(response));
        }
コード例 #2
0
        public object Sign(InputAuthorizeSignHash inputAuthSign)
        {
            InputCredentialsAuthorize inputCredentialsAuthorize = new InputCredentialsAuthorize()
            {
                credentialID  = inputAuthSign.credentialsID,
                numSignatures = inputAuthSign.numSignatures,
                hash          = inputAuthSign.hash,
                PIN           = inputAuthSign.PIN,
                OTP           = inputAuthSign.OTP,
                clientData    = inputAuthSign.clientData,
                description   = inputAuthSign.description
            };

            JsonSerializer serializer  = new JsonSerializer();
            ErrorLogger    errorLogger = new ErrorLogger();
            string         baseURL     = _configuration.GetSection("Transsped").GetSection("BaseURL").Value;

            CredentialsAuthorizeClient credentialsAuthorizeClient = new CredentialsAuthorizeClient(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));
            }

            string response = serializer.Serialize(credentialsAuthorizeClient.GetCredentialsAuthorize(access_token, inputCredentialsAuthorize));

            if (response != null && !response.Contains("error"))
            {
                OutputCredentialsAuthorize outCredAuth = serializer.Deserialize <OutputCredentialsAuthorize>(response);

                InputSignaturesSignHash inputSignatures = new InputSignaturesSignHash()
                {
                    clientData     = inputAuthSign.clientData,
                    credentialID   = inputAuthSign.credentialsID,
                    hash           = inputAuthSign.hash,
                    hashAlgo       = inputAuthSign.hashAlgo,
                    SAD            = outCredAuth.SAD,
                    signAlgo       = inputAuthSign.signAlgo,
                    signAlgoParams = inputAuthSign.signAlgoParams
                };

                SignHashClient signHashClient = new SignHashClient(serializer, errorLogger, baseURL);
                //string signResponse = serializer.Serialize(signHashClient.GetSignedHash(access_token, inputSignatures));


                return(signHashClient.GetSignedHash(access_token, inputSignatures));
            }
            else
            {
                OutputError error = new OutputError()
                {
                    error             = "invalid_access_token",
                    error_description = "Invalid access_token"
                };
                return(error);
            }
        }