Skip to content

Instantly share code, notes, and snippets.

View SumindaD's full-sized avatar

Suminda Niroshan SumindaD

  • 1BillionTech
  • Colombo, Sri Lanka
View GitHub Profile
trigger:
- none
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
fetchDepth: 0
fetchTags: true
persistCredentials: true
- task: CmdLine@2
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java
trigger:
- main
pool:
vmImage: ubuntu-latest
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
return new OkObjectResult("Hello World!");
cognitoIDTokenBlackListTableName: CognitoIDTokenBlackList-#{AWS::AccountId}-${self:custom.currentStage}
cognitoIDTokenBlackListTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.cognitoIDTokenBlackListTableName}
AttributeDefinitions:
- AttributeName: CognitoTokenID
AttributeType: S
KeySchema:
AWSTemplateFormatVersion: 2010-09-09
Description: The CloudFormation template for the Private & Public Subnets with RDS Database.
Parameters:
Stage:
Type: String
Default: dev
Resources:
# ======================= Private VPC Configuration ====================
# Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
# except in compliance with the License. A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed on an "AS IS"
# BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under the License.
using System;
using System.IO;
namespace SignImages
{
class Program
{
static void Main(string[] args)
{
const string PrivateKeryCertName = "PrivateKeyCert.pfx";
/// <summary>
/// Retrieve the image data from the signed xml document
/// </summary>
/// <param name="xmlFilePath">Path to the signed xml image document</param>
/// <returns>Byte[] of the image</returns>
public static byte[] GetImage(string xmlFilePath)
{
var unsignedXMLDocument = UnsignXMLDocument(xmlFilePath);
return DeserializeXMLToImage(unsignedXMLDocument);
/// <summary>
/// Deserialize the unsigned xml document and retrieve the image
/// </summary>
/// <param name="xmlDocument">Unsigned XmlDocument</param>
/// <returns>Byte[] of the image</returns>
private static byte[] DeserializeXMLToImage(XmlDocument xmlDocument)
{
StringWriter stringWriter = new StringWriter();
XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);
/// <summary>
/// Remove the Signature from signed XML document
/// </summary>
/// <param name="xmlFilePath">Path to the signed xml document</param>
/// <returns>The unsigned xml document</returns>
private static XmlDocument UnsignXMLDocument(string xmlFilePath)
{
var xmlDocument = ReadXMLDocumentFromPath(xmlFilePath);
var nodeList = xmlDocument.GetElementsByTagName("Signature");