test_class.file: saml-core/src/test/java/org/keycloak/saml/processing/core/saml/v2/writers/SAMLAssertionWriterTest.java
test_class.identifier: SAMLAssertionWriterTest
test_case.body: @Test
      public void testAuthnStatementSessionNotOnOrAfterExists() throws ProcessingException {
          long sessionLengthInSeconds = 3600;
  
          XMLGregorianCalendar issueInstant = XMLTimeUtil.getIssueInstant();
          XMLGregorianCalendar sessionExpirationDate = XMLTimeUtil.add(issueInstant, sessionLengthInSeconds);
  
          AuthnStatementType authnStatementType = new AuthnStatementType(issueInstant);
  
          authnStatementType.setSessionIndex("9b3cf799-225b-424a-8e5e-ee3c38e06ded::24b2f572-163c-43ad-8011-de6cd3803f76");
          authnStatementType.setSessionNotOnOrAfter(sessionExpirationDate);
  
          ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
          SAMLAssertionWriter samlAssertionWriter = new SAMLAssertionWriter(StaxUtil.getXMLStreamWriter(byteArrayOutputStream));
  
          samlAssertionWriter.write(authnStatementType, true);
  
          String serializedAssertion = new String(byteArrayOutputStream.toByteArray(), GeneralConstants.SAML_CHARSET);
          String expectedXMLAttribute = "SessionNotOnOrAfter=\"" + sessionExpirationDate.toString() + "\"";
  
          Assert.assertTrue(serializedAssertion.contains(expectedXMLAttribute));
      }
test_case.class_method_signature: SAMLAssertionWriterTest.testAuthnStatementSessionNotOnOrAfterExists()
test_case.full_signature: @Test public void testAuthnStatementSessionNotOnOrAfterExists()
test_case.identifier: testAuthnStatementSessionNotOnOrAfterExists
test_case.invocations: getIssueInstant add setSessionIndex setSessionNotOnOrAfter getXMLStreamWriter write toByteArray toString assertTrue contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testAuthnStatementSessionNotOnOrAfterExists()
focal_class.file: saml-core/src/main/java/org/keycloak/saml/processing/core/saml/v2/writers/SAMLAssertionWriter.java
focal_class.identifier: SAMLAssertionWriter
focal_class.class_method_signature: SAMLAssertionWriter.SAMLAssertionWriter(XMLStreamWriter writer)
focal_class.full_signature: public  SAMLAssertionWriter(XMLStreamWriter writer)
focal_class.identifier: SAMLAssertionWriter
focal_class.modifiers: public
focal_class.parameters: (XMLStreamWriter writer)
focal_class.signature:  SAMLAssertionWriter(XMLStreamWriter writer)
focal_class.class_method_signature: SAMLAssertionWriter.write(AssertionType assertion)
focal_class.full_signature: public void write(AssertionType assertion)
focal_class.identifier: write
focal_class.modifiers: public
focal_class.parameters: (AssertionType assertion)
focal_class.return: void
focal_class.signature: void write(AssertionType assertion)
focal_class.class_method_signature: SAMLAssertionWriter.write(StatementAbstractType statement)
focal_class.full_signature: public void write(StatementAbstractType statement)
focal_class.identifier: write
focal_class.modifiers: public
focal_class.parameters: (StatementAbstractType statement)
focal_class.return: void
focal_class.signature: void write(StatementAbstractType statement)
focal_class.class_method_signature: SAMLAssertionWriter.write(AttributeStatementType statement)
focal_class.full_signature: public void write(AttributeStatementType statement)
focal_class.identifier: write
focal_class.modifiers: public
focal_class.parameters: (AttributeStatementType statement)
focal_class.return: void
focal_class.signature: void write(AttributeStatementType statement)
focal_class.class_method_signature: SAMLAssertionWriter.write(AuthnStatementType authnStatement, boolean includeNamespace)
focal_class.full_signature: public void write(AuthnStatementType authnStatement, boolean includeNamespace)
focal_class.identifier: write
focal_class.modifiers: public
focal_class.parameters: (AuthnStatementType authnStatement, boolean includeNamespace)
focal_class.return: void
focal_class.signature: void write(AuthnStatementType authnStatement, boolean includeNamespace)
focal_class.class_method_signature: SAMLAssertionWriter.write(AuthnContextType authContext)
focal_class.full_signature: public void write(AuthnContextType authContext)
focal_class.identifier: write
focal_class.modifiers: public
focal_class.parameters: (AuthnContextType authContext)
focal_class.return: void
focal_class.signature: void write(AuthnContextType authContext)
focal_class.superclass: extends BaseWriter
focal_method.body: public void write(AssertionType assertion) throws ProcessingException {
          StaxUtil.writeStartElement(writer, ASSERTION_PREFIX, JBossSAMLConstants.ASSERTION.get(), ASSERTION_NSURI.get());
          StaxUtil.writeNameSpace(writer, ASSERTION_PREFIX, ASSERTION_NSURI.get());
          StaxUtil.writeDefaultNameSpace(writer, ASSERTION_NSURI.get());
  
          // Attributes
          StaxUtil.writeAttribute(writer, JBossSAMLConstants.ID.get(), assertion.getID());
          StaxUtil.writeAttribute(writer, JBossSAMLConstants.VERSION.get(), assertion.getVersion());
          StaxUtil.writeAttribute(writer, JBossSAMLConstants.ISSUE_INSTANT.get(), assertion.getIssueInstant().toString());
  
          NameIDType issuer = assertion.getIssuer();
          if (issuer != null)
              write(issuer, new QName(ASSERTION_NSURI.get(), JBossSAMLConstants.ISSUER.get(), ASSERTION_PREFIX));
  
          SubjectType subject = assertion.getSubject();
          if (subject != null) {
              write(subject);
          }
  
          ConditionsType conditions = assertion.getConditions();
          if (conditions != null) {
              StaxUtil.writeStartElement(writer, ASSERTION_PREFIX, JBossSAMLConstants.CONDITIONS.get(), ASSERTION_NSURI.get());
  
              if (conditions.getNotBefore() != null) {
                  StaxUtil.writeAttribute(writer, JBossSAMLConstants.NOT_BEFORE.get(), conditions.getNotBefore().toString());
              }
  
              if (conditions.getNotOnOrAfter() != null) {
                  StaxUtil.writeAttribute(writer, JBossSAMLConstants.NOT_ON_OR_AFTER.get(),
                          conditions.getNotOnOrAfter().toString());
              }
  
              List<ConditionAbstractType> typeOfConditions = conditions.getConditions();
              if (typeOfConditions != null) {
                  for (ConditionAbstractType typeCondition : typeOfConditions) {
                      if (typeCondition instanceof AudienceRestrictionType) {
                          AudienceRestrictionType art = (AudienceRestrictionType) typeCondition;
                          StaxUtil.writeStartElement(writer, ASSERTION_PREFIX, JBossSAMLConstants.AUDIENCE_RESTRICTION.get(),
                                  ASSERTION_NSURI.get());
                          List<URI> audiences = art.getAudience();
                          if (audiences != null) {
                              for (URI audience : audiences) {
                                  StaxUtil.writeStartElement(writer, ASSERTION_PREFIX, JBossSAMLConstants.AUDIENCE.get(),
                                          ASSERTION_NSURI.get());
                                  StaxUtil.writeCharacters(writer, audience.toString());
                                  StaxUtil.writeEndElement(writer);
                              }
                          }
  
                          StaxUtil.writeEndElement(writer);
                      }
                      if (typeCondition instanceof OneTimeUseType) {
                          StaxUtil.writeStartElement(writer, ASSERTION_PREFIX, JBossSAMLConstants.ONE_TIME_USE.get(),
                                  ASSERTION_NSURI.get());
                          StaxUtil.writeEndElement(writer);
                      }
                  }
              }
  
              StaxUtil.writeEndElement(writer);
          }
  
          AdviceType advice = assertion.getAdvice();
          if (advice != null)
              throw logger.notImplementedYet("Advice");
  
          Set<StatementAbstractType> statements = assertion.getStatements();
          if (statements != null) {
              for (StatementAbstractType statement : statements) {
                  if (statement instanceof AuthnStatementType) {
                      write((AuthnStatementType) statement, false);
                  } else if (statement instanceof AttributeStatementType) {
                      write((AttributeStatementType) statement);
                  } else
                      throw logger.writerUnknownTypeError(statement.getClass().getName());
              }
          }
  
          StaxUtil.writeEndElement(writer);
          StaxUtil.flush(writer);
      }
focal_method.class_method_signature: SAMLAssertionWriter.write(AssertionType assertion)
focal_method.full_signature: public void write(AssertionType assertion)
focal_method.identifier: write
focal_method.invocations: writeStartElement get get writeNameSpace get writeDefaultNameSpace get writeAttribute get getID writeAttribute get getVersion writeAttribute get toString getIssueInstant getIssuer write get get getSubject write getConditions writeStartElement get get getNotBefore writeAttribute get toString getNotBefore getNotOnOrAfter writeAttribute get toString getNotOnOrAfter getConditions writeStartElement get get getAudience writeStartElement get get writeCharacters toString writeEndElement writeEndElement writeStartElement get get writeEndElement writeEndElement getAdvice notImplementedYet getStatements write write writerUnknownTypeError getName getClass writeEndElement flush
focal_method.modifiers: public
focal_method.parameters: (AssertionType assertion)
focal_method.return: void
focal_method.signature: void write(AssertionType assertion)