本文整理汇总了Java中org.opensaml.saml2.metadata.IDPSSODescriptor类的典型用法代码示例。如果您正苦于以下问题:Java IDPSSODescriptor类的具体用法?Java IDPSSODescriptor怎么用?Java IDPSSODescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDPSSODescriptor类属于org.opensaml.saml2.metadata包,在下文中一共展示了IDPSSODescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processChildElement
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
IDPSSODescriptor descriptor = (IDPSSODescriptor) parentObject;
if (childObject instanceof SingleSignOnService) {
descriptor.getSingleSignOnServices().add((SingleSignOnService) childObject);
} else if (childObject instanceof NameIDMappingService) {
descriptor.getNameIDMappingServices().add((NameIDMappingService) childObject);
} else if (childObject instanceof AssertionIDRequestService) {
descriptor.getAssertionIDRequestServices().add((AssertionIDRequestService) childObject);
} else if (childObject instanceof AttributeProfile) {
descriptor.getAttributeProfiles().add((AttributeProfile) childObject);
} else if (childObject instanceof Attribute) {
descriptor.getAttributes().add((Attribute) childObject);
} else {
super.processChildElement(parentObject, childObject);
}
}
示例2: getCertificates
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
private static List<X509Certificate> getCertificates(IDPSSODescriptor idpSsoDescriptor)
throws SamlException {
List<X509Certificate> certificates;
try {
certificates =
idpSsoDescriptor
.getKeyDescriptors()
.stream()
.filter(x -> x.getUse() == UsageType.SIGNING)
.flatMap(SamlClient::getDatasWithCertificates)
.map(SamlClient::getFirstCertificate)
.collect(Collectors.toList());
} catch (Exception e) {
throw new SamlException("Exception in getCertificates", e);
}
return certificates;
}
示例3: buildEntityDescriptor
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
public static EntityDescriptor buildEntityDescriptor(Credential cred) {
EntityDescriptor data = (EntityDescriptor) SAMLUtil.unmarshallElement(TestHelper.class.getResourceAsStream("IdPMetadata.xml"));
IDPSSODescriptor idpSSODescriptor = data.getIDPSSODescriptor(SAMLConstants.SAML20P_NS);
org.opensaml.xml.signature.X509Certificate cert = SAMLUtil.buildXMLObject(org.opensaml.xml.signature.X509Certificate.class);
try {
cert.setValue(Base64.encodeBytes(getCertificate(cred).getEncoded()));
} catch (Exception e) {
throw new RuntimeException(e);
}
if (idpSSODescriptor.getKeyDescriptors().size() > 0) {
KeyDescriptor keyDescriptor = (KeyDescriptor) idpSSODescriptor.getKeyDescriptors().get(0);
if (keyDescriptor.getKeyInfo().getX509Datas().size() > 0) {
X509Data x509Data = (X509Data) keyDescriptor.getKeyInfo().getX509Datas().get(0);
x509Data.getX509Certificates().clear();
x509Data.getX509Certificates().add(cert);
}
}
return data;
}
示例4: decodeSamlMessage
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的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;
}
示例5: testChildElementsUnmarshall
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsUnmarshall() {
EntityDescriptor descriptor = (EntityDescriptor) unmarshallElement(childElementsFile);
assertNotNull("Extensions child", descriptor.getExtensions());
assertNotNull("Signature child", descriptor.getSignature());
assertEquals("IDPSSODescriptor count", 2, descriptor.getRoleDescriptors(IDPSSODescriptor.DEFAULT_ELEMENT_NAME).size());
assertEquals("SPSSODescriptor count", 3, descriptor.getRoleDescriptors(SPSSODescriptor.DEFAULT_ELEMENT_NAME).size());
assertEquals("AuthnAuthorityDescriptor count", 2, descriptor.getRoleDescriptors(AuthnAuthorityDescriptor.DEFAULT_ELEMENT_NAME).size());
assertEquals("AttributeAuthorityDescriptor count", 1, descriptor.getRoleDescriptors(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME).size());
assertEquals("PDPDescriptor count", 2, descriptor.getRoleDescriptors(PDPDescriptor.DEFAULT_ELEMENT_NAME).size());
assertNotNull("AffiliationDescriptor ", descriptor.getAffiliationDescriptor());
assertNotNull("Organization ", descriptor.getOrganization());
assertEquals("ContactPerson count", 1, descriptor.getContactPersons().size());
assertEquals("AdditionalMetadataLocation count", 3, descriptor.getAdditionalMetadataLocations().size());
}
示例6: testChildElementsUnmarshall
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsUnmarshall() {
IDPSSODescriptor descriptor = (IDPSSODescriptor) unmarshallElement(childElementsFile);
assertNotNull("Extensions", descriptor.getExtensions());
assertNotNull("Organization child", descriptor.getOrganization());
assertEquals("ContactPerson count", 2, descriptor.getContactPersons().size());
assertEquals("ArtifactResolutionService count", 1, descriptor.getArtifactResolutionServices().size());
assertEquals("SingleLogoutService count", 2, descriptor.getSingleLogoutServices().size());
assertEquals("ManageNameIDService count", 4, descriptor.getManageNameIDServices().size());
assertEquals("NameIDFormat count", 1, descriptor.getNameIDFormats().size());
assertEquals("SingleSignOnService count", 3, descriptor.getSingleSignOnServices().size());
assertEquals("NameIDMappingService count", 2, descriptor.getNameIDMappingServices().size());
assertEquals("AssertionIDRequestService count", 3, descriptor.getAssertionIDRequestServices().size());
assertEquals("AttributeProfile count", 3, descriptor.getAttributeProfiles().size());
}
示例7: testXSBooleanAttributes
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
/**
* Test the proper behavior of the XSBooleanValue attributes.
*/
public void testXSBooleanAttributes() {
IDPSSODescriptor descriptor = (IDPSSODescriptor) buildXMLObject(IDPSSODescriptor.DEFAULT_ELEMENT_NAME);
descriptor.setWantAuthnRequestsSigned(Boolean.TRUE);
assertEquals("Unexpected value for boolean attribute found", Boolean.TRUE, descriptor.getWantAuthnRequestsSigned());
assertNotNull("XSBooleanValue was null", descriptor.getWantAuthnRequestsSignedXSBoolean());
assertEquals("XSBooleanValue was unexpected value", new XSBooleanValue(Boolean.TRUE, false),
descriptor.getWantAuthnRequestsSignedXSBoolean());
assertEquals("XSBooleanValue string was unexpected value", "true",
descriptor.getWantAuthnRequestsSignedXSBoolean().toString());
descriptor.setWantAuthnRequestsSigned(Boolean.FALSE);
assertEquals("Unexpected value for boolean attribute found", Boolean.FALSE, descriptor.getWantAuthnRequestsSigned());
assertNotNull("XSBooleanValue was null", descriptor.getWantAuthnRequestsSignedXSBoolean());
assertEquals("XSBooleanValue was unexpected value", new XSBooleanValue(Boolean.FALSE, false),
descriptor.getWantAuthnRequestsSignedXSBoolean());
assertEquals("XSBooleanValue string was unexpected value", "false",
descriptor.getWantAuthnRequestsSignedXSBoolean().toString());
descriptor.setWantAuthnRequestsSigned((Boolean) null);
assertEquals("Unexpected default value for boolean attribute found", Boolean.FALSE, descriptor.getWantAuthnRequestsSigned());
assertNull("XSBooleanValue was not null", descriptor.getWantAuthnRequestsSignedXSBoolean());
}
示例8: validateSingleSign
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
protected void validateSingleSign(IDPSSODescriptor idpssoDescriptor) throws ValidationException {
if (idpssoDescriptor.getSingleSignOnServices() != null && idpssoDescriptor.getSingleSignOnServices().size() > 0) {
for (int i = 0; i < idpssoDescriptor.getSingleSignOnServices().size(); i++) {
if (!DatatypeHelper.isEmpty(idpssoDescriptor.getSingleSignOnServices().get(i).getResponseLocation())) {
throw new ValidationException("ResponseLocation of all SingleSignOnServices must be null");
}
}
}
}
示例9: validateNameIDMapping
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
protected void validateNameIDMapping(IDPSSODescriptor idpssoDescriptor) throws ValidationException {
if (idpssoDescriptor.getNameIDMappingServices() != null
&& idpssoDescriptor.getNameIDMappingServices().size() > 0) {
for (int i = 0; i < idpssoDescriptor.getNameIDMappingServices().size(); i++) {
if (!DatatypeHelper.isEmpty(idpssoDescriptor.getNameIDMappingServices().get(i).getResponseLocation())) {
throw new ValidationException("ResponseLocation of all NameIDMappingServices must be null");
}
}
}
}
示例10: processAttribute
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
IDPSSODescriptor descriptor = (IDPSSODescriptor) samlObject;
if (attribute.getLocalName().equals(IDPSSODescriptor.WANT_AUTHN_REQ_SIGNED_ATTRIB_NAME)) {
descriptor.setWantAuthnRequestsSigned(XSBooleanValue.valueOf(attribute.getValue()));
} else {
super.processAttribute(samlObject, attribute);
}
}
示例11: marshallAttributes
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
IDPSSODescriptor descriptor = (IDPSSODescriptor) samlObject;
if (descriptor.getWantAuthnRequestsSignedXSBoolean() != null) {
domElement.setAttributeNS(null, IDPSSODescriptor.WANT_AUTHN_REQ_SIGNED_ATTRIB_NAME, descriptor
.getWantAuthnRequestsSignedXSBoolean().toString());
}
super.marshallAttributes(samlObject, domElement);
}
示例12: getIDPSSODescriptor
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
/** {@inheritDoc} */
public IDPSSODescriptor getIDPSSODescriptor(String supportedProtocol) {
List<RoleDescriptor> descriptors = getRoleDescriptors(IDPSSODescriptor.DEFAULT_ELEMENT_NAME, supportedProtocol);
if (descriptors.size() > 0) {
return (IDPSSODescriptor) descriptors.get(0);
}
return null;
}
示例13: buildIDPSSODescriptor
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private IDPSSODescriptor buildIDPSSODescriptor(final SAMLConfig configuration) {
SAMLObjectBuilder<IDPSSODescriptor> builder = (SAMLObjectBuilder<IDPSSODescriptor>) builderFactory.getBuilder(IDPSSODescriptor.DEFAULT_ELEMENT_NAME);
IDPSSODescriptor idpDescriptor = builder.buildObject();
idpDescriptor.setWantAuthnRequestsSigned(false);
idpDescriptor.addSupportedProtocol(SAMLConstants.SAML20P_NS);
idpDescriptor.getSingleSignOnServices().add(getSingleSignOnService(configuration, SAMLConstants.SAML2_REDIRECT_BINDING_URI));
idpDescriptor.getSingleLogoutServices().add(getSingleLogoutService(configuration, SAMLConstants.SAML2_REDIRECT_BINDING_URI));
return idpDescriptor;
}
示例14: getIDPSSODescriptor
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
private static IDPSSODescriptor getIDPSSODescriptor(EntityDescriptor entityDescriptor)
throws SamlException {
IDPSSODescriptor idpssoDescriptor =
entityDescriptor.getIDPSSODescriptor("urn:oasis:names:tc:SAML:2.0:protocol");
if (idpssoDescriptor == null) {
throw new SamlException("Cannot retrieve IDP SSO descriptor");
}
return idpssoDescriptor;
}
示例15: getPostBinding
import org.opensaml.saml2.metadata.IDPSSODescriptor; //导入依赖的package包/类
private static SingleSignOnService getPostBinding(IDPSSODescriptor idpSsoDescriptor)
throws SamlException {
return idpSsoDescriptor
.getSingleSignOnServices()
.stream()
.filter(x -> x.getBinding().equals("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"))
.findAny()
.orElseThrow(() -> new SamlException("Cannot find HTTP-POST SSO binding in metadata"));
}