Serializable
public class CodeSource extends Object implements Serializable
This class extends the concept of a codebase to encapsulate not only the location (URL) but also the certificate chains that were used to verify signed code originating from that location.
Constructor | Description |
---|---|
CodeSource |
Constructs a CodeSource and associates it with the specified location and set of certificates. |
CodeSource |
Constructs a CodeSource and associates it with the specified location and set of code signers. |
Modifier and Type | Method | Description |
---|---|---|
boolean |
equals |
Tests for equality between the specified object and this object. |
final Certificate[] |
getCertificates() |
Returns the certificates associated with this CodeSource . |
final CodeSigner[] |
getCodeSigners() |
Returns the code signers associated with this CodeSource . |
final URL |
getLocation() |
Returns the location associated with this CodeSource . |
int |
hashCode() |
Returns the hash code value for this object. |
boolean |
implies |
Returns true if this CodeSource object "implies" the specified CodeSource . |
String |
toString() |
Returns a string describing this CodeSource , telling its URL and certificates. |
public CodeSource(URL url, Certificate[] certs)
CodeSource
and associates it with the specified location and set of certificates.url
- the location (URL). It may be null
.certs
- the certificate(s). It may be null
. The contents of the array are copied to protect against subsequent modification.public CodeSource(URL url, CodeSigner[] signers)
CodeSource
and associates it with the specified location and set of code signers.url
- the location (URL). It may be null
.signers
- the code signers. It may be null
. The contents of the array are copied to protect against subsequent modification.public int hashCode()
public boolean equals(Object obj)
CodeSource
objects are considered equal if their locations are of identical value and if their signer certificate chains are of identical value. It is not required that the certificate chains be in the same order.public final URL getLocation()
CodeSource
.null
if no URL was supplied during construction.public final Certificate[] getCertificates()
CodeSource
. If this CodeSource
object was created using the CodeSource(URL url, CodeSigner[] signers)
constructor then its certificate chains are extracted and used to create an array of Certificate
objects. Each signer certificate is followed by its supporting certificate chain (which may be empty). Each signer certificate and its supporting certificate chain is ordered bottom-to-top (i.e., with the signer certificate first and the (root) certificate authority last).
null
if there is none.public final CodeSigner[] getCodeSigners()
CodeSource
. If this CodeSource
object was created using the CodeSource(URL url, java.security.cert.Certificate[] certs)
constructor then its certificate chains are extracted and used to create an array of CodeSigner
objects. Note that only X.509 certificates are examined - all other certificate types are ignored.
null
if there is none.public boolean implies(CodeSource codesource)
CodeSource
object "implies" the specified CodeSource
. More specifically, this method makes the following checks. If any fail, it returns false
. If they all succeed, it returns true
.
For example, the codesource objects with the following locations and null
certificates all imply the codesource with the location http://www.example.com/classes/foo.jar
and null
certificates:
http: http://*.example.com/classes/* http://www.example.com/classes/- http://www.example.com/classes/foo.jarNote that if this
CodeSource
has a null
location and a null
certificate chain, then it implies every other CodeSource
.codesource
- CodeSource
to compare against.true
if the specified codesource is implied by this codesource, false
if not.public String toString()
CodeSource
, telling its URL and certificates.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/CodeSource.html