author | jlaskey |
Thu, 21 Jun 2018 08:58:59 -0300 | |
changeset 50695 | 36ca515343e0 |
parent 50614 | 3810c9a2efa1 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* reserved comment block |
|
3 |
* DO NOT REMOVE OR ALTER! |
|
4 |
*/ |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
5 |
/** |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
6 |
* Licensed to the Apache Software Foundation (ASF) under one |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
7 |
* or more contributor license agreements. See the NOTICE file |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
8 |
* distributed with this work for additional information |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
9 |
* regarding copyright ownership. The ASF licenses this file |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
10 |
* to you under the Apache License, Version 2.0 (the |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
11 |
* "License"); you may not use this file except in compliance |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
12 |
* with the License. You may obtain a copy of the License at |
2 | 13 |
* |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
14 |
* http://www.apache.org/licenses/LICENSE-2.0 |
2 | 15 |
* |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
16 |
* Unless required by applicable law or agreed to in writing, |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
17 |
* software distributed under the License is distributed on an |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
18 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
19 |
* KIND, either express or implied. See the License for the |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
20 |
* specific language governing permissions and limitations |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
21 |
* under the License. |
2 | 22 |
*/ |
23 |
package com.sun.org.apache.xml.internal.security.keys; |
|
24 |
||
25 |
import java.io.PrintStream; |
|
26 |
import java.security.PublicKey; |
|
27 |
||
28 |
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; |
|
29 |
import com.sun.org.apache.xml.internal.security.keys.content.KeyName; |
|
30 |
import com.sun.org.apache.xml.internal.security.keys.content.KeyValue; |
|
31 |
import com.sun.org.apache.xml.internal.security.keys.content.MgmtData; |
|
32 |
import com.sun.org.apache.xml.internal.security.keys.content.X509Data; |
|
33 |
||
34 |
/** |
|
50614
3810c9a2efa1
8177334: Update xmldsig implementation to Apache Santuario 2.1.1
weijun
parents:
47216
diff
changeset
|
35 |
* Utility class for {@code com.sun.org.apache.xml.internal.security.keys} package. |
2 | 36 |
* |
37 |
*/ |
|
50614
3810c9a2efa1
8177334: Update xmldsig implementation to Apache Santuario 2.1.1
weijun
parents:
47216
diff
changeset
|
38 |
public final class KeyUtils { |
2 | 39 |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
40 |
private KeyUtils() { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
41 |
// no instantiation |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
42 |
} |
2 | 43 |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
44 |
/** |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
45 |
* Method prinoutKeyInfo |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
46 |
* |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
47 |
* @param ki |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
48 |
* @param os |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
49 |
* @throws XMLSecurityException |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
50 |
*/ |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
51 |
public static void prinoutKeyInfo(KeyInfo ki, PrintStream os) |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
52 |
throws XMLSecurityException { |
2 | 53 |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
54 |
for (int i = 0; i < ki.lengthKeyName(); i++) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
55 |
KeyName x = ki.itemKeyName(i); |
2 | 56 |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
57 |
os.println("KeyName(" + i + ")=\"" + x.getKeyName() + "\""); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
58 |
} |
2 | 59 |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
60 |
for (int i = 0; i < ki.lengthKeyValue(); i++) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
61 |
KeyValue x = ki.itemKeyValue(i); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
62 |
PublicKey pk = x.getPublicKey(); |
2 | 63 |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
64 |
os.println("KeyValue Nr. " + i); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
65 |
os.println(pk); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
66 |
} |
2 | 67 |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
68 |
for (int i = 0; i < ki.lengthMgmtData(); i++) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
69 |
MgmtData x = ki.itemMgmtData(i); |
2 | 70 |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
71 |
os.println("MgmtData(" + i + ")=\"" + x.getMgmtData() + "\""); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
72 |
} |
2 | 73 |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
74 |
for (int i = 0; i < ki.lengthX509Data(); i++) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
75 |
X509Data x = ki.itemX509Data(i); |
2 | 76 |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
77 |
os.println("X509Data(" + i + ")=\"" + (x.containsCertificate() |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
78 |
? "Certificate " : "") + (x.containsIssuerSerial() |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
79 |
? "IssuerSerial " : "") + "\""); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
80 |
} |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
1337
diff
changeset
|
81 |
} |
2 | 82 |
} |