/**
  * @param SAML2_AuthnRequest $authnRequest
  * @param SimpleSAML_Configuration $idpConfig
  * @param $nameId
  * @param $issuer
  * @param array $attributes
  * @return SAML2_Response
  */
 public function create(SAML2_AuthnRequest $authnRequest, SimpleSAML_Configuration $idpConfig, $nameId, $issuer, array $attributes)
 {
     /* $returnAttributes contains the attributes we should return. Send them. */
     $assertion = new SAML2_Assertion();
     $assertion->setIssuer($issuer);
     $assertion->setNameId(array('Value' => $nameId, 'Format' => SAML2_Const::NAMEID_UNSPECIFIED));
     $assertion->setNotBefore(time());
     $assertion->setNotOnOrAfter(time() + 5 * 60);
     // Valid audiences is not required so disabled for now
     // $assertion->setValidAudiences(array($authnRequest->getIssuer()));
     $assertion->setAttributes($attributes);
     $assertion->setAttributeNameFormat(SAML2_Const::NAMEFORMAT_UNSPECIFIED);
     $assertion->setAuthnContext(SAML2_Const::AC_PASSWORD);
     $subjectConfirmation = new SAML2_XML_saml_SubjectConfirmation();
     $subjectConfirmation->Method = SAML2_Const::CM_BEARER;
     $subjectConfirmation->SubjectConfirmationData = new SAML2_XML_saml_SubjectConfirmationData();
     $subjectConfirmation->SubjectConfirmationData->NotOnOrAfter = time() + 5 * 60;
     $subjectConfirmation->SubjectConfirmationData->Recipient = $authnRequest->getAssertionConsumerServiceURL();
     $subjectConfirmation->SubjectConfirmationData->InResponseTo = $authnRequest->getId();
     $assertion->setSubjectConfirmation(array($subjectConfirmation));
     $response = new SAML2_Response();
     $response->setRelayState($authnRequest->getRelayState());
     $response->setDestination($authnRequest->getAssertionConsumerServiceURL());
     $response->setIssuer($issuer);
     $response->setInResponseTo($authnRequest->getId());
     $response->setAssertions(array($assertion));
     $this->addSigns($response, $idpConfig);
     return $response;
 }