public static boolean isAuthnContextMatching(List requestedACClassRefs,String acClassRef,String comparison,Map acClassRefLevelMap){
  Integer levelInt=(Integer)acClassRefLevelMap.get(acClassRef);
  if (levelInt == null) {
    if (debug.messageEnabled()) {
      debug.message("SAML2Utils.isAuthnContextMatching: " + "AuthnContextClassRef " + acClassRef + " is not supported.");
    }
    return false;
  }
  int level=levelInt.intValue();
  if ((comparison == null) || (comparison.length() == 0) || (comparison.equals("exact"))) {
    for (Iterator iter=requestedACClassRefs.iterator(); iter.hasNext(); ) {
      String requstedACClassRef=(String)iter.next();
      if (requstedACClassRef.equals(acClassRef)) {
        return true;
      }
    }
    return false;
  }
  debug.message("SAML2Utils.isAuthnContextMatching: acClassRef = {}, level = {}, comparison = {}",acClassRef,level,comparison);
  if (comparison.equals("minimum")) {
    for (Iterator iter=requestedACClassRefs.iterator(); iter.hasNext(); ) {
      String requstedACClassRef=(String)iter.next();
      Integer requestedLevelInt=(Integer)acClassRefLevelMap.get(requstedACClassRef);
      int requestedLevel=(requestedLevelInt == null) ? 0 : requestedLevelInt.intValue();
      if (debug.messageEnabled()) {
        debug.message("SAML2Utils." + "isAuthnContextMatching: requstedACClassRef = " + requstedACClassRef + ", level = "+ requestedLevel);
      }
      if (level >= requestedLevel) {
        return true;
      }
    }
    return false;
  }
 else   if (comparison.equals("better")) {
    for (Iterator iter=requestedACClassRefs.iterator(); iter.hasNext(); ) {
      String requstedACClassRef=(String)iter.next();
      Integer requestedLevelInt=(Integer)acClassRefLevelMap.get(requstedACClassRef);
      int requestedLevel=(requestedLevelInt == null) ? 0 : requestedLevelInt.intValue();
      if (debug.messageEnabled()) {
        debug.message("SAML2Utils." + "isAuthnContextMatching: requstedACClassRef = " + requstedACClassRef + ", level = "+ requestedLevel);
      }
      if (level <= requestedLevel) {
        return false;
      }
    }
    return true;
  }
 else   if (comparison.equals("maximum")) {
    for (Iterator iter=requestedACClassRefs.iterator(); iter.hasNext(); ) {
      String requstedACClassRef=(String)iter.next();
      Integer requestedLevelInt=(Integer)acClassRefLevelMap.get(requstedACClassRef);
      int requestedLevel=(requestedLevelInt == null) ? 0 : requestedLevelInt.intValue();
      if (debug.messageEnabled()) {
        debug.message("SAML2Utils." + "isAuthnContextMatching: requstedACClassRef = " + requstedACClassRef + ", level = "+ requestedLevel);
      }
      if (level <= requestedLevel) {
        return true;
      }
    }
    return false;
  }
  return false;
}

public static boolean isAuthnContextMatching ( List requestedACClassRefs , String acClassRef , String comparison , Map acClassRefLevelMap ) { Integer levelInt = ( Integer ) acClassRefLevelMap . get ( acClassRef ) ; if ( levelInt == null ) { if ( debug . messageEnabled ( ) ) { debug . message ( "SAML2Utils.isAuthnContextMatching: " + "AuthnContextClassRef " + acClassRef + " is not supported." ) ; } return false ; } int level = levelInt . intValue ( ) ; if ( ( comparison == null ) || ( comparison . length ( ) == 0 ) || ( comparison . equals ( "exact" ) ) ) { for ( Iterator iter = requestedACClassRefs . iterator ( ) ; iter . hasNext ( ) ; ) { String requstedACClassRef = ( String ) iter . next ( ) ; if ( requstedACClassRef . equals ( acClassRef ) ) { return true ; } } return false ; } debug . message ( "SAML2Utils.isAuthnContextMatching: acClassRef = {}, level = {}, comparison = {}" , acClassRef , level , comparison ) ; if ( comparison . equals ( "minimum" ) ) { for ( Iterator iter = requestedACClassRefs . iterator ( ) ; iter . hasNext ( ) ; ) { String requstedACClassRef = ( String ) iter . next ( ) ; Integer requestedLevelInt = ( Integer ) acClassRefLevelMap . get ( requstedACClassRef ) ; int requestedLevel = ( requestedLevelInt == null ) ? 0 : requestedLevelInt . intValue ( ) ; if ( debug . messageEnabled ( ) ) { debug . message ( "SAML2Utils." + "isAuthnContextMatching: requstedACClassRef = " + requstedACClassRef + ", level = " + requestedLevel ) ; } if ( level >= requestedLevel ) { return true ; } } return false ; } else if ( comparison . equals ( "better" ) ) { for ( Iterator iter = requestedACClassRefs . iterator ( ) ; iter . hasNext ( ) ; ) { String requstedACClassRef = ( String ) iter . next ( ) ; Integer requestedLevelInt = ( Integer ) acClassRefLevelMap . get ( requstedACClassRef ) ; int requestedLevel = ( requestedLevelInt == null ) ? 0 : requestedLevelInt . intValue ( ) ; if ( debug . messageEnabled ( ) ) { debug . message ( "SAML2Utils." + "isAuthnContextMatching: requstedACClassRef = " + requstedACClassRef + ", level = " + requestedLevel ) ; } if ( level <= requestedLevel ) { return false ; } } return true ; } else if ( comparison . equals ( "maximum" ) ) { for ( Iterator iter = requestedACClassRefs . iterator ( ) ; iter . hasNext ( ) ; ) { String requstedACClassRef = ( String ) iter . next ( ) ; Integer requestedLevelInt = ( Integer ) acClassRefLevelMap . get ( requstedACClassRef ) ; int requestedLevel = ( requestedLevelInt == null ) ? 0 : requestedLevelInt . intValue ( ) ; if ( debug . messageEnabled ( ) ) { debug . message ( "SAML2Utils." + "isAuthnContextMatching: requstedACClassRef = " + requstedACClassRef + ", level = " + requestedLevel ) ; } if ( level <= requestedLevel ) { return true ; } } return false ; } return false ; }
returns true if the specified authncontextclassref matches a list of requested authncontextclassref .
