private void indexCertificate ( X509Certificate cert ) { X500Principal subject = cert . getSubjectX500Principal ( ) ; Object oldEntry = certSubjects . put ( subject , cert ) ; if ( oldEntry != null ) { // assume this is unlikely if ( oldEntry instanceof X509Certificate ) { if ( cert . equals ( oldEntry ) ) { return ; } List < X509Certificate > list = new ArrayList <> ( 2 ) ; list . add ( cert ) ; list . add ( ( X509Certificate ) oldEntry ) ; certSubjects . put ( subject , list ) ; } else { @ SuppressWarnings ( "unchecked" ) // See certSubjects javadoc. List < X509Certificate > list = ( List < X509Certificate > ) oldEntry ; if ( list . contains ( cert ) == false ) { list . add ( cert ) ; } certSubjects . put ( subject , list ) ; } } }
Add an X509Certificate to the index .