[jboss-cvs] JBossAS SVN: r94953 - projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 15 11:20:37 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-10-15 11:20:37 -0400 (Thu, 15 Oct 2009)
New Revision: 94953
Modified:
projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/VirtualFile.java
Log:
Add getCertificates() convenience method
Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/VirtualFile.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/VirtualFile.java 2009-10-15 14:55:23 UTC (rev 94952)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/VirtualFile.java 2009-10-15 15:20:37 UTC (rev 94953)
@@ -29,6 +29,7 @@
import java.net.URL;
import java.net.URISyntaxException;
import java.security.CodeSigner;
+import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -418,8 +419,7 @@
/**
* Get the {@link CodeSigner}s for a the virtual file.
*
- * @return {@link CodeSigner} for the virtual file or null if not signed.
- * @throws IOException
+ * @return the {@link CodeSigner}s for the virtual file, or {@code null} if not signed
*/
public CodeSigner[] getCodeSigners() {
final VFS.Mount mount = VFS.getMount(this);
@@ -427,6 +427,24 @@
}
/**
+ * Get the {@link Certificate}s for the virtual file. Simply extracts the certificate entries from
+ * the code signers array.
+ *
+ * @return the certificates for the virtual file, or {@code null} if not signed
+ */
+ public Certificate[] getCertificates() {
+ final CodeSigner[] codeSigners = getCodeSigners();
+ if (codeSigners == null) {
+ return null;
+ }
+ final List<Certificate> certList = new ArrayList<Certificate>(codeSigners.length * 3);
+ for (CodeSigner signer : codeSigners) {
+ certList.addAll(signer.getSignerCertPath().getCertificates());
+ }
+ return certList.toArray(new Certificate[certList.size()]);
+ }
+
+ /**
* Get a human-readable (but non-canonical) representation of this virtual file.
*
* @return the string
More information about the jboss-cvs-commits
mailing list