• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NameID类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: processChildElement

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {
    LogoutRequest req = (LogoutRequest) parentSAMLObject;

    if (childSAMLObject instanceof BaseID) {
        req.setBaseID((BaseID) childSAMLObject);
    } else if (childSAMLObject instanceof NameID) {
        req.setNameID((NameID) childSAMLObject);
    } else if (childSAMLObject instanceof EncryptedID) {
        req.setEncryptedID((EncryptedID) childSAMLObject);
    } else if (childSAMLObject instanceof SessionIndex) {
        req.getSessionIndexes().add((SessionIndex) childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:LogoutRequestUnmarshaller.java


示例2: 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


示例3: testChildElementsMarshall

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsMarshall() {
    QName qname = new QName(SAMLConstants.SAML20P_NS, LogoutRequest.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX);
    LogoutRequest req = (LogoutRequest) buildXMLObject(qname);
    
    super.populateChildElements(req);
    
    QName nameIDQName = new QName(SAMLConstants.SAML20_NS, NameID.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    req.setNameID((NameID) buildXMLObject(nameIDQName));
    
    QName sessionIndexQName = new QName(SAMLConstants.SAML20P_NS, SessionIndex.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX);
    for (int i=0; i<expectedNumSessionIndexes; i++){
        req.getSessionIndexes().add((SessionIndex) buildXMLObject(sessionIndexQName));
    }
    
    assertEquals(expectedChildElementsDOM, req);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:18,代码来源:LogoutRequestTest.java


示例4: getAcsEndpoint

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
/**
 * Gets the source location used to for the artifacts created by this encoder.
 * 
 * @param requestContext current request context
 * 
 * @return source location used to for the artifacts created by this encoder
 */
protected Endpoint getAcsEndpoint(SAMLMessageContext<SAMLObject, SAMLObject, NameID> requestContext) {
    BasicEndpointSelector selector = new BasicEndpointSelector();
    selector.setEndpointType(ArtifactResolutionService.DEFAULT_ELEMENT_NAME);
    selector.getSupportedIssuerBindings().add(SAMLConstants.SAML2_SOAP11_BINDING_URI);
    selector.setMetadataProvider(requestContext.getMetadataProvider());
    selector.setEntityMetadata(requestContext.getLocalEntityMetadata());
    selector.setEntityRoleMetadata(requestContext.getLocalEntityRoleMetadata());

    Endpoint acsEndpoint = selector.selectEndpoint();

    if (acsEndpoint == null) {
        log.error("No artifact resolution service endpoint defined for the entity "
                + requestContext.getOutboundMessageIssuer());
        return null;
    }

    return acsEndpoint;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:SAML2ArtifactType0004Builder.java


示例5: processChildElement

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {
    ManageNameIDRequest req = (ManageNameIDRequest) parentSAMLObject;

    if (childSAMLObject instanceof NameID) {
        req.setNameID((NameID) childSAMLObject);
    } else if (childSAMLObject instanceof EncryptedID) {
        req.setEncryptedID((EncryptedID) childSAMLObject);
    } else if (childSAMLObject instanceof NewID) {
        req.setNewID((NewID) childSAMLObject);
    } else if (childSAMLObject instanceof NewEncryptedID) {
        req.setNewEncryptedID((NewEncryptedID) childSAMLObject);
    } else if (childSAMLObject instanceof Terminate) {
        req.setTerminate((Terminate) childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:ManageNameIDRequestUnmarshaller.java


示例6: processChildElement

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {
    NameIDMappingRequest req = (NameIDMappingRequest) parentSAMLObject;

    if (childSAMLObject instanceof BaseID) {
        req.setBaseID((BaseID) childSAMLObject);
    } else if (childSAMLObject instanceof NameID) {
        req.setNameID((NameID) childSAMLObject);
    } else if (childSAMLObject instanceof EncryptedID) {
        req.setEncryptedID((EncryptedID) childSAMLObject);
    } else if (childSAMLObject instanceof NameIDPolicy) {
        req.setNameIDPolicy((NameIDPolicy) childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:NameIDMappingRequestUnmarshaller.java


示例7: processChildElement

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
/** {@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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:SubjectUnmarshaller.java


示例8: processChildElement

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
    SubjectConfirmation subjectConfirmation = (SubjectConfirmation) parentObject;

    if (childObject instanceof BaseID) {
        subjectConfirmation.setBaseID((BaseID) childObject);
    } else if (childObject instanceof NameID) {
        subjectConfirmation.setNameID((NameID) childObject);
    } else if (childObject instanceof EncryptedID) {
        subjectConfirmation.setEncryptedID((EncryptedID) childObject);
    } else if (childObject instanceof SubjectConfirmationData) {
        subjectConfirmation.setSubjectConfirmationData((SubjectConfirmationData) childObject);
    } else {
        super.processChildElement(parentObject, childObject);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:SubjectConfirmationUnmarshaller.java


示例9: marshallAttributes

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
    NameIDType nameID = (NameIDType) samlObject;

    if (nameID.getNameQualifier() != null) {
        domElement.setAttributeNS(null, NameID.NAME_QUALIFIER_ATTRIB_NAME, nameID.getNameQualifier());
    }

    if (nameID.getSPNameQualifier() != null) {
        domElement.setAttributeNS(null, NameID.SP_NAME_QUALIFIER_ATTRIB_NAME, nameID.getSPNameQualifier());
    }

    if (nameID.getFormat() != null) {
        domElement.setAttributeNS(null, NameID.FORMAT_ATTRIB_NAME, nameID.getFormat());
    }

    if (nameID.getSPProvidedID() != null) {
        domElement.setAttributeNS(null, NameID.SPPROVIDED_ID_ATTRIB_NAME, nameID.getSPProvidedID());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AbstractNameIDTypeMarshaller.java


示例10: 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


示例11: testAttributes

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
@Test
public void testAttributes() {
    SAMLCredential samlCredential = mock(SAMLCredential.class);
    NameID nameId = mock(NameID.class);
    when(samlCredential.getNameID()).thenReturn(nameId);
    Attribute attribute = mock(Attribute.class);
    when(attribute.getName()).thenReturn("attr");
    when(samlCredential.getAttributes()).thenReturn(Collections.singletonList(attribute));
    when(samlCredential.getAttribute("attr")).thenReturn(attribute);
    when(samlCredential.getAttributeAsString("attr")).thenReturn("value");
    when(samlCredential.getAttributeAsStringArray("attr")).thenReturn(new String[]{"value"});
    when(nameId.toString()).thenReturn(NameID.UNSPECIFIED);
    SAMLUserDetails details = (SAMLUserDetails) new SimpleSAMLUserDetailsService().loadUserBySAML(samlCredential);
    assertThat(details.getPassword()).isEmpty();
    assertThat(details.isAccountNonExpired()).isTrue();
    assertThat(details.isAccountNonLocked()).isTrue();
    assertThat(details.isCredentialsNonExpired()).isTrue();
    assertThat(details.isEnabled()).isTrue();
    assertThat(details.getAuthorities()).extracting(GrantedAuthority::getAuthority).containsExactly("ROLE_USER");
    assertThat(details.getAttribute("attr")).isEqualTo("value");
    assertThat(details.getAttributeArray("attr")).containsExactly("value");
    assertThat(details.getAttributes()).containsOnlyKeys("attr").containsValue("value");
    assertThat(details.getAttributesArrays()).containsOnlyKeys("attr");
    assertThat(details.getAttributesArrays().get("attr")).containsExactly("value");
}
 
开发者ID:ulisesbocchio,项目名称:spring-boot-security-saml,代码行数:26,代码来源:SimpleSAMLUserDetailsServiceTest.java


示例12: testAttributes

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
@Test
public void testAttributes() {
    SAMLCredential samlCredential = mock(SAMLCredential.class);
    NameID nameId = mock(NameID.class);
    when(samlCredential.getNameID()).thenReturn(nameId);
    Attribute attribute = mock(Attribute.class);
    when(attribute.getName()).thenReturn("attr");
    when(samlCredential.getAttributes()).thenReturn(Collections.singletonList(attribute));
    when(samlCredential.getAttribute("attr")).thenReturn(attribute);
    when(samlCredential.getAttributeAsString("attr")).thenReturn("value");
    when(samlCredential.getAttributeAsStringArray("attr")).thenReturn(new String[]{"value"});
    when(nameId.toString()).thenReturn(NameID.UNSPECIFIED);
    SAMLUserDetails details = new SAMLUserDetails(samlCredential);
    assertThat(details.getPassword()).isEmpty();
    assertThat(details.isAccountNonExpired()).isTrue();
    assertThat(details.isAccountNonLocked()).isTrue();
    assertThat(details.isCredentialsNonExpired()).isTrue();
    assertThat(details.isEnabled()).isTrue();
    assertThat(details.getAuthorities()).extracting(GrantedAuthority::getAuthority).containsExactly("ROLE_USER");
    assertThat(details.getAttribute("attr")).isEqualTo("value");
    assertThat(details.getAttributeArray("attr")).containsExactly("value");
    assertThat(details.getAttributes()).containsOnlyKeys("attr").containsValue("value");
    assertThat(details.getAttributesArrays()).containsOnlyKeys("attr");
    assertThat(details.getAttributesArrays().get("attr")).containsExactly("value");
}
 
开发者ID:ulisesbocchio,项目名称:spring-boot-security-saml,代码行数:26,代码来源:SAMLUserDetailsTest.java


示例13: buildLogoutRequest

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
/**
 * Generate a new LogoutRequest.
 * 
 * @param session The session containing the active assertion.
 * @param logoutServiceLocation Destination for the logout request.
 * @param issuerEntityId Entity ID of the issuing entity.
 */
@SuppressWarnings("deprecation")
public static OIOLogoutRequest buildLogoutRequest(HttpSession session, String logoutServiceLocation, String issuerEntityId, SessionHandler handler) {
	LogoutRequest logoutRequest = new LogoutRequestBuilder().buildObject();

	logoutRequest.setID(Utils.generateUUID());
	logoutRequest.setIssueInstant(new DateTime(DateTimeZone.UTC));
	logoutRequest.addNamespace(OIOSAMLConstants.SAML20_NAMESPACE);
	logoutRequest.setDestination(logoutServiceLocation);
	logoutRequest.setReason("urn:oasis:names:tc:SAML:2.0:logout:user");
	logoutRequest.setIssuer(SAMLUtil.createIssuer(issuerEntityId));

	OIOAssertion assertion = handler.getAssertion(session.getId());
	if (assertion != null) {
		NameID nameID = SAMLUtil.createNameID(assertion.getSubjectNameIDValue());
		nameID.setFormat(assertion.getAssertion().getSubject().getNameID().getFormat());
		logoutRequest.setNameID(nameID);
		SessionIndex sessionIndex = new SessionIndexBuilder().buildObject();
		logoutRequest.getSessionIndexes().add(sessionIndex);
		sessionIndex.setSessionIndex(assertion.getSessionIndex());
	}

	try {
		if (log.isDebugEnabled()) {
			log.debug("Validate the logoutRequest...");
		}
		logoutRequest.validate(true);
		if (log.isDebugEnabled()) {
			log.debug("...OK");
		}
	} catch (ValidationException e) {
		throw new WrappedException(Layer.CLIENT, e);
	}

	return new OIOLogoutRequest(logoutRequest);
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:43,代码来源:OIOLogoutRequest.java


示例14: 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


示例15: 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


示例16: setUp

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

  mockWebSSOProfileConsumer = mock( WebSSOProfileConsumer.class );
  mockSAMLMessageStorage =  mock( SAMLMessageStorage.class );
  mockNameID = mock( NameID.class );
  mockAssertion = mock( Assertion.class );

  mockSAMLUserDetailsService = mock( PentahoSamlUserDetailsService.class );

  samlAuthProvider = mock( SAMLAuthenticationProvider.class, CALLS_REAL_METHODS );
  samlAuthProvider.setUserDetails( mockSAMLUserDetailsService );
  samlAuthProvider.setConsumer( mockWebSSOProfileConsumer );
  samlAuthProvider.setSamlLogger( new SAMLEmptyLogger() );
  samlAuthProvider.setForcePrincipalAsString( true ); // TODO
}
 
开发者ID:pentaho,项目名称:pentaho-engineering-samples,代码行数:17,代码来源:SamlAuthenticationProviderTest.java


示例17: decodeSamlMessage

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
public static SAMLMessageContext decodeSamlMessage(HttpServletRequest request, HttpServletResponse response) throws Exception {

        SAMLMessageContext<SAMLObject, SAMLObject, NameID> samlMessageContext =
                new BasicSAMLMessageContext<SAMLObject, SAMLObject, NameID>();

        HttpServletRequestAdapter httpServletRequestAdapter =
                new HttpServletRequestAdapter(request);
        samlMessageContext.setInboundMessageTransport(httpServletRequestAdapter);
        samlMessageContext.setInboundSAMLProtocol(SAMLConstants.SAML20P_NS);
        HttpServletResponseAdapter httpServletResponseAdapter =
                new HttpServletResponseAdapter(response, request.isSecure());
        samlMessageContext.setOutboundMessageTransport(httpServletResponseAdapter);
        samlMessageContext.setPeerEntityRole(IDPSSODescriptor.DEFAULT_ELEMENT_NAME);

        SecurityPolicyResolver securityPolicyResolver =
                getSecurityPolicyResolver(request.isSecure());

        samlMessageContext.setSecurityPolicyResolver(securityPolicyResolver);
        HTTPPostDecoder samlMessageDecoder = new HTTPPostDecoder();
        samlMessageDecoder.decode(samlMessageContext);
        return samlMessageContext;
    }
 
开发者ID:imCodePartnerAB,项目名称:iVIS,代码行数:23,代码来源:SAMLUtils.java


示例18: 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


示例19: buildArtifact

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
/** {@inheritDoc} */
public SAML2ArtifactType0004 buildArtifact(SAMLMessageContext<SAMLObject, SAMLObject, NameID> requestContext) {
    try {
        IndexedEndpoint acsEndpoint = (IndexedEndpoint) getAcsEndpoint(requestContext);
        byte[] endpointIndex = DatatypeHelper.intToByteArray(acsEndpoint.getIndex());
        byte[] trimmedIndex = new byte[2];
        trimmedIndex[0] = endpointIndex[2];
        trimmedIndex[1] = endpointIndex[3];

        MessageDigest sha1Digester = MessageDigest.getInstance("SHA-1");
        byte[] source = sha1Digester.digest(requestContext.getLocalEntityId().getBytes());

        SecureRandom handleGenerator = SecureRandom.getInstance("SHA1PRNG");
        byte[] assertionHandle;
        assertionHandle = new byte[20];
        handleGenerator.nextBytes(assertionHandle);

        return new SAML2ArtifactType0004(trimmedIndex, source, assertionHandle);
    } catch (NoSuchAlgorithmException e) {
        log.error("JVM does not support required cryptography algorithms: SHA-1/SHA1PRNG.", e);
        throw new InternalError("JVM does not support required cryptography algorithms: SHA-1/SHA1PRNG.");
    }
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:24,代码来源:SAML2ArtifactType0004Builder.java


示例20: getAcsEndpoint

import org.opensaml.saml2.core.NameID; //导入依赖的package包/类
/**
 * Gets the source location used to for the artifacts created by this encoder.
 * 
 * @param requestContext current request context
 * 
 * @return source location used to for the artifacts created by this encoder
 */
protected Endpoint getAcsEndpoint(SAMLMessageContext<SAMLObject, SAMLObject, NameID> requestContext) {
    BasicEndpointSelector selector = new BasicEndpointSelector();
    selector.setEndpointType(ArtifactResolutionService.DEFAULT_ELEMENT_NAME);
    selector.getSupportedIssuerBindings().add(SAMLConstants.SAML2_SOAP11_BINDING_URI);
    selector.setMetadataProvider(requestContext.getMetadataProvider());
    selector.setEntityMetadata(requestContext.getLocalEntityMetadata());
    selector.setEntityRoleMetadata(requestContext.getLocalEntityRoleMetadata());

    Endpoint acsEndpoint = selector.selectEndpoint();

    if (acsEndpoint == null) {
        log.error("Unable to select source location for artifact.  No artifact resolution service defined for issuer.");
        return null;
    }

    return acsEndpoint;
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:25,代码来源:SAML2ArtifactType0004Builder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TypeVariable类代码示例发布时间:2022-05-21
下一篇:
Java IterableSubject类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap