Class JarCertVerifier
java.lang.Object
net.sourceforge.jnlp.tools.JarCertVerifier
- All Implemented Interfaces:
CertVerifier
The jar certificate verifier utility.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AppVerifierThe application verifier to use by this instanceprivate final Map<CertPath, CertInformation> The certificates used for jar verification linked to their respective informationprivate CertPathTemporary cert path hack to be used to keep track of which one a UI dialog is usingAbsolute location to jars and the number of entries which are possibly signableprivate static final Loggerprivate static final Stringprivate static final PatternAll of the jar files that were not verifiedAll of the jar files that were verified for signing -
Constructor Summary
ConstructorsConstructorDescriptionJarCertVerifier(AppVerifier verifier) Create a new jar certificate verifier utility that uses the provided verifier for its strategy pattern. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(List<JARDesc> jars, ResourceTracker tracker) Update the verifier to consider new jars when verifying.voidadd(JARDesc jar, ResourceTracker tracker) Update the verifier to consider a new jar when verifying.booleanReturns if all jars are signed.private voidcheckCertUsage(CertPath certPath, X509Certificate userCert) Check if userCert is designed to be a code signerprivate voidcheckTrustedCerts(CertPath certPath) Checks the user's trusted.certs file and the cacerts file to see if a publisher's and/or CA's certificate exists there.voidcheckTrustWithUser(SecurityDelegate securityDelegate, JNLPFile file) booleangetCertInformation(CertPath cPath) Find the information the specified cert path has with respect to this application.Get a list of the cert paths of all signers across the app.getDetails(CertPath certPath) getPublisher(CertPath certPath) booleanstatic intgetTotalJarEntries(Map<String, Integer> map) Get the total number of entries in the provided map.(package private) static booleanhasObjectSigningBit(byte[] netscapeEx) booleanReturns whether or not the app is considered completely signed.static booleanisJarSigned(JARDesc jar, AppVerifier verifier, ResourceTracker tracker) (package private) static booleanisMetaInfFile(String name) Returns whether a file is in META-INF, and thus does not require signing.private booleanisSigned()booleanprivate booleanisTrustedTsa(CertPath certPath) voidsetCurrentlyUsedCertPath(CertPath certPath) private static voidvalidateCertpathWhenRootCANotInChain(CertPath certPath, KeyStore caKeyStore) private JarCertVerifier.VerifyResultChecks through all the jar entries of jarName for signers, storing all the common ones in the certs hash map.(package private) JarCertVerifier.VerifyResultverifyJarEntryCerts(String jarPath, boolean jarHasManifest, List<JarEntry> entries) Checks through all the jar entries for signers, storing all the common ones in the certs hash map.private voidverifyJars(List<JARDesc> jars, ResourceTracker tracker) Verify the jars provided and update the state of this instance to match the new information.private JarCertVerifier.VerifyResultverifySigners(Map<CertPath, Integer> jarSignCount) private ZonedDateTimezonedDateTime(Date date)
-
Field Details
-
LOG
-
META_INF
- See Also:
-
SIG
-
verifiedJars
-
unverifiedJars
-
certs
The certificates used for jar verification linked to their respective information -
jarSignableEntries
-
appVerifier
The application verifier to use by this instance -
currentlyUsed
Temporary cert path hack to be used to keep track of which one a UI dialog is using
-
-
Constructor Details
-
JarCertVerifier
Create a new jar certificate verifier utility that uses the provided verifier for its strategy pattern.- Parameters:
verifier- The application verifier to be used by the new instance.
-
-
Method Details
-
isTriviallySigned
public boolean isTriviallySigned()- Returns:
- true if there are no signable entries in the jar. This will return false if any of verified jars have content more than just META-INF/.
-
getAlreadyTrustPublisher
public boolean getAlreadyTrustPublisher()- Specified by:
getAlreadyTrustPublisherin interfaceCertVerifier- Returns:
- if the publisher is already trusted
-
getRootInCaCerts
public boolean getRootInCaCerts()- Specified by:
getRootInCaCertsin interfaceCertVerifier- Returns:
- if the root is in CA certs
-
getCertPath
- Specified by:
getCertPathin interfaceCertVerifier- Returns:
- a valid certificate path to this certificate being verified
-
getDetails
- Specified by:
getDetailsin interfaceCertVerifier- Parameters:
certPath- certificate- Returns:
- the details regarding issue with this certificate
-
getCertsList
-
getCertInformation
Find the information the specified cert path has with respect to this application.- Parameters:
cPath- certificate to provide info- Returns:
- All the information the path has with this app.
-
isFullySigned
public boolean isFullySigned()Returns whether or not the app is considered completely signed.An app using a JNLP is considered signed if all of the entries of its jars are signed by at least one common signer.
An applet on the other hand only needs to have each individual jar be fully signed by a signer. The signers can differ between jars.
- Returns:
- Whether or not the app is considered signed.
-
isSigned
private boolean isSigned() -
isJarSigned
public static boolean isJarSigned(JARDesc jar, AppVerifier verifier, ResourceTracker tracker) throws Exception - Throws:
Exception
-
add
Update the verifier to consider a new jar when verifying.- Parameters:
jar- A new jars to be verified.tracker- Resource tracker used to obtain the the jars from cache- Throws:
Exception- Caused by issues with obtaining the jars' entries or interacting with the tracker.
-
add
Update the verifier to consider new jars when verifying.- Parameters:
jars- List of new jars to be verified.tracker- Resource tracker used to obtain the the jars from cache- Throws:
Exception- Caused by issues with obtaining the jars' entries or interacting with the tracker.
-
verifyJars
Verify the jars provided and update the state of this instance to match the new information.- Parameters:
jars- List of new jars to be verified.tracker- Resource tracker used to obtain the the jars from cache- Throws:
Exception- Caused by issues with obtaining the jars' entries or interacting with the tracker.
-
verifyJar
Checks through all the jar entries of jarName for signers, storing all the common ones in the certs hash map.- Parameters:
jarPath- The absolute path to the jar file.- Returns:
- The return of
verifyJarEntryCerts(String, boolean, List)using the entries found in the jar located at jarName.
-
verifyJarEntryCerts
JarCertVerifier.VerifyResult verifyJarEntryCerts(String jarPath, boolean jarHasManifest, List<JarEntry> entries) Checks through all the jar entries for signers, storing all the common ones in the certs hash map.- Parameters:
jarPath- The absolute path to the jar file.jarHasManifest- Whether or not the associated jar has a manifest.entries- The list of entries in the associated jar.- Returns:
- If there is at least one signable entry that is not signed by a common signer, return UNSIGNED. Otherwise every signable entry is signed by at least one common signer. If the signer has no issues, return SIGNED_OK. If there are any signing issues, return SIGNED_NOT_OK.
- Throws:
RuntimeException- Will be thrown if there are issues with entries.
-
isTrustedTsa
-
verifySigners
-
zonedDateTime
-
checkTrustedCerts
Checks the user's trusted.certs file and the cacerts file to see if a publisher's and/or CA's certificate exists there.- Parameters:
certPath- The cert path of the signer being checked for trust.
-
validateCertpathWhenRootCANotInChain
private static void validateCertpathWhenRootCANotInChain(CertPath certPath, KeyStore caKeyStore) throws KeyStoreException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, CertPathValidatorException -
setCurrentlyUsedCertPath
-
getPublisher
- Specified by:
getPublisherin interfaceCertVerifier- Parameters:
certPath- to be read for publisher- Returns:
- the application's publisher's certificate.
-
getRoot
- Specified by:
getRootin interfaceCertVerifier- Parameters:
certPath- certificate- Returns:
- the application's root's certificate. This may return the same certificate as getPublisher(CertPath certPath) in the event that the application is self signed.
-
isMetaInfFile
Returns whether a file is in META-INF, and thus does not require signing.Signature-related files under META-INF include: . META-INF/MANIFEST.MF . META-INF/SIG-* . META-INF/*.SF . META-INF/*.DSA . META-INF/*.RSA
-
checkCertUsage
Check if userCert is designed to be a code signer- Parameters:
userCert- the certificate to be examined
-
hasObjectSigningBit
static boolean hasObjectSigningBit(byte[] netscapeEx) - Parameters:
netscapeEx- DER value of the Netscape cert type extension: OCTET STRING { BIT STRING }- Returns:
- whether bit 3 (object signing) is set; false if malformed
-
allJarsSigned
public boolean allJarsSigned()Returns if all jars are signed.- Returns:
- True if all jars are signed, false if there are one or more unsigned jars
-
checkTrustWithUser
public void checkTrustWithUser(SecurityDelegate securityDelegate, JNLPFile file) throws LaunchException - Throws:
LaunchException
-
getJarSignableEntries
-
getTotalJarEntries
-