Search in sources :

Example 1 with CertificateChainInfo

use of org.platformlayer.auth.model.CertificateChainInfo in project platformlayer by platformlayer.

the class RootResource method requireSystemAccess.

protected void requireSystemAccess() throws AuthenticatorException {
    X509Certificate[] certChain = getCertificateChain();
    if (certChain != null && certChain.length != 0) {
        CertificateChainInfo chain = new CertificateChainInfo();
        for (X509Certificate cert : certChain) {
            CertificateInfo info = new CertificateInfo();
            info.publicKey = Hex.toHex(cert.getPublicKey().getEncoded());
            info.subjectDN = Certificates.getSubject(cert);
            // Md5Hash hash = OpenSshUtils.getSignature(cert.getPublicKey());
            // certificateInfo.setPublicKeyHash(hash.toHex());
            chain.certificates.add(info);
        }
        ServiceAccount auth = systemAuthenticator.authenticate(chain);
        if (auth != null) {
            log.debug("Certificate authentication SUCCESS for " + chain);
            return;
        }
        log.debug("Certificate authentication FAIL for " + chain);
    } else {
        log.debug("Certificate authentication FAIL (no certificate presented)");
    }
    throwUnauthorized();
// return myTokenInfo;
}
Also used : ServiceAccount(org.platformlayer.auth.ServiceAccount) CertificateChainInfo(org.platformlayer.auth.model.CertificateChainInfo) CertificateInfo(org.platformlayer.auth.model.CertificateInfo) X509Certificate(java.security.cert.X509Certificate)

Aggregations

X509Certificate (java.security.cert.X509Certificate)1 ServiceAccount (org.platformlayer.auth.ServiceAccount)1 CertificateChainInfo (org.platformlayer.auth.model.CertificateChainInfo)1 CertificateInfo (org.platformlayer.auth.model.CertificateInfo)1