@Override public CredentialStorage createCredentialStorage(IdentityContext context, Account account, X509Certificate cert, CredentialStore<?> store, Date effectiveDate, Date expiryDate) { X509CertificateStorage storage = new X509CertificateStorage(cert); if (effectiveDate != null) { storage.setEffectiveDate(effectiveDate); } storage.setExpiryDate(expiryDate); return storage; } }
@Override protected boolean validateCredential(IdentityContext context, final CredentialStorage storage, final X509CertificateCredentials credentials, CredentialStore<?> store) { X509CertificateStorage certificateStorage = (X509CertificateStorage) storage; if (!credentials.isTrusted()) { try { byte[] certBytes = Base64.decode(certificateStorage.getBase64Cert()); CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); X509Certificate storedCert = (X509Certificate) certFactory .generateCertificate(new ByteArrayInputStream(certBytes)); X509Certificate providedCert = credentials.getCertificate(); return storedCert.equals(providedCert); } catch (Exception e) { throw new IdentityManagementException("Error while checking user's certificate.", e); } } return true; }
@Override protected boolean validateCredential(IdentityContext context, final CredentialStorage storage, final X509CertificateCredentials credentials, CredentialStore<?> store) { X509CertificateStorage certificateStorage = (X509CertificateStorage) storage; if (!credentials.isTrusted()) { try { byte[] certBytes = Base64.decode(certificateStorage.getBase64Cert()); CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); X509Certificate storedCert = (X509Certificate) certFactory .generateCertificate(new ByteArrayInputStream(certBytes)); X509Certificate providedCert = credentials.getCertificate(); return storedCert.equals(providedCert); } catch (Exception e) { throw new IdentityManagementException("Error while checking user's certificate.", e); } } return true; }
@Override public CredentialStorage createCredentialStorage(IdentityContext context, Account account, X509Certificate cert, CredentialStore<?> store, Date effectiveDate, Date expiryDate) { X509CertificateStorage storage = new X509CertificateStorage(cert); if (effectiveDate != null) { storage.setEffectiveDate(effectiveDate); } storage.setExpiryDate(expiryDate); return storage; } }