1 2 18 package com.sun.org.apache.xml.internal.security.keys; 19 20 21 22 import java.io.PrintStream ; 23 import java.security.PublicKey ; 24 25 import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; 26 import com.sun.org.apache.xml.internal.security.keys.content.KeyName; 27 import com.sun.org.apache.xml.internal.security.keys.content.KeyValue; 28 import com.sun.org.apache.xml.internal.security.keys.content.MgmtData; 29 import com.sun.org.apache.xml.internal.security.keys.content.X509Data; 30 31 32 37 public class KeyUtils { 38 39 private KeyUtils() { 40 } 42 43 50 public static void prinoutKeyInfo(KeyInfo ki, PrintStream os) 51 throws XMLSecurityException { 52 53 for (int i = 0; i < ki.lengthKeyName(); i++) { 54 KeyName x = ki.itemKeyName(i); 55 56 os.println("KeyName(" + i + ")=\"" + x.getKeyName() + "\""); 57 } 58 59 for (int i = 0; i < ki.lengthKeyValue(); i++) { 60 KeyValue x = ki.itemKeyValue(i); 61 PublicKey pk = x.getPublicKey(); 62 63 os.println("KeyValue Nr. " + i); 64 os.println(pk); 65 } 66 67 for (int i = 0; i < ki.lengthMgmtData(); i++) { 68 MgmtData x = ki.itemMgmtData(i); 69 70 os.println("MgmtData(" + i + ")=\"" + x.getMgmtData() + "\""); 71 } 72 73 for (int i = 0; i < ki.lengthX509Data(); i++) { 74 X509Data x = ki.itemX509Data(i); 75 76 os.println("X509Data(" + i + ")=\"" + (x.containsCertificate() 77 ? "Certificate " 78 : "") + (x 79 .containsIssuerSerial() 80 ? "IssuerSerial " 81 : "") + "\""); 82 } 83 } 84 } 85 | Popular Tags |