Click here to Skip to main content
15,918,808 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Jun Du7-Mar-07 16:38
Jun Du7-Mar-07 16:38 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Jun Du8-Mar-07 5:05
Jun Du8-Mar-07 5:05 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Mark Salsbery8-Mar-07 6:06
Mark Salsbery8-Mar-07 6:06 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Jun Du9-Mar-07 3:28
Jun Du9-Mar-07 3:28 
GeneralRe: Need advice on display rotation performance from experienced programmers... Pin
Mark Salsbery9-Mar-07 11:16
Mark Salsbery9-Mar-07 11:16 
QuestionHow to map message in each item of list control? Pin
Max++7-Mar-07 6:24
Max++7-Mar-07 6:24 
AnswerRe: How to map message in each item of list control? Pin
Hamid_RT7-Mar-07 7:01
Hamid_RT7-Mar-07 7:01 
QuestionC++ XML Transform Pin
Andy H7-Mar-07 6:19
Andy H7-Mar-07 6:19 
Does anyone PLEASE know how to perform the following (example is in Java, using Apache library) in C++:


import java.io.*;<br />
import javax.xml.parsers.*;<br />
import java.security.*;<br />
<br />
import org.w3c.dom.*;<br />
<br />
import org.apache.xml.security.signature.*;<br />
import org.apache.xml.security.transforms.*;<br />
import org.apache.xml.security.Init;<br />
<br />
import org.bouncycastle.util.encoders.Base64;<br />
<br />
/**<br />
 * This code generates an IRmark value for an input document.<br />
 * The value is a base64 encoded SHA1 digest of a signature<br />
 * transform over a certain style of document. The value has<br />
 * to be placed inside documents to be signed by the XPE when<br />
 * used in a EDS/IR deployment.<br />
 *<br />
 * The code has a number of jar dependencies:-<br />
 * 	xmlsec.jar - The Apache XML Security Library<br />
 * 	log4j-1.2.5.jar - The Apache Log utility<br />
 *  xalan.jar - Apache XSLT/XPath processor<br />
 *  xercesImpl.jar - Apache XML processor<br />
 *  bc-jce-jdk13-114.jar - Bouncy Castle JCE library<br />
 *<br />
 *  The Bouncy Castle JCE provider is automatically downloaded<br />
 *  by the Apache XML sec library build so you may already have<br />
 *  that.<br />
 */<br />
public class IRMark {<br />
<br />
   /**<br />
    * Generate and print the IRmark.<br />
    *<br />
    * @param args - Pass the filename of the input document<br />
    * @throws Exception<br />
    */<br />
	public static void main(String args[]) throws Exception {<br />
<br />
   		// Init the Apache XML security library<br />
		Init.init();<br />
<br />
		// Check we are given a file to work with<br />
		if (args.length!=1) {<br />
			System.out.println("Use: IRmark <file> ");<br />
			return;<br />
		}<br />
<br />
		// Open the input file<br />
		FileInputStream fis=null;<br />
		try {<br />
			fis=new FileInputStream(args[0]);<br />
		} catch (FileNotFoundException e) {<br />
			System.out.println("The file " + args[0] + " could not be opened.");<br />
			return;<br />
		}<br />
<br />
		// Load file into a byte array<br />
		byte[] data=null;<br />
		try {<br />
			int bytes=fis.available();<br />
			data=new byte[bytes];<br />
			fis.read(data);<br />
		} catch (IOException e) {<br />
			System.out.println("Error reading file.");<br />
			e.printStackTrace();<br />
		}<br />
<br />
		// First part is to run the a transform over the input to extract the<br />
		// fragment to be digested. This is done by setting up a Transforms<br />
		// object from a Template and then executing against the input document<br />
<br />
		// The transforms to be performed are specified by using the template XML below.<br />
      	String transformStr =<br />
        "<?xml version='1.0'?>\n"<br />
      	+ "<dsig:Transforms xmlns:dsig='http://www.w3.org/2000/09/xmldsig#'" <br />
		+	"xmlns:gt='http://www.govtalk.gov.uk/CM/envelope'" <br />
		+		  "xmlns:ir='http://www.govtalk.gov.uk/taxation/SA'>\n"<br />
      	+ "<dsig:Transform Algorithm='http://www.w3.org/TR/1999/REC-xpath-19991116'>\n"<br />
      	+ "<dsig:XPath>\n"<br />
      	+ "count(ancestor-or-self::node()|/gt:GovTalkMessage/gt:Body)=count(ancestor-or-self::node())\n"<br />
		+ " and count(self::ir:IRmark)=0 \n"<br />
		+ " and count(../self::ir:IRmark)=0 \n"<br />
		+ "</dsig:XPath>\n"<br />
      	+ "</dsig:Transform>\n"<br />
      	+ "<dsig:Transform Algorithm='http://www.w3.org/TR/2001/REC-xml-c14n-20010315#'/>\n"<br />
      	+ "</dsig:Transforms>\n"<br />
      	;<br />
<br />
		// Parse the transform details to create a document<br />
		DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();<br />
		dbf.setNamespaceAware(true);<br />
		DocumentBuilder db=dbf.newDocumentBuilder();<br />
		Document doc=db.parse(new ByteArrayInputStream(transformStr.getBytes()));<br />
<br />
		// Construct a Apache security Transforms object from that document<br />
		Transforms transforms = new Transforms(doc.getDocumentElement(), null);<br />
<br />
		// Now perform the transform on the input to get the results.<br />
      	XMLSignatureInput input = new XMLSignatureInput(data);<br />
      	XMLSignatureInput result = transforms.performTransforms(input);<br />
<br />
      	// Uncomment this line to see transform output<br />
      	// System.out.println(new String(result.getBytes()));<br />
<br />
      	// Second part is to run output via SHA1 digest<br />
      	// This is done via the standard java.security API<br />
		MessageDigest md = MessageDigest.getInstance("SHA");<br />
		md.update(result.getBytes());<br />
		byte[] digest=md.digest();<br />
<br />
		// And finally print a Base64 of the digest with<br />
		// The help of the BouncyCastle JCE library<br />
		System.out.println("IRmark: " + new String(Base64.encode(digest)));<br />
   }<br />
}

AnswerRe: C++ XML Transform Pin
Cedric Moonen7-Mar-07 7:20
Cedric Moonen7-Mar-07 7:20 
JokeRe: C++ XML Transform Pin
Maximilien7-Mar-07 7:24
Maximilien7-Mar-07 7:24 
JokeRe: C++ XML Transform Pin
Cedric Moonen7-Mar-07 7:27
Cedric Moonen7-Mar-07 7:27 
GeneralRe: C++ XML Transform Pin
Maximilien7-Mar-07 7:55
Maximilien7-Mar-07 7:55 
GeneralRe: C++ XML Transform Pin
Andy H7-Mar-07 7:54
Andy H7-Mar-07 7:54 
GeneralRe: C++ XML Transform Pin
Cedric Moonen7-Mar-07 10:33
Cedric Moonen7-Mar-07 10:33 
GeneralRe: C++ XML Transform Pin
Andy H7-Mar-07 11:05
Andy H7-Mar-07 11:05 
QuestionHow to get the local time in seconds? Pin
Yonggoo7-Mar-07 5:35
Yonggoo7-Mar-07 5:35 
AnswerRe: How to get the local time in seconds? Pin
led mike7-Mar-07 5:41
led mike7-Mar-07 5:41 
GeneralRe: How to get the local time in seconds? Pin
Yonggoo7-Mar-07 7:21
Yonggoo7-Mar-07 7:21 
GeneralRe: How to get the local time in seconds? Pin
led mike7-Mar-07 7:36
led mike7-Mar-07 7:36 
GeneralRe: How to get the local time in seconds? Pin
Yonggoo7-Mar-07 8:51
Yonggoo7-Mar-07 8:51 
GeneralRe: How to get the local time in seconds? Pin
Yonggoo7-Mar-07 8:50
Yonggoo7-Mar-07 8:50 
AnswerRe: How to get the local time in seconds? Pin
Mark Salsbery7-Mar-07 7:47
Mark Salsbery7-Mar-07 7:47 
AnswerRe: How to get the local time in seconds? Pin
David Crow7-Mar-07 7:50
David Crow7-Mar-07 7:50 
QuestionChanging the size of a window Pin
rschocks7-Mar-07 4:55
rschocks7-Mar-07 4:55 
QuestionRe: Changing the size of a window Pin
David Crow7-Mar-07 4:59
David Crow7-Mar-07 4:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.