private static boolean validateSAMLResponseForFedlet(Response samlResp,String spEntityID,boolean wantNameIDEncrypted) throws SAML2Exception {
  boolean resp=true;
  if (samlResp != null && samlResp.isSigned()) {
    List assertions=null;
    if (wantNameIDEncrypted) {
      assertions=samlResp.getEncryptedAssertion();
    }
 else {
      assertions=samlResp.getAssertion();
    }
    if (assertions == null) {
      return false;
    }
    for (Iterator asserIter=assertions.iterator(); asserIter.hasNext(); ) {
      Assertion assertion=null;
      if (wantNameIDEncrypted) {
        assertion=getDecryptedAssertion((EncryptedAssertion)asserIter.next(),spEntityID);
      }
 else {
        assertion=(Assertion)asserIter.next();
      }
      if (assertion != null) {
        Conditions conditions=assertion.getConditions();
        if (conditions != null) {
          List audienceRes=conditions.getAudienceRestrictions();
          if (audienceRes.size() > 1) {
            resp=false;
            break;
          }
        }
        List statements=assertion.getAttributeStatements();
        if (statements.size() > 1) {
          resp=false;
          break;
        }
      }
    }
  }
 else {
    resp=false;
  }
  return resp;
}

private static boolean validateSAMLResponseForFedlet ( Response samlResp , String spEntityID , boolean wantNameIDEncrypted ) throws SAML2Exception { boolean resp = true ; if ( samlResp != null && samlResp . isSigned ( ) ) { List assertions = null ; if ( wantNameIDEncrypted ) { assertions = samlResp . getEncryptedAssertion ( ) ; } else { assertions = samlResp . getAssertion ( ) ; } if ( assertions == null ) { return false ; } for ( Iterator asserIter = assertions . iterator ( ) ; asserIter . hasNext ( ) ; ) { Assertion assertion = null ; if ( wantNameIDEncrypted ) { assertion = getDecryptedAssertion ( ( EncryptedAssertion ) asserIter . next ( ) , spEntityID ) ; } else { assertion = ( Assertion ) asserIter . next ( ) ; } if ( assertion != null ) { Conditions conditions = assertion . getConditions ( ) ; if ( conditions != null ) { List audienceRes = conditions . getAudienceRestrictions ( ) ; if ( audienceRes . size ( ) > 1 ) { resp = false ; break ; } } List statements = assertion . getAttributeStatements ( ) ; if ( statements . size ( ) > 1 ) { resp = false ; break ; } } } } else { resp = false ; } return resp ; }
validates the saml response obtained from attribute authortity
