private void validate ( final X509Certificate cert ) throws GeneralSecurityException { cert . checkValidity ( ) ; this . revocationChecker . check ( cert ) ; val pathLength = cert . getBasicConstraints ( ) ; if ( pathLength < 0 ) { if ( ! isCertificateAllowed ( cert ) ) { throw new FailedLoginException ( "Certificate subject does not match pattern " + this . regExSubjectDnPattern . pattern ( ) ) ; } if ( this . checkKeyUsage && ! isValidKeyUsage ( cert ) ) { throw new FailedLoginException ( "Certificate keyUsage constraint forbids SSL client authentication." ) ; } } else { if ( pathLength == Integer . MAX_VALUE && ! this . maxPathLengthAllowUnspecified ) { throw new FailedLoginException ( "Unlimited certificate path length not allowed by configuration." ) ; } if ( pathLength > this . maxPathLength && pathLength < Integer . MAX_VALUE ) { throw new FailedLoginException ( String . format ( "Certificate path length %s exceeds maximum value %s." , pathLength , this . maxPathLength ) ) ; } } }
Validate the X509Certificate received .