Commit 0b182063 authored by Ricki Hirner's avatar Ricki Hirner 🐑

Use singleton objects instead of companion objects whenever possible

parent 83ba9b50
Pipeline #8917158 passed with stage
in 3 minutes and 58 seconds
......@@ -15,30 +15,28 @@ import java.util.logging.Level
import javax.net.ssl.TrustManagerFactory
import javax.net.ssl.X509TrustManager
class CertUtils {
companion object {
object CertUtils {
@JvmStatic
fun getTrustManager(keyStore: KeyStore?): X509TrustManager? {
try {
val tmf = TrustManagerFactory.getInstance("X509")
tmf.init(keyStore)
for (trustManager in tmf.trustManagers)
if (trustManager is X509TrustManager)
return trustManager
} catch(e: GeneralSecurityException) {
Constants.log.log(Level.SEVERE, "Couldn't initialize trust manager", e)
}
return null;
}
@JvmStatic
fun getTag(cert: X509Certificate): String {
val str = StringBuilder()
for (b in cert.signature)
str.append(String.format("%02x", b))
return str.toString()
@JvmStatic
fun getTrustManager(keyStore: KeyStore?): X509TrustManager? {
try {
val tmf = TrustManagerFactory.getInstance("X509")
tmf.init(keyStore)
for (trustManager in tmf.trustManagers)
if (trustManager is X509TrustManager)
return trustManager
} catch(e: GeneralSecurityException) {
Constants.log.log(Level.SEVERE, "Couldn't initialize trust manager", e)
}
return null;
}
@JvmStatic
fun getTag(cert: X509Certificate): String {
val str = StringBuilder()
for (b in cert.signature)
str.append(String.format("%02x", b))
return str.toString()
}
}
......@@ -10,14 +10,12 @@ package at.bitfire.cert4android
import java.util.logging.Logger
class Constants {
companion object {
object Constants {
@JvmField
var log: Logger = Logger.getLogger("cert4android")
@JvmField
var log: Logger = Logger.getLogger("cert4android")
@JvmField
val NOTIFICATION_CERT_DECISION = 88809
@JvmField
val NOTIFICATION_CERT_DECISION = 88809
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment