Element oldAssertionElement = (Element) token.getFirstChild();
if (!this.isAssertion(oldAssertionElement))
throw logger.assertionInvalidError();
// get the JAXB representation of the old assertion.
AssertionType oldAssertion = null;
try {
oldAssertion = SAMLUtil.fromElement(oldAssertionElement);
} catch (Exception je) {
throw logger.samlAssertionUnmarshallError(je);
}
// canceled assertions cannot be renewed.
if (this.revocationRegistry.isRevoked(SAMLUtil.SAML2_TOKEN_TYPE, oldAssertion.getID()))
throw logger.samlAssertionRevokedCouldNotRenew(oldAssertion.getID());
// adjust the lifetime for the renewed assertion.
ConditionsType conditions = oldAssertion.getConditions();
conditions.setNotBefore(context.getRequestSecurityToken().getLifetime().getCreated());
conditions.setNotOnOrAfter(context.getRequestSecurityToken().getLifetime().getExpires());
// create a new unique ID for the renewed assertion.
String assertionID = IDGenerator.create("ID_");
List<StatementAbstractType> statements = new ArrayList<StatementAbstractType>();
statements.addAll(oldAssertion.getStatements());
// create the new assertion.
AssertionType newAssertion = SAMLAssertionFactory.createAssertion(assertionID, oldAssertion.getIssuer(), context
.getRequestSecurityToken().getLifetime().getCreated(), conditions, oldAssertion.getSubject(), statements);
// create a security token with the new assertion.
Element assertionElement = null;
try {