*/
synchronized void checkAuthentication()
throws UnsupportedConstraintException
{
if (clientCredential == null) {
throw new UnsupportedConstraintException(
"Client is not authenticated");
} else if (clientCredential.isDestroyed()) {
throw new UnsupportedConstraintException(
"Private credentials are destroyed");
} else if (System.currentTimeMillis() > credentialsValidUntil) {
throw new UnsupportedConstraintException(
"Certificates are no longer valid");
}
if (subjectIsReadOnly) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(authenticationPermission);
}
} else {
Subject subject = getSubject();
X509Certificate cert = clientCredential.getCertificate();
if (SubjectCredentials.getPrincipal(subject, cert) == null) {
throw new UnsupportedConstraintException("Missing principal");
}
CertPath chain =
SubjectCredentials.getCertificateChain(subject, cert);
if (chain == null) {
throw new UnsupportedConstraintException(
"Missing public credentials");
}
X500PrivateCredential pc = getPrivateCredential(
cert, authenticationPermission);
if (pc == null) {
throw new UnsupportedConstraintException(
"Missing private credentials");
} else if (!equalPrivateCredentials(clientCredential, pc)) {
throw new UnsupportedConstraintException(
"Wrong private credentials");
}
}
}