org.opensaml.saml.saml1.core.Assertion.getConditions()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中org.opensaml.saml.saml1.core.Assertion.getConditions()方法的一些代码示例,展示了Assertion.getConditions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assertion.getConditions()方法的具体详情如下:
包路径:org.opensaml.saml.saml1.core.Assertion
类名称:Assertion
方法名:getConditions

Assertion.getConditions介绍

[英]Return the (singleton) Object, representing the Conditions sub element.
[中]返回(单例)对象,表示Conditions子元素。

代码示例

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-common

public Instant getNotOnOrAfter() {
  DateTime validTill = null;
  if (getSamlVersion().equals(SAMLVersion.VERSION_20)) {
    validTill = getSaml2().getConditions().getNotOnOrAfter();
  } else {
    validTill = getSaml1().getConditions().getNotOnOrAfter();
  }
  // Now convert to a Java Instant Object
  if (validTill != null) {
    return validTill.toDate().toInstant();
  }
  return null;
}

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-common

public Instant getNotBefore() {
  DateTime validFrom = null;
  if (getSamlVersion().equals(SAMLVersion.VERSION_20)) {
    validFrom = getSaml2().getConditions().getNotBefore();
  } else {
    validFrom = getSaml1().getConditions().getNotBefore();
  }
  // Now convert to a Java Instant Object
  if (validFrom != null) {
    return validFrom.toDate().toInstant();
  }
  return null;
}

代码示例来源:origin: org.opensaml/opensaml-saml-api

/**
 * Creates and adds a {@link Conditions} to a given {@link Assertion}. If the {@link Assertion} already contains an
 * {@link Conditions} this method just returns.
 * 
 * @param action current action
 * @param assertion assertion to which the condition will be added
 * 
 * @return the {@link Conditions} that already existed on, or the one that was added to, the {@link Assertion}
 */
@Nonnull public static Conditions addConditionsToAssertion(@Nonnull final AbstractProfileAction action,
    @Nonnull final Assertion assertion) {
  Conditions conditions = assertion.getConditions();
  if (conditions == null) {
    final SAMLObjectBuilder<Conditions> conditionsBuilder = (SAMLObjectBuilder<Conditions>)
        XMLObjectProviderRegistrySupport.getBuilderFactory().<Conditions>getBuilderOrThrow(
            Conditions.DEFAULT_ELEMENT_NAME);
    conditions = conditionsBuilder.buildObject();
    assertion.setConditions(conditions);
    getLogger().debug("Profile Action {}: Assertion {} did not already contain Conditions, added",
        action.getClass().getSimpleName(), assertion.getID());
  } else {
    getLogger().debug("Profile Action {}: Assertion {} already contains Conditions, nothing was done",
        action.getClass().getSimpleName(), assertion.getID());
  }
  return conditions;
}

代码示例来源:origin: apache/cxf

private DateTime getExpiryDate(SamlAssertionWrapper assertion) {
  if (assertion.getSamlVersion().equals(SAMLVersion.VERSION_20)) {
    return assertion.getSaml2().getConditions().getNotOnOrAfter();
  }
  return assertion.getSaml1().getConditions().getNotOnOrAfter();
}

代码示例来源:origin: org.apache.cxf.services.sts/cxf-services-sts-core

private DateTime getExpiryDate(SamlAssertionWrapper assertion) {
  if (assertion.getSamlVersion().equals(SAMLVersion.VERSION_20)) {
    return assertion.getSaml2().getConditions().getNotOnOrAfter();
  }
  return assertion.getSaml1().getConditions().getNotOnOrAfter();
}

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-common

/**
 * Check the Conditions of the Assertion.
 */
public void checkConditions(int futureTTL) throws WSSecurityException {
  DateTime validFrom = null;
  DateTime validTill = null;
  if (getSamlVersion().equals(SAMLVersion.VERSION_20)
    && getSaml2().getConditions() != null) {
    validFrom = getSaml2().getConditions().getNotBefore();
    validTill = getSaml2().getConditions().getNotOnOrAfter();
  } else if (getSamlVersion().equals(SAMLVersion.VERSION_11)
    && getSaml1().getConditions() != null) {
    validFrom = getSaml1().getConditions().getNotBefore();
    validTill = getSaml1().getConditions().getNotOnOrAfter();
  }
  if (validFrom != null) {
    DateTime currentTime = new DateTime();
    currentTime = currentTime.plusSeconds(futureTTL);
    if (validFrom.isAfter(currentTime)) {
      LOG.debug("SAML Token condition (Not Before) not met");
      throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
    }
  }
  if (validTill != null && validTill.isBeforeNow()) {
    LOG.debug("SAML Token condition (Not On Or After) not met");
    throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
  }
}

代码示例来源:origin: org.apereo.cas/cas-server-support-wsfederation

credential.setIssuer(assertion.getIssuer());
credential.setIssuedOn(ZonedDateTime.parse(assertion.getIssueInstant().toDateTimeISO().toString()));
val conditions = assertion.getConditions();
if (conditions != null) {
  credential.setNotBefore(ZonedDateTime.parse(conditions.getNotBefore().toDateTimeISO().toString()));

代码示例来源:origin: apache/cxf

protected List<String> getAudienceRestrictions(SamlAssertionWrapper assertion) {
  List<String> addresses = new ArrayList<>();
  if (assertion.getSaml1() != null) {
    for (AudienceRestrictionCondition restriction
      : assertion.getSaml1().getConditions().getAudienceRestrictionConditions()) {
      for (org.opensaml.saml.saml1.core.Audience audience : restriction.getAudiences()) {
        addresses.add(audience.getUri());
      }
    }
  } else if (assertion.getSaml2() != null) {
    for (org.opensaml.saml.saml2.core.AudienceRestriction restriction
      : assertion.getSaml2().getConditions().getAudienceRestrictions()) {
      for (org.opensaml.saml.saml2.core.Audience audience : restriction.getAudiences()) {
        addresses.add(audience.getAudienceURI());
      }
    }
  }
  return addresses;
}

代码示例来源:origin: org.apache.cxf.services.sts/cxf-services-sts-core

protected List<String> getAudienceRestrictions(SamlAssertionWrapper assertion) {
  List<String> addresses = new ArrayList<>();
  if (assertion.getSaml1() != null) {
    for (AudienceRestrictionCondition restriction
      : assertion.getSaml1().getConditions().getAudienceRestrictionConditions()) {
      for (org.opensaml.saml.saml1.core.Audience audience : restriction.getAudiences()) {
        addresses.add(audience.getUri());
      }
    }
  } else if (assertion.getSaml2() != null) {
    for (org.opensaml.saml.saml2.core.AudienceRestriction restriction
      : assertion.getSaml2().getConditions().getAudienceRestrictions()) {
      for (org.opensaml.saml.saml2.core.Audience audience : restriction.getAudiences()) {
        addresses.add(audience.getAudienceURI());
      }
    }
  }
  return addresses;
}

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-common

issueInstant = getSaml2().getIssueInstant();
} else if (getSamlVersion().equals(SAMLVersion.VERSION_11)
  && getSaml1().getConditions() != null) {
  validTill = getSaml1().getConditions().getNotOnOrAfter();
  issueInstant = getSaml1().getIssueInstant();

代码示例来源:origin: org.jasig.cas/cas-server-support-wsfederation

credential.setIssuedOn(assertion.getIssueInstant());
final Conditions conditions = assertion.getConditions();
if (conditions != null) {
  credential.setNotBefore(conditions.getNotBefore());

代码示例来源:origin: apache/cxf

protected boolean validateConditions(
  SamlAssertionWrapper assertion, ReceivedToken validateTarget
) {
  DateTime validFrom = null;
  DateTime validTill = null;
  DateTime issueInstant = null;
  if (assertion.getSamlVersion().equals(SAMLVersion.VERSION_20)) {
    validFrom = assertion.getSaml2().getConditions().getNotBefore();
    validTill = assertion.getSaml2().getConditions().getNotOnOrAfter();
    issueInstant = assertion.getSaml2().getIssueInstant();
  } else {
    validFrom = assertion.getSaml1().getConditions().getNotBefore();
    validTill = assertion.getSaml1().getConditions().getNotOnOrAfter();
    issueInstant = assertion.getSaml1().getIssueInstant();
  }
  if (validFrom != null && validFrom.isAfterNow()) {
    LOG.log(Level.WARNING, "SAML Token condition not met");
    return false;
  } else if (validTill != null && validTill.isBeforeNow()) {
    LOG.log(Level.WARNING, "SAML Token condition not met");
    validateTarget.setState(STATE.EXPIRED);
    return false;
  }
  if (issueInstant != null && issueInstant.isAfterNow()) {
    LOG.log(Level.WARNING, "SAML Token IssueInstant not met");
    return false;
  }
  return true;
}

代码示例来源:origin: org.apache.cxf.services.sts/cxf-services-sts-core

protected boolean validateConditions(
  SamlAssertionWrapper assertion, ReceivedToken validateTarget
) {
  DateTime validFrom = null;
  DateTime validTill = null;
  DateTime issueInstant = null;
  if (assertion.getSamlVersion().equals(SAMLVersion.VERSION_20)) {
    validFrom = assertion.getSaml2().getConditions().getNotBefore();
    validTill = assertion.getSaml2().getConditions().getNotOnOrAfter();
    issueInstant = assertion.getSaml2().getIssueInstant();
  } else {
    validFrom = assertion.getSaml1().getConditions().getNotBefore();
    validTill = assertion.getSaml1().getConditions().getNotOnOrAfter();
    issueInstant = assertion.getSaml1().getIssueInstant();
  }
  if (validFrom != null && validFrom.isAfterNow()) {
    LOG.log(Level.WARNING, "SAML Token condition not met");
    return false;
  } else if (validTill != null && validTill.isBeforeNow()) {
    LOG.log(Level.WARNING, "SAML Token condition not met");
    validateTarget.setState(STATE.EXPIRED);
    return false;
  }
  if (issueInstant != null && issueInstant.isAfterNow()) {
    LOG.log(Level.WARNING, "SAML Token IssueInstant not met");
    return false;
  }
  return true;
}

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-common

} else if (getSamlVersion().equals(SAMLVersion.VERSION_11) && getSaml1().getConditions() != null) {
  org.opensaml.saml.saml1.core.Conditions conditions = getSaml1().getConditions();
  if (conditions != null && conditions.getAudienceRestrictionConditions() != null
    && !conditions.getAudienceRestrictionConditions().isEmpty()) {

代码示例来源:origin: org.apache.cxf.services.sts/cxf-services-sts-core

if (assertion.getSaml1() != null) {
  List<AudienceRestrictionCondition> restrConditions =
    assertion.getSaml1().getConditions().getAudienceRestrictionConditions();
  if (!matchSaml1AudienceRestriction(appliesToAddress, restrConditions)) {
    LOG.log(Level.WARNING, "The AppliesTo address does not match the Audience Restriction");

代码示例来源:origin: apache/cxf

if (assertion.getSaml1() != null) {
  List<AudienceRestrictionCondition> restrConditions =
    assertion.getSaml1().getConditions().getAudienceRestrictionConditions();
  if (!matchSaml1AudienceRestriction(appliesToAddress, restrConditions)) {
    LOG.log(Level.WARNING, "The AppliesTo address does not match the Audience Restriction");

代码示例来源:origin: apache/cxf

validTill = renewedAssertion.getSaml2().getConditions().getNotOnOrAfter();
} else {
  validFrom = renewedAssertion.getSaml1().getConditions().getNotBefore();
  validTill = renewedAssertion.getSaml1().getConditions().getNotOnOrAfter();

代码示例来源:origin: org.apache.cxf.services.sts/cxf-services-sts-core

validTill = renewedAssertion.getSaml2().getConditions().getNotOnOrAfter();
} else {
  validFrom = renewedAssertion.getSaml1().getConditions().getNotBefore();
  validTill = renewedAssertion.getSaml1().getConditions().getNotOnOrAfter();

代码示例来源:origin: apache/cxf

validTill = assertion.getSaml2().getConditions().getNotOnOrAfter();
} else {
  validFrom = assertion.getSaml1().getConditions().getNotBefore();
  validTill = assertion.getSaml1().getConditions().getNotOnOrAfter();

代码示例来源:origin: org.apache.cxf.services.sts/cxf-services-sts-core

validTill = assertion.getSaml2().getConditions().getNotOnOrAfter();
} else {
  validFrom = assertion.getSaml1().getConditions().getNotBefore();
  validTill = assertion.getSaml1().getConditions().getNotOnOrAfter();

相关文章