Untitled
raw download clone
TEXT
views 32
,
size 2664 b
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dp="http://www.datapower.com/extensions"
xmlns:dpconfig="http://www.datapower.com/param/config"
extension-element-prefixes="dp"
exclude-result-prefixes="dp env" version="1.0">
<xsl:output method="text" encoding="utf-8" indent="yes" media-type="application/json"/>
<xsl:template match="/">

<dp:set-http-response-header name="'Content-Type'" value="'application/json'" />

<!-- Query to obatin keys-->
<xsl:variable name="query">
DECLARE	@return_value int
EXEC	@return_value = [dbo].[DescryptionService]
</xsl:variable>

<!-- Result set query to obatin keys-->
<xsl:variable name="result" select="dp:sql-execute('BPDCredencialesBDEncryptionService',$query)"/>

<!-- Generate KeyDek  AES256-->
<xsl:variable name="keyDek"> <xsl:value-of select="dp:generate-key('http://www.w3.org/2001/04/xmlenc#aes256-cbc')"/> </xsl:variable>

<!-- RSA private key Encrytion Service-->
<xsl:variable name="dataValue"><xsl:value-of select="$result/sql/row[1]/column[2]/value"/>
</xsl:variable>

<!-- Algorithm to encrypt-->
<xsl:variable name="algorithm" select="'http://www.w3.org/2001/04/xmlenc#aes256-cbc'"/>
  <xsl:variable name="session-key">
  <xsl:value-of select="dp:generate-key($algorithm)"/>
</xsl:variable>
 
<!-- Algorithm to encrypt-->
<xsl:variable name="output" select="dp:encrypt-data($algorithm,$session-key,$dataValue)"/>
 

<xsl:variable name="dataValue">
{
	"llaveKEK": <xsl:value-of select="$keyDek"/>
}
</xsl:variable>


<xsl:variable name="resultValue">
{
	"scoreMinimo": <xsl:value-of select="$result/sql/row[1]/column[2]/value"/>
}
</xsl:variable>

<xsl:variable name="HUELLA">
{
	"HUELLA": <xsl:value-of select="//*[local-name()='Huella']"/>
}
</xsl:variable>


<xsl:variable name="encryptedDataVariable">
{
	"output": <xsl:value-of select="$output"/>
}
</xsl:variable>

<dp:set-variable name="'var://context/Desarrollo/resultValue'" value="$resultValue"/>
<dp:set-variable name="'var://context/Desarrollo/dataValue'" value="$dataValue"/>
<dp:set-variable name="'var://context/Desarrollo/huella'" value="$HUELLA"/>
<dp:set-variable name="'var://context/Desarrollo/encryptedDataVariable'" value="$encryptedDataVariable"/>

<xsl:value-of select="dp:variable('var://context/Desarrollo/resultValue')"/>
<xsl:value-of select="dp:variable('var://context/Desarrollo/dataValue')"/>
<xsl:value-of select="dp:variable('var://context/Desarrollo/huella')"/>
<xsl:value-of select="dp:variable('var://context/Desarrollo/encryptedDataVariable')"/>



	</xsl:template>
</xsl:stylesheet>
close fullscreen
Login or Register to edit or fork this paste. It's free.