@Test void loadFederated() { Bundle bundle = new Bundle(); loader.load(bundle, createFederatedIDPXml(DocumentTools.INSTANCE.getDocumentBuilder().newDocument())); assertFalse(bundle.getIdentityProviders().isEmpty()); assertEquals(1, bundle.getIdentityProviders().size()); assertNotNull(bundle.getIdentityProviders().get("Test")); IdentityProvider entity = bundle.getIdentityProviders().get("Test"); assertNotNull(entity); assertEquals(IdentityProviderType.FEDERATED, entity.getType()); assertPropertiesContent(ImmutableMap.of( "Prop", "Value", "Gateway", "7layer" ), entity.getProperties()); assertNotNull(entity.getIdentityProviderDetail()); assertTrue(entity.getIdentityProviderDetail() instanceof FederatedIdentityProviderDetail); FederatedIdentityProviderDetail federatedIdentityProviderDetail = (FederatedIdentityProviderDetail) entity.getIdentityProviderDetail(); assertFalse(federatedIdentityProviderDetail.getCertificateReferences().isEmpty()); assertTrue(federatedIdentityProviderDetail.getCertificateReferences().contains(CERT_REF)); assertEquals(1, federatedIdentityProviderDetail.getCertificateReferences().size()); }
@Override public void load(final Bundle bundle, final Element element) { final Element identityProviderElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), ID_PROV); final String name = getSingleChildElementTextContent(identityProviderElement, NAME); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(identityProviderElement, PROPERTIES, true), PROPERTIES); final String typeString = getSingleChildElementTextContent(identityProviderElement, ID_PROV_TYPE); IdentityProviderType type = stream(IdentityProviderType.values()).filter(c -> c.getValue().equals(typeString)).findFirst().orElseThrow(() -> new BundleLoadException("Invalid Identity Provider Type: " + typeString)); IdentityProvider identityProvider = new IdentityProvider(); identityProvider.setId(identityProviderElement.getAttribute(ATTRIBUTE_ID)); identityProvider.setName(name); identityProvider.setProperties(properties); identityProvider.setType(type); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(identityProviderElement.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); identityProvider.setAnnotations(annotations); bundle.getIdentityProviders().put(name, identityProvider); switch (type) { case BIND_ONLY_LDAP: Element extensionXml = getSingleChildElement(identityProviderElement, EXTENSION); identityProvider.setIdentityProviderDetail(buildBindOnlyLdapIdentityProviderDetail( getSingleChildElement(extensionXml, BIND_ONLY_ID_PROV_DETAIL) )); break; case FEDERATED: extensionXml = getSingleChildElement(identityProviderElement, EXTENSION, true); if (extensionXml != null) { identityProvider.setIdentityProviderDetail(buildFederatedIdentityProviderDetail( getSingleChildElement(extensionXml, FEDERATED_ID_PROV_DETAIL) )); } break; case POLICY_BACKED: case INTERNAL: case LDAP: default: } }
IdentityProviderLoader implements BundleEntityLoader { @Override public void load(final Bundle bundle, final Element element) { final Element identityProviderElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), ID_PROV); final String name = getSingleChildElementTextContent(identityProviderElement, NAME); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(identityProviderElement, PROPERTIES, true), PROPERTIES); final String typeString = getSingleChildElementTextContent(identityProviderElement, ID_PROV_TYPE); IdentityProviderType type = stream(IdentityProviderType.values()).filter(c -> c.getValue().equals(typeString)).findFirst().orElseThrow(() -> new BundleLoadException("Invalid Identity Provider Type: " + typeString)); IdentityProvider identityProvider = new IdentityProvider(); identityProvider.setId(identityProviderElement.getAttribute(ATTRIBUTE_ID)); identityProvider.setName(name); identityProvider.setProperties(properties); identityProvider.setType(type); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(identityProviderElement.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); identityProvider.setAnnotations(annotations); bundle.getIdentityProviders().put(name, identityProvider); switch (type) { case BIND_ONLY_LDAP: Element extensionXml = getSingleChildElement(identityProviderElement, EXTENSION); identityProvider.setIdentityProviderDetail(buildBindOnlyLdapIdentityProviderDetail( getSingleChildElement(extensionXml, BIND_ONLY_ID_PROV_DETAIL) )); break; case FEDERATED: extensionXml = getSingleChildElement(identityProviderElement, EXTENSION, true); if (extensionXml != null) { identityProvider.setIdentityProviderDetail(buildFederatedIdentityProviderDetail( getSingleChildElement(extensionXml, FEDERATED_ID_PROV_DETAIL) )); } break; case POLICY_BACKED: case INTERNAL: case LDAP: default: } } }
IdentityProviderLoader implements BundleEntityLoader { @Override public void load(final Bundle bundle, final Element element) { final Element identityProviderElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), ID_PROV); final String name = getSingleChildElementTextContent(identityProviderElement, NAME); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(identityProviderElement, PROPERTIES, true), PROPERTIES); final String typeString = getSingleChildElementTextContent(identityProviderElement, ID_PROV_TYPE); IdentityProviderType type = stream(IdentityProviderType.values()).filter(c -> c.getValue().equals(typeString)).findFirst().orElseThrow(() -> new BundleLoadException("Invalid Identity Provider Type: " + typeString)); IdentityProvider identityProvider = new IdentityProvider(); identityProvider.setId(identityProviderElement.getAttribute(ATTRIBUTE_ID)); identityProvider.setName(name); identityProvider.setProperties(properties); identityProvider.setType(type); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(identityProviderElement.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); identityProvider.setAnnotations(annotations); bundle.getIdentityProviders().put(name, identityProvider); switch (type) { case BIND_ONLY_LDAP: Element extensionXml = getSingleChildElement(identityProviderElement, EXTENSION); identityProvider.setIdentityProviderDetail(buildBindOnlyLdapIdentityProviderDetail( getSingleChildElement(extensionXml, BIND_ONLY_ID_PROV_DETAIL) )); break; case FEDERATED: extensionXml = getSingleChildElement(identityProviderElement, EXTENSION, true); if (extensionXml != null) { identityProvider.setIdentityProviderDetail(buildFederatedIdentityProviderDetail( getSingleChildElement(extensionXml, FEDERATED_ID_PROV_DETAIL) )); } break; case POLICY_BACKED: case INTERNAL: case LDAP: default: } } IdentityProviderLoader(); }
IdentityProviderLoader implements BundleEntityLoader { @Override public void load(final Bundle bundle, final Element element) { final Element identityProviderElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), ID_PROV); final String name = getSingleChildElementTextContent(identityProviderElement, NAME); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(identityProviderElement, PROPERTIES, true), PROPERTIES); final String typeString = getSingleChildElementTextContent(identityProviderElement, ID_PROV_TYPE); IdentityProviderType type = stream(IdentityProviderType.values()).filter(c -> c.getValue().equals(typeString)).findFirst().orElseThrow(() -> new BundleLoadException("Invalid Identity Provider Type: " + typeString)); IdentityProvider identityProvider = new IdentityProvider(); identityProvider.setId(identityProviderElement.getAttribute(ATTRIBUTE_ID)); identityProvider.setName(name); identityProvider.setProperties(properties); identityProvider.setType(type); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(identityProviderElement.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); identityProvider.setAnnotations(annotations); bundle.getIdentityProviders().put(name, identityProvider); switch (type) { case BIND_ONLY_LDAP: Element extensionXml = getSingleChildElement(identityProviderElement, EXTENSION); identityProvider.setIdentityProviderDetail(buildBindOnlyLdapIdentityProviderDetail( getSingleChildElement(extensionXml, BIND_ONLY_ID_PROV_DETAIL) )); break; case FEDERATED: extensionXml = getSingleChildElement(identityProviderElement, EXTENSION, true); if (extensionXml != null) { identityProvider.setIdentityProviderDetail(buildFederatedIdentityProviderDetail( getSingleChildElement(extensionXml, FEDERATED_ID_PROV_DETAIL) )); } break; case POLICY_BACKED: case INTERNAL: case LDAP: default: } } IdentityProviderLoader(); @Override void load(final Bundle bundle, final Element element); @Override String getEntityType(); }
IdentityProviderLoader implements BundleEntityLoader { @Override public void load(final Bundle bundle, final Element element) { final Element identityProviderElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), ID_PROV); final String name = getSingleChildElementTextContent(identityProviderElement, NAME); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(identityProviderElement, PROPERTIES, true), PROPERTIES); final String typeString = getSingleChildElementTextContent(identityProviderElement, ID_PROV_TYPE); IdentityProviderType type = stream(IdentityProviderType.values()).filter(c -> c.getValue().equals(typeString)).findFirst().orElseThrow(() -> new BundleLoadException("Invalid Identity Provider Type: " + typeString)); IdentityProvider identityProvider = new IdentityProvider(); identityProvider.setId(identityProviderElement.getAttribute(ATTRIBUTE_ID)); identityProvider.setName(name); identityProvider.setProperties(properties); identityProvider.setType(type); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(identityProviderElement.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); identityProvider.setAnnotations(annotations); bundle.getIdentityProviders().put(name, identityProvider); switch (type) { case BIND_ONLY_LDAP: Element extensionXml = getSingleChildElement(identityProviderElement, EXTENSION); identityProvider.setIdentityProviderDetail(buildBindOnlyLdapIdentityProviderDetail( getSingleChildElement(extensionXml, BIND_ONLY_ID_PROV_DETAIL) )); break; case FEDERATED: extensionXml = getSingleChildElement(identityProviderElement, EXTENSION, true); if (extensionXml != null) { identityProvider.setIdentityProviderDetail(buildFederatedIdentityProviderDetail( getSingleChildElement(extensionXml, FEDERATED_ID_PROV_DETAIL) )); } break; case POLICY_BACKED: case INTERNAL: case LDAP: default: } } IdentityProviderLoader(); @Override void load(final Bundle bundle, final Element element); @Override String getEntityType();  }