KeyUtils.java revision 11099:678faa7d1a6a
1126261Smlaier/* 2145836Smlaier * reserved comment block 3126258Smlaier * DO NOT REMOVE OR ALTER! 4126258Smlaier */ 5126258Smlaier/** 6126258Smlaier * Licensed to the Apache Software Foundation (ASF) under one 7126258Smlaier * or more contributor license agreements. See the NOTICE file 8126258Smlaier * distributed with this work for additional information 9126258Smlaier * regarding copyright ownership. The ASF licenses this file 10126258Smlaier * to you under the Apache License, Version 2.0 (the 11126258Smlaier * "License"); you may not use this file except in compliance 12126258Smlaier * with the License. You may obtain a copy of the License at 13126258Smlaier * 14126258Smlaier * http://www.apache.org/licenses/LICENSE-2.0 15126258Smlaier * 16126258Smlaier * Unless required by applicable law or agreed to in writing, 17126258Smlaier * software distributed under the License is distributed on an 18126258Smlaier * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19126258Smlaier * KIND, either express or implied. See the License for the 20126258Smlaier * specific language governing permissions and limitations 21126258Smlaier * under the License. 22126258Smlaier */ 23126258Smlaierpackage com.sun.org.apache.xml.internal.security.keys; 24126258Smlaier 25126258Smlaierimport java.io.PrintStream; 26126258Smlaierimport java.security.PublicKey; 27126258Smlaier 28126258Smlaierimport com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; 29126258Smlaierimport com.sun.org.apache.xml.internal.security.keys.content.KeyName; 30126258Smlaierimport com.sun.org.apache.xml.internal.security.keys.content.KeyValue; 31126258Smlaierimport com.sun.org.apache.xml.internal.security.keys.content.MgmtData; 32126258Smlaierimport com.sun.org.apache.xml.internal.security.keys.content.X509Data; 33126258Smlaier 34126258Smlaier/** 35126258Smlaier * Utility class for the <CODE>com.sun.org.apache.xml.internal.security.keys</CODE> package. 36126258Smlaier * 37145836Smlaier * @author $Author: coheigea $ 38126258Smlaier */ 39126258Smlaierpublic class KeyUtils { 40126258Smlaier 41126258Smlaier private KeyUtils() { 42126258Smlaier // no instantiation 43145836Smlaier } 44127145Smlaier 45130933Sbrooks /** 46126261Smlaier * Method prinoutKeyInfo 47126261Smlaier * 48126258Smlaier * @param ki 49126261Smlaier * @param os 50126261Smlaier * @throws XMLSecurityException 51127145Smlaier */ 52126261Smlaier public static void prinoutKeyInfo(KeyInfo ki, PrintStream os) 53126261Smlaier throws XMLSecurityException { 54126261Smlaier 55126258Smlaier for (int i = 0; i < ki.lengthKeyName(); i++) { 56126258Smlaier KeyName x = ki.itemKeyName(i); 57126258Smlaier 58135920Smlaier os.println("KeyName(" + i + ")=\"" + x.getKeyName() + "\""); 59135920Smlaier } 60135920Smlaier 61126258Smlaier for (int i = 0; i < ki.lengthKeyValue(); i++) { 62126258Smlaier KeyValue x = ki.itemKeyValue(i); 63126258Smlaier PublicKey pk = x.getPublicKey(); 64126258Smlaier 65126258Smlaier os.println("KeyValue Nr. " + i); 66130613Smlaier os.println(pk); 67145836Smlaier } 68126258Smlaier 69126258Smlaier for (int i = 0; i < ki.lengthMgmtData(); i++) { 70126258Smlaier MgmtData x = ki.itemMgmtData(i); 71126258Smlaier 72126258Smlaier os.println("MgmtData(" + i + ")=\"" + x.getMgmtData() + "\""); 73126258Smlaier } 74126258Smlaier 75126258Smlaier for (int i = 0; i < ki.lengthX509Data(); i++) { 76126258Smlaier X509Data x = ki.itemX509Data(i); 77126258Smlaier 78126258Smlaier os.println("X509Data(" + i + ")=\"" + (x.containsCertificate() 79126258Smlaier ? "Certificate " : "") + (x.containsIssuerSerial() 80126258Smlaier ? "IssuerSerial " : "") + "\""); 81126258Smlaier } 82126258Smlaier } 83126258Smlaier} 84126258Smlaier