org.opensaml.saml2.core.Subject.setNameID()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(109)

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

Subject.setNameID介绍

[英]Sets the name identifier of the principal for this request.
[中]设置此请求的主体的名称标识符。

代码示例

代码示例来源:origin: cloudfoundry/uaa

public AuthnRequest buildIdpInitiatedAuthnRequest(String nameIDFormat,
                         String spEntityID,
                         String assertionUrl) {
  @SuppressWarnings("unchecked")
  SAMLObjectBuilder<AuthnRequest> builder = (SAMLObjectBuilder<AuthnRequest>) builderFactory
    .getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME);
  AuthnRequest request = builder.buildObject();
  request.setVersion(SAMLVersion.VERSION_20);
  request.setID(generateID());
  request.setIssuer(getIssuer(spEntityID));
  request.setVersion(SAMLVersion.VERSION_20);
  request.setIssueInstant(new DateTime());
  request.setID(null);
  request.setAssertionConsumerServiceURL(assertionUrl);
  if (null != nameIDFormat) {
    NameID nameID = ((SAMLObjectBuilder<NameID>) builderFactory.getBuilder(NameID.DEFAULT_ELEMENT_NAME)).buildObject();
    nameID.setFormat(nameIDFormat);
    Subject subject = ((SAMLObjectBuilder<Subject>) builderFactory.getBuilder(Subject.DEFAULT_ELEMENT_NAME)).buildObject();
    subject.setNameID(nameID);
    request.setSubject(subject);
  }
  return request;
}

代码示例来源:origin: cloudfoundry/uaa

public AuthnRequest mockAuthnRequest(String nameIDFormat) {
  @SuppressWarnings("unchecked")
  SAMLObjectBuilder<AuthnRequest> builder = (SAMLObjectBuilder<AuthnRequest>) builderFactory
   .getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME);
  AuthnRequest request = builder.buildObject();
  request.setVersion(SAMLVersion.VERSION_20);
  request.setID(generateID());
  request.setIssuer(getIssuer(SP_ENTITY_ID));
  request.setVersion(SAMLVersion.VERSION_20);
  request.setIssueInstant(new DateTime());
  if (null != nameIDFormat) {
    NameID nameID = ((SAMLObjectBuilder<NameID>) builderFactory.getBuilder(NameID.DEFAULT_ELEMENT_NAME))
     .buildObject();
    nameID.setFormat(nameIDFormat);
    Subject subject = ((SAMLObjectBuilder<Subject>) builderFactory.getBuilder(Subject.DEFAULT_ELEMENT_NAME))
     .buildObject();
    subject.setNameID(nameID);
    request.setSubject(subject);
  }
  return request;
}

代码示例来源:origin: cloudfoundry/uaa

subject.setNameID(nameID);

代码示例来源:origin: org.apache.rampart/rampart-trust

/**
 * This method will set the subject principal details to the given subject.
 * @param subject The subject.
 * @param subjectNameId Subject name id, to identify the principal
 * @param format Format of the subjectNameId, i.e. email, x509subject etc ...
 * @throws TrustException If an error occurred while building NameID.
 */
protected static void setSubjectNamedIdentifierData(Subject subject, String subjectNameId, String format)
    throws TrustException {
  //Create NameID and attach it to the subject
  NameID nameID = SAML2Utils.createNamedIdentifier(subjectNameId, format);
  subject.setNameID(nameID);
}

代码示例来源:origin: se.skltp.adapterservices.se.apotekensservice/TicketMachine

@Override
  public Subject build() {
    Subject subject = new SubjectBuilder().buildObject();
    subject.setNameID(nameId);		
    if(subjectConfermations.size() >0){
      for (SubjectConfirmation subjectConfirmation : subjectConfermations) {
        subject.getSubjectConfirmations().add(subjectConfirmation);
      }
    }
    return subject;
  }
}

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

/** {@inheritDoc} */
  protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
    Subject subject = (Subject) parentObject;

    if (childObject instanceof BaseID) {
      subject.setBaseID((BaseID) childObject);
    } else if (childObject instanceof NameID) {
      subject.setNameID((NameID) childObject);
    } else if (childObject instanceof EncryptedID) {
      subject.setEncryptedID((EncryptedID) childObject);
    } else if (childObject instanceof SubjectConfirmation) {
      subject.getSubjectConfirmations().add((SubjectConfirmation) childObject);
    } else {
      super.processChildElement(parentObject, childObject);
    }
  }
}

代码示例来源:origin: OpenConext/Mujina

private static Subject buildSubject(String subjectNameId, String subjectNameIdType, String recipient, String inResponseTo) {
 NameID nameID = buildSAMLObject(NameID.class, NameID.DEFAULT_ELEMENT_NAME);
 nameID.setValue(subjectNameId);
 nameID.setFormat(subjectNameIdType);
 Subject subject = buildSAMLObject(Subject.class, Subject.DEFAULT_ELEMENT_NAME);
 subject.setNameID(nameID);
 SubjectConfirmation subjectConfirmation = buildSAMLObject(SubjectConfirmation.class, SubjectConfirmation.DEFAULT_ELEMENT_NAME);
 subjectConfirmation.setMethod(SubjectConfirmation.METHOD_BEARER);
 SubjectConfirmationData subjectConfirmationData = buildSAMLObject(SubjectConfirmationData.class, SubjectConfirmationData.DEFAULT_ELEMENT_NAME);
 subjectConfirmationData.setRecipient(recipient);
 subjectConfirmationData.setInResponseTo(inResponseTo);
 subjectConfirmationData.setNotOnOrAfter(new DateTime().plusMinutes(8 * 60));
 subjectConfirmationData.setAddress(recipient);
 subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);
 subject.getSubjectConfirmations().add(subjectConfirmation);
 return subject;
}

代码示例来源:origin: org.wso2.carbon.identity.carbon.auth.saml2/org.wso2.carbon.identity.authenticator.saml2.sso.common

nameId.setValue(subjectName);
nameId.setFormat(NameIdentifier.EMAIL);
subject.setNameID(nameId);
authnRequest.setSubject(subject);

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.authenticator.saml2.sso.common

nameId.setValue(subjectName);
nameId.setFormat(NameIdentifier.EMAIL);
subject.setNameID(nameId);
authnRequest.setSubject(subject);

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

subject.setNameID(nameID);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.wss4j

subject.setNameID(nameID);

代码示例来源:origin: be.fedict.eid-idp/eid-idp-common-saml2

NameID nameId = buildXMLObject(NameID.class,
    NameID.DEFAULT_ELEMENT_NAME);
subject.setNameID(nameId);
nameId.setValue(userId);

代码示例来源:origin: usnistgov/iheos-toolkit2

subject.setNameID(nameID);

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.saml2/org.wso2.carbon.identity.authenticator.inbound.saml2sso

nameId.setFormat(config.getNameIdFormat());
subjectElem.setNameID(nameId);

代码示例来源:origin: org.wso2.carbon.identity.tool.validator.sso.saml2/org.wso2.carbon.identity.tools.saml.validator

subject.setNameID(nameId);

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.tools.saml.validator

subject.setNameID(nameId);

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.sso.saml

subject.setNameID(nameId);

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.saml.cloud/org.wso2.carbon.identity.sso.saml.cloud

subject.setNameID(nameId);

相关文章