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


Java NameID.setValue方法代码示例

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


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

示例1: givenAValidAttributeQuery

import org.opensaml.saml.saml2.core.NameID; //导入方法依赖的package包/类
private AttributeQuery givenAValidAttributeQuery() {
    AttributeQuery query = openSamlXmlObjectFactory.createAttributeQuery();

    query.setIssueInstant(DateTime.now());
    Subject originalSubject = openSamlXmlObjectFactory.createSubject();
    NameID originalSubjectNameId = openSamlXmlObjectFactory.createNameId("name_id");
    Issuer originalIssuer = openSamlXmlObjectFactory.createIssuer("issuer_id");
    originalSubject.setNameID(originalSubjectNameId);

    SubjectConfirmation subjectConfirmation = openSamlXmlObjectFactory.createSubjectConfirmation();
    originalSubject.getSubjectConfirmations().add(subjectConfirmation);
    query.setSubject(originalSubject);
    query.setIssuer(originalIssuer);

    originalIssuer.setValue("original issuer");
    query.setID("original id");
    originalSubjectNameId.setValue("original subject id");
    originalSubjectNameId.setSPNameQualifier("http://foo.com");

    List<Attribute> attributes = query.getAttributes();
    AttributeFactory_1_1 attributeFactory = new AttributeFactory_1_1(openSamlXmlObjectFactory);
    attributes.add(attributeFactory.createFirstnameAttribute(ImmutableList.of(new SimpleMdsValue<>(FIRST_NAME, null, null, false))));

    return query;
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:26,代码来源:InboundMatchingServiceRequestUnmarshallerTest.java

示例2: buildLogoutRequest

import org.opensaml.saml.saml2.core.NameID; //导入方法依赖的package包/类
/**
 * Returns a SAML 2.0 Logout Request (LogoutRequest) instance.
 *
 * @param user         the identifier that specify the principal as currently recognized by the identity and
 *                     service providers
 * @param sessionIndex the identifier that indexes this session at the message recipient
 * @return a SAML 2.0 Logout Request (LogoutRequest) instance
 */
private LogoutRequest buildLogoutRequest(String user, String sessionIndex) {
    //  creates a Logout Request instance
    LogoutRequest logoutRequest = new LogoutRequestBuilder().buildObject();

    DateTime issueInstant = new DateTime();

    Issuer issuer = new IssuerBuilder().buildObject();
    issuer.setValue(contextConfiguration.getIssuerId());

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

    SessionIndex sessionIndexElement = new SessionIndexBuilder().buildObject();
    sessionIndexElement.setSessionIndex(sessionIndex);

    //  sets the mandatory attributes of a SAML 2.0 Request
    logoutRequest.setID(SSOUtils.createID());
    logoutRequest.setIssueInstant(issueInstant);

    logoutRequest.setDestination(serverConfiguration.getIdpURL());
    //  time at which the request expires, after which the recipient may discard the message
    logoutRequest.setNotOnOrAfter(new DateTime(issueInstant.getMillis() + (5 * 60 * 1000)));
    logoutRequest.setIssuer(issuer);
    logoutRequest.setNameID(nameId);
    logoutRequest.getSessionIndexes().add(sessionIndexElement);
    //  indicates the reason for the logout
    logoutRequest.setReason("Single Logout");

    return logoutRequest;
}
 
开发者ID:wso2-extensions,项目名称:tomcat-extension-samlsso,代码行数:40,代码来源:SAML2SSOManager.java

示例3: not

import org.opensaml.saml.saml2.core.NameID; //导入方法依赖的package包/类
@PreAuthorize("isAuthenticated() and not(hasRole('" + StandardEntitlement.ANONYMOUS + "'))")
public SAML2RequestTO createLogoutRequest(final String accessToken, final String spEntityID) {
    check();

    // 1. fetch the current JWT used for Syncope authentication
    JwsJwtCompactConsumer consumer = new JwsJwtCompactConsumer(accessToken);
    if (!consumer.verifySignatureWith(jwsSignatureVerifier)) {
        throw new IllegalArgumentException("Invalid signature found in Access Token");
    }

    // 2. look for IdP
    String idpEntityID = (String) consumer.getJwtClaims().getClaim(JWT_CLAIM_IDP_ENTITYID);
    if (idpEntityID == null) {
        throw new NotFoundException("No SAML 2.0 IdP information found in the access token");
    }
    SAML2IdPEntity idp = cache.get(idpEntityID);
    if (idp == null) {
        throw new NotFoundException("SAML 2.0 IdP '" + idpEntityID + "'");
    }
    if (idp.getSLOLocation(idp.getBindingType()) == null) {
        throw new IllegalArgumentException("No SingleLogoutService available for " + idp.getId());
    }

    // 3. create LogoutRequest
    LogoutRequest logoutRequest = new LogoutRequestBuilder().buildObject();
    logoutRequest.setID("_" + UUID_GENERATOR.generate().toString());
    logoutRequest.setDestination(idp.getSLOLocation(idp.getBindingType()).getLocation());

    DateTime now = new DateTime();
    logoutRequest.setIssueInstant(now);
    logoutRequest.setNotOnOrAfter(now.plusMinutes(5));

    Issuer issuer = new IssuerBuilder().buildObject();
    issuer.setValue(spEntityID);
    logoutRequest.setIssuer(issuer);

    NameID nameID = new NameIDBuilder().buildObject();
    nameID.setFormat((String) consumer.getJwtClaims().getClaim(JWT_CLAIM_NAMEID_FORMAT));
    nameID.setValue((String) consumer.getJwtClaims().getClaim(JWT_CLAIM_NAMEID_VALUE));
    logoutRequest.setNameID(nameID);

    SessionIndex sessionIndex = new SessionIndexBuilder().buildObject();
    sessionIndex.setSessionIndex((String) consumer.getJwtClaims().getClaim(JWT_CLAIM_SESSIONINDEX));
    logoutRequest.getSessionIndexes().add(sessionIndex);

    SAML2RequestTO requestTO = new SAML2RequestTO();
    requestTO.setIdpServiceAddress(logoutRequest.getDestination());
    requestTO.setBindingType(idp.getBindingType());
    try {
        // 3. generate relay state as JWT
        Map<String, Object> claims = new HashMap<>();
        claims.put(JWT_CLAIM_IDP_DEFLATE,
                idp.getBindingType() == SAML2BindingType.REDIRECT ? true : idp.isUseDeflateEncoding());
        Triple<String, String, Date> relayState =
                accessTokenDataBinder.generateJWT(logoutRequest.getID(), JWT_RELAY_STATE_DURATION, claims);
        requestTO.setRelayState(relayState.getMiddle());

        // 4. sign and encode AuthnRequest
        switch (idp.getBindingType()) {
            case REDIRECT:
                requestTO.setContent(saml2rw.encode(logoutRequest, true));
                requestTO.setSignAlg(saml2rw.getSigAlgo());
                requestTO.setSignature(saml2rw.sign(requestTO.getContent(), requestTO.getRelayState()));
                break;

            case POST:
            default:
                saml2rw.sign(logoutRequest);
                requestTO.setContent(saml2rw.encode(logoutRequest, idp.isUseDeflateEncoding()));
        }
    } catch (Exception e) {
        LOG.error("While generating LogoutRequest", e);
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown);
        sce.getElements().add(e.getMessage());
        throw sce;
    }

    return requestTO;
}
 
开发者ID:apache,项目名称:syncope,代码行数:80,代码来源:SAML2SPLogic.java

示例4: getNameID

import org.opensaml.saml.saml2.core.NameID; //导入方法依赖的package包/类
/**
 * Gets name id.
 *
 * @param nameIdFormat the name id format
 * @param nameIdValue the name id value
 * @return the name iD
 */
protected NameID getNameID(final String nameIdFormat, final String nameIdValue) {
    final NameID nameId = newSamlObject(NameID.class);
    nameId.setFormat(nameIdFormat);
    nameId.setValue(nameIdValue);
    return nameId;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:14,代码来源:AbstractSaml20ObjectBuilder.java

示例5: getNameID

import org.opensaml.saml.saml2.core.NameID; //导入方法依赖的package包/类
/**
 * Gets name id.
 *
 * @param nameIdFormat the name id format
 * @param nameIdValue  the name id value
 * @return the name iD
 */
protected NameID getNameID(final String nameIdFormat, final String nameIdValue) {
    final NameID nameId = newSamlObject(NameID.class);
    nameId.setFormat(nameIdFormat);
    nameId.setValue(nameIdValue);
    return nameId;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:14,代码来源:AbstractSaml20ObjectBuilder.java


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