

CREATE COMPUTE MODULE DECRYPT_DOTNET_SUBFLOW_SET_DECRYPT_PARAMETER
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		CALL CopyMessageHeaders();
		-- CALL CopyEntireMessage();

		SET OutputLocalEnvironment = InputLocalEnvironment;

		SET OutputLocalEnvironment.decrypt.phrase = 'L0v3BTN43v3rp07@Pr1m@';
		SET OutputLocalEnvironment.decrypt.salt = '==P@22m0r4isM1n3==';
		SET OutputLocalEnvironment.decrypt.vector = '@1B2c3D4e5F6g7H8';
		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyMessageHeaders() BEGIN
		DECLARE I INTEGER 1;
		DECLARE J INTEGER;
		SET J = CARDINALITY(InputRoot.*[]);
		WHILE I < J DO
			SET OutputRoot.*[I] = InputRoot.*[I];
			SET I = I + 1;
		END WHILE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE COMPUTE MODULE DECRYPT_DOTNET_SUBFLOW_SET_FAULT_USER_PASSWORD_EMPTY
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		-- CALL CopyMessageHeaders();
		CALL CopyEntireMessage();

		DECLARE i INTEGER 1;
		label1 : BEGIN
			FOR error AS InputRoot.XMLNSC.*[] DO
				IF FIELDNAME(error) <> 'XmlDeclaration' THEN
					SET OutputRoot.XMLNSC.*[i].error = 'User and Password are not set';
					SET OutputRoot.XMLNSC.*[i].errorCode = '1001';
					SET OutputRoot.XMLNSC.*[i].errorDetail = 'User and Password are not set';
					LEAVE label1;
				END IF;

				SET i = i + 1;
			END FOR;
		END;

		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyMessageHeaders() BEGIN
		DECLARE I INTEGER 1;
		DECLARE J INTEGER;
		SET J = CARDINALITY(InputRoot.*[]);
		WHILE I < J DO
			SET OutputRoot.*[I] = InputRoot.*[I];
			SET I = I + 1;
		END WHILE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE FILTER MODULE DECRYPT_DOTNET_SUBFLOW_FILTER_USER_PASSWORD_EMPTY
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		DECLARE soapenv NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';

		IF (Root.XMLNSC.soapenv:Envelope.soapenv:Body.*[1].userId = '') OR (Root.XMLNSC.soapenv:Envelope.soapenv:Body.*[1].password = '') THEN
			RETURN TRUE;
		ELSE
			RETURN FALSE;
		END IF;
	END;
END MODULE;
