private boolean calculateAuthenticationSuccess(Object principal,Object credentials,Object tokenDetails){
  boolean successAuthentication=false;
  if (credentials instanceof Collection) {
    final Collection<?> multiValueCredentials=(Collection<?>)credentials;
    if (multiValueCredentials.contains(principal)) {
      successAuthentication=checkSourceIPAddressIfNeccessary(tokenDetails);
    }
  }
 else   if (principal.equals(credentials)) {
    successAuthentication=checkSourceIPAddressIfNeccessary(tokenDetails);
  }
  return successAuthentication;
}

private boolean calculateAuthenticationSuccess ( Object principal , Object credentials , Object tokenDetails ) { boolean successAuthentication = false ; if ( credentials instanceof Collection ) { final Collection < ? > multiValueCredentials = ( Collection < ? > ) credentials ; if ( multiValueCredentials . contains ( principal ) ) { successAuthentication = checkSourceIPAddressIfNeccessary ( tokenDetails ) ; } } else if ( principal . equals ( credentials ) ) { successAuthentication = checkSourceIPAddressIfNeccessary ( tokenDetails ) ; } return successAuthentication ; }
the credentials may either be of type headerauthentication or of type collection < headerauthentication > depending on the authentication mode in use ( the latter is used in case of trusted reverse - proxy ) . it is checked whether principal equals credentials ( respectively if credentials contains principal in case of collection ) because we want to check if e . g . controllerid containing in the url equals the controllerid in the special header set by the reverse - proxy which extracted the cn from the certificate .
