当前位置: 首页>>代码示例>>Java>>正文


Java NameID.setValue方法代码示例

本文整理汇总了Java中org.opensaml.saml2.core.NameID.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java NameID.setValue方法的具体用法?Java NameID.setValue怎么用?Java NameID.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opensaml.saml2.core.NameID的用法示例。


在下文中一共展示了NameID.setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildLogoutRequest

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
protected LogoutRequest buildLogoutRequest(String user, String sessionIdx) throws SSOAgentException {

        LogoutRequest logoutReq = new LogoutRequestBuilder().buildObject();

        logoutReq.setID(SSOAgentUtils.createID());
        logoutReq.setDestination(ssoAgentConfig.getSAML2().getIdPURL());

        DateTime issueInstant = new DateTime();
        logoutReq.setIssueInstant(issueInstant);
        logoutReq.setNotOnOrAfter(new DateTime(issueInstant.getMillis() + 5 * 60 * 1000));

        IssuerBuilder issuerBuilder = new IssuerBuilder();
        Issuer issuer = issuerBuilder.buildObject();
        issuer.setValue(ssoAgentConfig.getSAML2().getSPEntityId());
        logoutReq.setIssuer(issuer);

        NameID nameId = new NameIDBuilder().buildObject();
        nameId.setFormat("urn:oasis:names:tc:SAML:2.0:nameid-format:entity");
        nameId.setValue(user);
        logoutReq.setNameID(nameId);

        SessionIndex sessionIndex = new SessionIndexBuilder().buildObject();
        sessionIndex.setSessionIndex(sessionIdx);
        logoutReq.getSessionIndexes().add(sessionIndex);

        logoutReq.setReason("Single Logout");

        return logoutReq;
    }
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:30,代码来源:SAML2SSOManager.java

示例2: createLogoutRequest

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public LogoutRequest createLogoutRequest(Response resp) {
  LogoutRequest lr = ((SAMLObjectBuilder<LogoutRequest>) 
        _bf.getBuilder(LogoutRequest.DEFAULT_ELEMENT_NAME)).buildObject();
  String uid = UUID.randomUUID().toString();
  
  lr.setID(uid);
  lr.setIssueInstant(new DateTime());
  lr.setVersion(SAMLVersion.VERSION_20);
  lr.setIssuer(getIssuer());
  
  // Get NameID and SessionIndex from first assertion from
  // Authentication Response object
  Assertion asr = resp.getAssertions().get(0);
  NameID nid = ((SAMLObjectBuilder<NameID>) 
      _bf.getBuilder(NameID.DEFAULT_ELEMENT_NAME)).buildObject();
  nid.setValue(asr.getSubject().getNameID().getValue());
  lr.setNameID(nid);
  
  // Set session index(es)
  List<AuthnStatement> ausl = asr.getAuthnStatements();
  if (ausl != null) {
    for (AuthnStatement aus :ausl) {
      SessionIndex sindex = ((SAMLObjectBuilder<SessionIndex>) 
          _bf.getBuilder(SessionIndex.DEFAULT_ELEMENT_NAME)).buildObject();
      sindex.setSessionIndex(aus.getSessionIndex());
      lr.getSessionIndexes().add(sindex);
    }
  }
  
  return lr;
}
 
开发者ID:osbitools,项目名称:OsBiToolsWs,代码行数:33,代码来源:SamlSecurityProvider.java

示例3: getSubjectNameIDValue

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
@Test
public void getSubjectNameIDValue() {
	String expectedValue = "testvalue";

	NameID nameid = new NameIDStubImpl();
	nameid.setValue(expectedValue);

	Subject subject = new SubjectStubImpl();
	subject.setNameID(nameid);

	Assertion localAssertion = new AssertionStubImpl();
	localAssertion.setSubject(subject);

	assertEquals(expectedValue, new OIOAssertion(localAssertion).getSubjectNameIDValue());

	assertEquals("joetest", assertion.getSubjectNameIDValue());
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:18,代码来源:OIOAssertionTest.java

示例4: makeEmailFormatName

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
public static NameID makeEmailFormatName(final String subjectNameId, final String subjectNameIdFormat, final String subjectNameIdQualifier) {
    NameID nameID = (new NameIDBuilder().buildObject());

    if (subjectNameIdFormat.equals("email")) {
        nameID.setFormat(NameIDType.EMAIL);
    } else if (subjectNameIdFormat.equals("unspecified")) {
        nameID.setFormat(NameIDType.UNSPECIFIED);
    } else {
        throw new IllegalArgumentException("subjectNameIdFormat must be 'email' or 'unspecified'.");
    }
    
    if (subjectNameIdQualifier != null) {
        nameID.setNameQualifier(subjectNameIdQualifier);
    }
    
    nameID.setValue(subjectNameId);
    
    return nameID;
}
 
开发者ID:SAP,项目名称:SAPJamSampleCode,代码行数:20,代码来源:OAuth2SAMLUtil.java

示例5: buildLogoutRequest

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
/**
 * Build the logout request
 *
 * @param subject name of the user
 * @param reason  reason for generating logout request.
 * @return LogoutRequest object
 * @throws Exception
 */
public LogoutRequest buildLogoutRequest(String subject, String reason, String sessionIndexStr) throws Exception {
    log.info("Building logout request");
    Util.doBootstrap();
    LogoutRequest logoutReq = new org.opensaml.saml2.core.impl.LogoutRequestBuilder().buildObject();
    logoutReq.setID(Util.createID());
    logoutReq.setDestination(Util.getIdentityProviderSSOServiceURL());

    DateTime issueInstant = new DateTime();
    logoutReq.setIssueInstant(issueInstant);
    logoutReq.setNotOnOrAfter(new DateTime(issueInstant.getMillis() + 5 * 60 * 1000));

    IssuerBuilder issuerBuilder = new IssuerBuilder();
    Issuer issuer = issuerBuilder.buildObject();
    issuer.setValue(Util.getServiceProviderId());
    logoutReq.setIssuer(issuer);

    NameID nameId = new NameIDBuilder().buildObject();
    nameId.setFormat(SAML2SSOAuthenticatorConstants.SAML2_NAME_ID_POLICY_TRANSIENT);
    nameId.setValue(subject);
    logoutReq.setNameID(nameId);

    SessionIndex sessionIndex = new SessionIndexBuilder().buildObject();
    sessionIndex.setSessionIndex(sessionIndexStr);
    logoutReq.getSessionIndexes().add(sessionIndex);

    logoutReq.setReason(reason);

    Util.setSignature(logoutReq, XMLSignature.ALGO_ID_SIGNATURE_RSA, new SignKeyDataHolder());

    return logoutReq;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:40,代码来源:LogoutRequestBuilder.java

示例6: buildAuthenticationRequest

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
/**
 * Generate an authentication request with passive support.
 *
 * @return AuthnRequest Object
 * @throws Exception
 */
public AuthnRequest buildAuthenticationRequest(String subjectName, String nameIdPolicyFormat, boolean isPassive)
        throws Exception {

    if (log.isDebugEnabled()) {
        log.debug("Building Authentication Request");
    }
    Util.doBootstrap();
    AuthnRequest authnRequest = (AuthnRequest) Util
            .buildXMLObject(AuthnRequest.DEFAULT_ELEMENT_NAME);
    authnRequest.setID(Util.createID());
    authnRequest.setVersion(SAMLVersion.VERSION_20);
    authnRequest.setIssueInstant(new DateTime());
    authnRequest.setIssuer(buildIssuer());
    authnRequest.setNameIDPolicy(buildNameIDPolicy(nameIdPolicyFormat));
    authnRequest.setIsPassive(isPassive);
    authnRequest.setDestination(Util.getIdentityProviderSSOServiceURL());
    String acs = Util.getAssertionConsumerServiceURL();
    if (acs != null && acs.trim().length() > 0) {
        authnRequest.setAssertionConsumerServiceURL(acs);
    } else {
        authnRequest.setAssertionConsumerServiceURL(CarbonUIUtil.getAdminConsoleURL("").replace("carbon/", "acs"));
    }

    if (subjectName != null) {
        Subject subject = new SubjectBuilder().buildObject();
        NameID nameId = new NameIDBuilder().buildObject();
        nameId.setValue(subjectName);
        nameId.setFormat(NameIdentifier.EMAIL);
        subject.setNameID(nameId);
        authnRequest.setSubject(subject);

    }

    Util.setSignature(authnRequest, XMLSignature.ALGO_ID_SIGNATURE_RSA, new SignKeyDataHolder());

    return authnRequest;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:44,代码来源:AuthenticationRequestBuilder.java

示例7: testNameFailure

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
/**
 * Tests Name failure.
 * 
 * @throws ValidationException
 */
public void testNameFailure() throws ValidationException {
    NameID nameID = (NameID) target;

    nameID.setValue(null);
    assertValidationFail("Name was null, should raise a Validation Exception");

    nameID.setValue("");
    assertValidationFail("Name was empty string, should raise a Validation Exception");
    
    nameID.setValue("    ");
    assertValidationFail("Name was white space, should raise a Validation Exception");
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:18,代码来源:NameIDSchemaTest.java

示例8: testSingleElementMarshall

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementMarshall() {
    QName qname = new QName(SAMLConstants.SAML20_NS, NameID.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    NameID nameID = (NameID) buildXMLObject(qname);

    nameID.setValue(expectedName);
    assertEquals(expectedDOM, nameID);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:9,代码来源:NameIDTest.java

示例9: testSingleElementOptionalAttributesMarshall

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesMarshall() {
    QName qname = new QName(SAMLConstants.SAML20_NS, NameID.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    NameID nameID = (NameID) buildXMLObject(qname);

    nameID.setValue(expectedName);
    nameID.setNameQualifier(expectedNameQualifier);
    nameID.setSPNameQualifier(expectedSPNameQualifier);
    nameID.setFormat(expectedFormat);
    nameID.setSPProvidedID(expectedSPID);
    assertEquals(expectedOptionalAttributesDOM, nameID);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:13,代码来源:NameIDTest.java

示例10: buildLogoutRequest

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
/**
 * Build the logout request
 * @param subject name of the user
 * @param reason reason for generating logout request.
 * @return LogoutRequest object
 */
public LogoutRequest buildLogoutRequest(String subject,String sessionIndexId, String reason,
                                        String issuerId) {
    Util.doBootstrap();
    LogoutRequest logoutReq = new org.opensaml.saml2.core.impl.LogoutRequestBuilder().buildObject();
    logoutReq.setID(Util.createID());

    DateTime issueInstant = new DateTime();
    logoutReq.setIssueInstant(issueInstant);
    logoutReq.setNotOnOrAfter(new DateTime(issueInstant.getMillis() + 5 * 60 * 1000));

    IssuerBuilder issuerBuilder = new IssuerBuilder();
    Issuer issuer = issuerBuilder.buildObject();
    issuer.setValue(issuerId);
    logoutReq.setIssuer(issuer);

    NameID nameId = new NameIDBuilder().buildObject();
    nameId.setFormat(SSOConstants.SAML2_NAME_ID_POLICY);
    nameId.setValue(subject);
    logoutReq.setNameID(nameId);

    SessionIndex sessionIndex = new SessionIndexBuilder().buildObject();
    sessionIndex.setSessionIndex(sessionIndexId);
    logoutReq.getSessionIndexes().add(sessionIndex);

    logoutReq.setReason(reason);

    return logoutReq;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:35,代码来源:LogoutRequestBuilder.java

示例11: createSubject

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
private Subject createSubject(final String subjectId, final Integer samlAssertionDays) {
	DateTime currentDate = new DateTime();
	if (samlAssertionDays != null)
		currentDate = currentDate.plusDays(samlAssertionDays);
	
	// create name element
	NameIDBuilder nameIdBuilder = new NameIDBuilder(); 
	NameID nameId = nameIdBuilder.buildObject();
	nameId.setValue(subjectId);
	nameId.setFormat("urn:oasis:names:tc:SAML:2.0:nameid-format:persistent");

	SubjectConfirmationDataBuilder dataBuilder = new SubjectConfirmationDataBuilder();
	SubjectConfirmationData subjectConfirmationData = dataBuilder.buildObject();
	subjectConfirmationData.setNotOnOrAfter(currentDate);
	
	SubjectConfirmationBuilder subjectConfirmationBuilder = new SubjectConfirmationBuilder();
	SubjectConfirmation subjectConfirmation = subjectConfirmationBuilder.buildObject();
	subjectConfirmation.setMethod("urn:oasis:names:tc:SAML:2.0:cm:bearer");
	subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);
	
	// create subject element
	SubjectBuilder subjectBuilder = new SubjectBuilder();
	Subject subject = subjectBuilder.buildObject();
	subject.setNameID(nameId);
	subject.getSubjectConfirmations().add(subjectConfirmation);
	
	return subject;
}
 
开发者ID:rackerlabs,项目名称:saml-generator,代码行数:29,代码来源:SamlAssertionProducer.java

示例12: buildLogoutRequest

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
public static LogoutRequest buildLogoutRequest(String logoutUrl, String spId, String nameIdString) {
    Issuer issuer = new IssuerBuilder().buildObject();
    issuer.setValue(spId);
    NameID nameID = new NameIDBuilder().buildObject();
    nameID.setValue(nameIdString);
    LogoutRequest logoutRequest = new LogoutRequestBuilder().buildObject();
    logoutRequest.setID(generateSecureRandomId());
    logoutRequest.setDestination(logoutUrl);
    logoutRequest.setVersion(SAMLVersion.VERSION_20);
    logoutRequest.setIssueInstant(new DateTime());
    logoutRequest.setIssuer(issuer);
    logoutRequest.setNameID(nameID);
    return logoutRequest;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:15,代码来源:SAMLUtils.java

示例13: buildMockResponse

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
private Response buildMockResponse() throws Exception {
    Response samlMessage = new ResponseBuilder().buildObject();
    samlMessage.setID("foo");
    samlMessage.setVersion(SAMLVersion.VERSION_20);
    samlMessage.setIssueInstant(new DateTime(0));
    Issuer issuer = new IssuerBuilder().buildObject();
    issuer.setValue("MockedIssuer");
    samlMessage.setIssuer(issuer);
    Status status = new StatusBuilder().buildObject();
    StatusCode statusCode = new StatusCodeBuilder().buildObject();
    statusCode.setValue(StatusCode.SUCCESS_URI);
    status.setStatusCode(statusCode);
    samlMessage.setStatus(status);
    Assertion assertion = new AssertionBuilder().buildObject();
    Subject subject = new SubjectBuilder().buildObject();
    NameID nameID = new NameIDBuilder().buildObject();
    nameID.setValue("SOME-UNIQUE-ID");
    nameID.setFormat(NameIDType.PERSISTENT);
    subject.setNameID(nameID);
    assertion.setSubject(subject);
    AuthnStatement authnStatement = new AuthnStatementBuilder().buildObject();
    authnStatement.setSessionIndex("Some Session String");
    assertion.getAuthnStatements().add(authnStatement);
    AttributeStatement attributeStatement = new AttributeStatementBuilder().buildObject();
    assertion.getAttributeStatements().add(attributeStatement);
    samlMessage.getAssertions().add(assertion);
    return samlMessage;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:29,代码来源:SAML2LoginAPIAuthenticatorCmdTest.java

示例14: buildLogoutRequest

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
/**
 * Build a SAML2 Single Logout Request.
 * 
 * @return the authentication request
 * @throws SamlBuildingException
 */
protected LogoutRequest buildLogoutRequest(final SamlBindingEnum binding, final IAuthentication auth)
		throws SamlBuildingException {
	final DateTime issueInstant = new DateTime();
	final LogoutRequest logoutRequest = this.logoutRequestBuilder.buildObject(LogoutRequest.DEFAULT_ELEMENT_NAME);

	logoutRequest.setIssueInstant(issueInstant);
	logoutRequest.setIssuer(this.buildIssuer());
	logoutRequest.setDestination(this.idpConfig.getIdpSloEndpointUrl(binding));
	logoutRequest.setVersion(SAMLVersion.VERSION_20);
	logoutRequest.setNotOnOrAfter(this.buildNotOnOrAfterTime(issueInstant));

	final String subjectId = auth.getSubjectId();
	if (!StringUtils.hasText(subjectId)) {
		// We don't know the subject so we cannot build a logout request
		throw new SamlBuildingException("No SAML 2.0 Subject can be found to build the Single Logout Request !");
	}

	final NameIDBuilder builder = new NameIDBuilder();
	final NameID newNameId = builder.buildObject(NameID.DEFAULT_ELEMENT_NAME);
	newNameId.setValue(subjectId);
	logoutRequest.setNameID(newNameId);

	final String sessionIndex = auth.getSessionIndex();
	if (StringUtils.hasText(sessionIndex)) {
		final SessionIndex sessionIndexObj = this.sessionIndexBuilder
				.buildObject(SessionIndex.DEFAULT_ELEMENT_NAME);
		sessionIndexObj.setSessionIndex(sessionIndex);
		logoutRequest.getSessionIndexes().add(sessionIndexObj);
	}

	this.getSaml20SpProcessor().signSamlObject(logoutRequest);

	return logoutRequest;
}
 
开发者ID:mxbossard,项目名称:java-saml2-sp,代码行数:41,代码来源:OpenSaml20IdpConnector.java

示例15: buildAssertion

import org.opensaml.saml2.core.NameID; //导入方法依赖的package包/类
private Assertion buildAssertion() throws NoSuchAlgorithmException, IllegalAccessException, KeyStoreException, java.security.cert.CertificateException,
		SignatureException, MarshallingException, CertificateException, IOException, SecurityException, MetadataProviderException {
	SecureRandomIdentifierGenerator idGenerator = new SecureRandomIdentifierGenerator();

	Assertion assertion = buildXMLObjectDefaultName(Assertion.class);

	Issuer issuer = buildXMLObjectDefaultName(Issuer.class);
	issuer.setValue(MockIDPProperties.getIdpEntityId());
	assertion.setIssuer(issuer);
	assertion.setIssueInstant(new DateTime());

	assertion.setID(idGenerator.generateIdentifier());

	Subject subject = buildXMLObjectDefaultName(Subject.class);
	assertion.setSubject(subject);

	NameID nameID = buildXMLObjectDefaultName(NameID.class);
	nameID.setFormat(NameIDType.TRANSIENT);
	nameID.setValue("5VkzP/MZ1PMJ62o45/7DdFms9y7K");
	nameID.setSPNameQualifier("steras-openam");
	nameID.setNameQualifier("FakeIdP");

	subject.setNameID(nameID);

	subject.getSubjectConfirmations().add(buildSubjectConfirmation());

	assertion.setConditions(buildConditions());

	assertion.getAttributeStatements().add(buildAttributeStatement());

	assertion.getAuthnStatements().add(buildAuthnStatement());

	signSAMLObject(assertion, getIDPKeyFromKeystore());
	return assertion;
}
 
开发者ID:rasmusson,项目名称:MockIDP,代码行数:36,代码来源:MockIDPArtifactResolve.java


注:本文中的org.opensaml.saml2.core.NameID.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。