/** * Constructs and adds a {@link Assertion} to the given {@link Response}. The {@link Assertion} is constructed * using the parameters supplied, and its issue instant is set to the issue instant of the given {@link Response}. * * @param action the current action * @param response the response to which the assertion will be added * @param idGenerator source of assertion ID * @param issuer value for assertion * * @return the assertion that was added to the response */ @Nonnull public static Assertion addAssertionToResponse(@Nonnull final AbstractProfileAction action, @Nonnull final Response response, @Nonnull final IdentifierGenerationStrategy idGenerator, @Nonnull @NotEmpty final String issuer) { final Assertion assertion = buildAssertion(action, idGenerator, issuer); assertion.setIssueInstant(response.getIssueInstant()); getLogger().debug("Profile Action {}: Added Assertion {} to Response {}", new Object[] {action.getClass().getSimpleName(), assertion.getID(), response.getID(),}); response.getAssertions().add(assertion); return assertion; }
} else if (Assertion.ISSUEINSTANT_ATTRIB_NAME.equals(attribute.getLocalName()) && !Strings.isNullOrEmpty(attribute.getValue())) { assertion.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC())); } else if (Assertion.MAJORVERSION_ATTRIB_NAME.equals(attribute.getLocalName())) { int major;
/** * Constructs an {@link Assertion} using the parameters supplied, with its issue instant set to the * current time. * * @param action the current action * @param idGenerator source of assertion ID * @param issuer value for assertion * * @return the assertion */ @Nonnull public static Assertion buildAssertion(@Nonnull final AbstractProfileAction action, @Nonnull final IdentifierGenerationStrategy idGenerator, @Nonnull @NotEmpty final String issuer) { final SAMLObjectBuilder<Assertion> assertionBuilder = (SAMLObjectBuilder<Assertion>) XMLObjectProviderRegistrySupport.getBuilderFactory().<Assertion>getBuilderOrThrow( Assertion.DEFAULT_ELEMENT_NAME); final Assertion assertion = assertionBuilder.buildObject(); assertion.setID(idGenerator.generateIdentifier()); assertion.setIssueInstant(new DateTime()); assertion.setIssuer(issuer); assertion.setVersion(SAMLVersion.VERSION_11); getLogger().debug("Profile Action {}: Created Assertion {}", action.getClass().getSimpleName(), assertion.getID()); return assertion; }
/** * Create a new SAML1 response object. * * @param authnStatement the authn statement * @param issuer the issuer * @param issuedAt the issued at * @param id the id * @return the assertion */ public Assertion newAssertion(final AuthenticationStatement authnStatement, final String issuer, final DateTime issuedAt, final String id) { final Assertion assertion = newSamlObject(Assertion.class); assertion.setID(id); assertion.setIssueInstant(issuedAt); assertion.setIssuer(issuer); assertion.getAuthenticationStatements().add(authnStatement); return assertion; }
/** * Create a new SAML 1.1 assertion * * @param issuer of type String * @return A SAML 1.1 assertion */ @SuppressWarnings("unchecked") public static Assertion createSamlv1Assertion(String issuer) { if (assertionV1Builder == null) { assertionV1Builder = (SAMLObjectBuilder<Assertion>) builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME); if (assertionV1Builder == null) { throw new IllegalStateException( "OpenSaml engine not initialized. Please make sure to initialize the OpenSaml " + "engine prior using it" ); } } Assertion assertion = assertionV1Builder.buildObject( Assertion.DEFAULT_ELEMENT_NAME, Assertion.TYPE_NAME ); assertion.setVersion(SAMLVersion.VERSION_11); assertion.setIssuer(issuer); assertion.setIssueInstant(new DateTime()); // now assertion.setID(IDGenerator.generateID("_")); return assertion; }
private void createNewConditions(SamlAssertionWrapper assertion, TokenRenewerParameters tokenParameters) { ConditionsBean conditions = conditionsProvider.getConditions(convertToProviderParameters(tokenParameters)); if (assertion.getSaml1() != null) { org.opensaml.saml.saml1.core.Assertion saml1Assertion = assertion.getSaml1(); saml1Assertion.setIssueInstant(new DateTime()); org.opensaml.saml.saml1.core.Conditions saml1Conditions = SAML1ComponentBuilder.createSamlv1Conditions(conditions); saml1Assertion.setConditions(saml1Conditions); } else { org.opensaml.saml.saml2.core.Assertion saml2Assertion = assertion.getSaml2(); saml2Assertion.setIssueInstant(new DateTime()); org.opensaml.saml.saml2.core.Conditions saml2Conditions = SAML2ComponentBuilder.createConditions(conditions); saml2Assertion.setConditions(saml2Conditions); } }
private void createNewConditions(SamlAssertionWrapper assertion, TokenRenewerParameters tokenParameters) { ConditionsBean conditions = conditionsProvider.getConditions(convertToProviderParameters(tokenParameters)); if (assertion.getSaml1() != null) { org.opensaml.saml.saml1.core.Assertion saml1Assertion = assertion.getSaml1(); saml1Assertion.setIssueInstant(new DateTime()); org.opensaml.saml.saml1.core.Conditions saml1Conditions = SAML1ComponentBuilder.createSamlv1Conditions(conditions); saml1Assertion.setConditions(saml1Conditions); } else { org.opensaml.saml.saml2.core.Assertion saml2Assertion = assertion.getSaml2(); saml2Assertion.setIssueInstant(new DateTime()); org.opensaml.saml.saml2.core.Conditions saml2Conditions = SAML2ComponentBuilder.createConditions(conditions); saml2Assertion.setConditions(saml2Conditions); } }
assertion.setIssueInstant(now); assertion.setVersion(SAMLVersion.VERSION_11); assertion.setIssuer(entityID);