/** {@inheritDoc} */ protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) { final DelegationPolicy delegationPolicy = (DelegationPolicy) XMLObjectSupport.buildXMLObject( DelegationPolicy.DEFAULT_ELEMENT_NAME); delegationPolicy.setMaximumTokenDelegationChainLength(maxChainLength); if (assertion.getAdvice() == null) { assertion.setAdvice((Advice) XMLObjectSupport.buildXMLObject(Advice.DEFAULT_ELEMENT_NAME)); } assertion.getAdvice().getChildren().add(delegationPolicy); }
/** * Creates and adds a {@link Advice} to a given {@link Assertion}. If the {@link Assertion} already contains an * {@link Advice} this method just returns. * * @param action current action * @param assertion assertion to which the advice will be added * * @return the {@link Advice} that already existed on, or the one that was added to, the {@link Assertion} */ @Nonnull public static Advice addAdviceToAssertion(@Nonnull final AbstractProfileAction action, @Nonnull final Assertion assertion) { Advice advice = assertion.getAdvice(); if (advice == null) { final SAMLObjectBuilder<Advice> adviceBuilder = (SAMLObjectBuilder<Advice>) XMLObjectProviderRegistrySupport.getBuilderFactory().<Advice>getBuilderOrThrow( Advice.DEFAULT_ELEMENT_NAME); advice = adviceBuilder.buildObject(); assertion.setAdvice(advice); getLogger().debug("Profile Action {}: Assertion {} did not already contain Advice, one was added", action.getClass().getSimpleName(), assertion.getID()); } else { getLogger().debug("Profile Action {}: Assertion {} already contained Advice, nothing was done", action.getClass().getSimpleName(), assertion.getID()); } return advice; }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException { Assertion assertion = (Assertion) parentObject; if (childObject instanceof Issuer) { assertion.setIssuer((Issuer) childObject); } else if (childObject instanceof Signature) { assertion.setSignature((Signature) childObject); } else if (childObject instanceof Subject) { assertion.setSubject((Subject) childObject); } else if (childObject instanceof Conditions) { assertion.setConditions((Conditions) childObject); } else if (childObject instanceof Advice) { assertion.setAdvice((Advice) childObject); } else if (childObject instanceof Statement) { assertion.getStatements().add((Statement) childObject); } else { super.processChildElement(parentObject, childObject); } }
org.opensaml.saml.saml2.core.Advice advice = SAML2ComponentBuilder.createAdvice(samlCallback.getAdvice()); saml2.setAdvice(advice);