getCertificates(): This method is available in the java.net.JarURLConnection class of Java.
Syntax:
Certificate[] java.net.JarURLConnection.getCertificates() throws IOException
This method returns the Certificate objects for this connection if the URL for it points to a JAR file entry, null otherwise. This method can only be called once the connection has been completely verified by reading from the input stream until the end of the stream has been reached. Otherwise, this method will return null
Parameters: NA
Returns: the Certificate object for this connection if the URL for it points to a JAR file entry, null otherwise.
Throws:
1. IOException - if getting the JAR entry causes an IOException to be thrown.
Approach
Java
package com.JarURLConnection;import java.net.JarURLConnection;import java.net.URL;import java.util.Arrays;public class JarURLConnectiongetCertificates {private final static String JAR_URL ="jar:file:/D:/testClass.jar!/";public static void main(String[] args) throws Exception {URL FileSysUrl = new URL(JAR_URL);JarURLConnection jarURLConn =(JarURLConnection) FileSysUrl.openConnection();System.out.println(Arrays.toString(jarURLConn.getCertificates()));}}
Output:
null
Some other methods of JarURLConnection class
getAttributes(): This method returns the Attributes object for this connection if its URL points to a JAR file entry, null otherwise.
getCertificates(): This method returns the Certificate objects for this connection if the URL for it points to a JAR file entry, null otherwise.
getEntryName(): This method returns the entry name for this connection.
getJarEntry(): This method returns the JAR entry object for this connection if any.
getJarFile(): This method returns the JAR file for this connection.
getJarFileURL(): This method returns the URL for the Jar file for this connection.
getMainAttributes(): This method returns the main Attributes for the JAR file for this connection.
getManifest(): This method returns the Manifest for this connection, or null if none.
No comments:
Post a Comment