@Test void whenGetMetadataCalledExpectMetadataByteArray() { Security.addProvider(new BouncyCastleProvider()); Mockito.when(buildProperties.getVersion()).thenReturn("2.0"); byte[] metadata = metadataService.getMetadata(); String metadataAsString = new String(metadata); Assertions.assertTrue(ArrayUtils.isNotEmpty(metadata)); Assertions.assertTrue(metadataAsString.contains("CONTACT_PERSON_COMPANY")); Assertions.assertTrue(metadataAsString.contains("CONTACT_PERSON_EMAIL")); Assertions.assertTrue(metadataAsString.contains("CONTACT_PERSON_GIVENNAME")); Assertions.assertTrue(metadataAsString.contains("CONTACT_PERSON_TEL")); Assertions.assertTrue(metadataAsString.contains("http: Assertions.assertTrue(metadataAsString.contains("ORGANIZATION_DISPLAY_NAME")); Assertions.assertTrue(metadataAsString.contains("http: Assertions.assertTrue(new String(metadata).contains("2.0")); }
@Override public byte[] getMetadata() { ArrayList<EidasPersonAttributes> list = new ArrayList<>(); list.add(EidasNaturalPersonAttributes.FAMILY_NAME); list.add(EidasNaturalPersonAttributes.FIRST_NAME); list.add(EidasNaturalPersonAttributes.CURRENT_ADDRESS); list.add(EidasNaturalPersonAttributes.PERSON_IDENTIFIER); list.add(EidasNaturalPersonAttributes.BIRTH_NAME); list.add(EidasNaturalPersonAttributes.PLACE_OF_BIRTH); list.add(EidasNaturalPersonAttributes.DATE_OF_BIRTH); List<EidasNameIdType> supportedNameIdTypes = new ArrayList<>(); supportedNameIdTypes.add(EidasNameIdType.PERSISTENT); supportedNameIdTypes.add(EidasNameIdType.TRANSIENT); supportedNameIdTypes.add(EidasNameIdType.UNSPECIFIED); try { EidasSigner signer = getEidasSigner(); Date validUntil; if (configHolder.getMetadataValidity() == null) { validUntil = new Date(System.currentTimeMillis() + 30L * 86400000L); } else { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); validUntil = sdf.parse(configHolder.getMetadataValidity()); } String middlewareVersion = buildProperties.getVersion(); boolean requesterIdFlag = true; return EidasSaml.createMetaDataService("_eumiddleware", configHolder.getServerURLWithContextPath() + ContextPaths.METADATA, validUntil, signer.getSigCert(), configHolder.getDecryptionCert(), configHolder.getOrganization(), configHolder.getContactPerson(), configHolder.getContactPerson(), configHolder.getServerURLWithContextPath() + ContextPaths.REQUEST_RECEIVER, configHolder.getServerURLWithContextPath() + ContextPaths.REQUEST_RECEIVER, supportedNameIdTypes, list, signer, middlewareVersion, configHolder.isDoSignMetadata(), requesterIdFlag); } catch (ParseException | CertificateEncodingException | MarshallingException | SignatureException | TransformerFactoryConfigurationError | TransformerException | InitializationException | IOException | UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException e) { log.error("Cannot create metadata for this middleware", e); } return ArrayUtils.EMPTY_BYTE_ARRAY; }
MetadataServiceImpl implements MetadataService { @Override public byte[] getMetadata() { ArrayList<EidasPersonAttributes> list = new ArrayList<>(); list.add(EidasNaturalPersonAttributes.FAMILY_NAME); list.add(EidasNaturalPersonAttributes.FIRST_NAME); list.add(EidasNaturalPersonAttributes.CURRENT_ADDRESS); list.add(EidasNaturalPersonAttributes.PERSON_IDENTIFIER); list.add(EidasNaturalPersonAttributes.BIRTH_NAME); list.add(EidasNaturalPersonAttributes.PLACE_OF_BIRTH); list.add(EidasNaturalPersonAttributes.DATE_OF_BIRTH); List<EidasNameIdType> supportedNameIdTypes = new ArrayList<>(); supportedNameIdTypes.add(EidasNameIdType.PERSISTENT); supportedNameIdTypes.add(EidasNameIdType.TRANSIENT); supportedNameIdTypes.add(EidasNameIdType.UNSPECIFIED); try { EidasSigner signer = getEidasSigner(); Date validUntil; if (configHolder.getMetadataValidity() == null) { validUntil = new Date(System.currentTimeMillis() + 30L * 86400000L); } else { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); validUntil = sdf.parse(configHolder.getMetadataValidity()); } String middlewareVersion = buildProperties.getVersion(); boolean requesterIdFlag = true; return EidasSaml.createMetaDataService("_eumiddleware", configHolder.getServerURLWithContextPath() + ContextPaths.METADATA, validUntil, signer.getSigCert(), configHolder.getDecryptionCert(), configHolder.getOrganization(), configHolder.getContactPerson(), configHolder.getContactPerson(), configHolder.getServerURLWithContextPath() + ContextPaths.REQUEST_RECEIVER, configHolder.getServerURLWithContextPath() + ContextPaths.REQUEST_RECEIVER, supportedNameIdTypes, list, signer, middlewareVersion, configHolder.isDoSignMetadata(), requesterIdFlag); } catch (ParseException | CertificateEncodingException | MarshallingException | SignatureException | TransformerFactoryConfigurationError | TransformerException | InitializationException | IOException | UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException e) { log.error("Cannot create metadata for this middleware", e); } return ArrayUtils.EMPTY_BYTE_ARRAY; } }
MetadataServiceImpl implements MetadataService { @Override public byte[] getMetadata() { ArrayList<EidasPersonAttributes> list = new ArrayList<>(); list.add(EidasNaturalPersonAttributes.FAMILY_NAME); list.add(EidasNaturalPersonAttributes.FIRST_NAME); list.add(EidasNaturalPersonAttributes.CURRENT_ADDRESS); list.add(EidasNaturalPersonAttributes.PERSON_IDENTIFIER); list.add(EidasNaturalPersonAttributes.BIRTH_NAME); list.add(EidasNaturalPersonAttributes.PLACE_OF_BIRTH); list.add(EidasNaturalPersonAttributes.DATE_OF_BIRTH); List<EidasNameIdType> supportedNameIdTypes = new ArrayList<>(); supportedNameIdTypes.add(EidasNameIdType.PERSISTENT); supportedNameIdTypes.add(EidasNameIdType.TRANSIENT); supportedNameIdTypes.add(EidasNameIdType.UNSPECIFIED); try { EidasSigner signer = getEidasSigner(); Date validUntil; if (configHolder.getMetadataValidity() == null) { validUntil = new Date(System.currentTimeMillis() + 30L * 86400000L); } else { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); validUntil = sdf.parse(configHolder.getMetadataValidity()); } String middlewareVersion = buildProperties.getVersion(); boolean requesterIdFlag = true; return EidasSaml.createMetaDataService("_eumiddleware", configHolder.getServerURLWithContextPath() + ContextPaths.METADATA, validUntil, signer.getSigCert(), configHolder.getDecryptionCert(), configHolder.getOrganization(), configHolder.getContactPerson(), configHolder.getContactPerson(), configHolder.getServerURLWithContextPath() + ContextPaths.REQUEST_RECEIVER, configHolder.getServerURLWithContextPath() + ContextPaths.REQUEST_RECEIVER, supportedNameIdTypes, list, signer, middlewareVersion, configHolder.isDoSignMetadata(), requesterIdFlag); } catch (ParseException | CertificateEncodingException | MarshallingException | SignatureException | TransformerFactoryConfigurationError | TransformerException | InitializationException | IOException | UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException e) { log.error("Cannot create metadata for this middleware", e); } return ArrayUtils.EMPTY_BYTE_ARRAY; } MetadataServiceImpl(ConfigHolder configHolder,
                             BuildProperties buildProperties,
                             HSMServiceHolder hsmServiceHolder); }
MetadataServiceImpl implements MetadataService { @Override public byte[] getMetadata() { ArrayList<EidasPersonAttributes> list = new ArrayList<>(); list.add(EidasNaturalPersonAttributes.FAMILY_NAME); list.add(EidasNaturalPersonAttributes.FIRST_NAME); list.add(EidasNaturalPersonAttributes.CURRENT_ADDRESS); list.add(EidasNaturalPersonAttributes.PERSON_IDENTIFIER); list.add(EidasNaturalPersonAttributes.BIRTH_NAME); list.add(EidasNaturalPersonAttributes.PLACE_OF_BIRTH); list.add(EidasNaturalPersonAttributes.DATE_OF_BIRTH); List<EidasNameIdType> supportedNameIdTypes = new ArrayList<>(); supportedNameIdTypes.add(EidasNameIdType.PERSISTENT); supportedNameIdTypes.add(EidasNameIdType.TRANSIENT); supportedNameIdTypes.add(EidasNameIdType.UNSPECIFIED); try { EidasSigner signer = getEidasSigner(); Date validUntil; if (configHolder.getMetadataValidity() == null) { validUntil = new Date(System.currentTimeMillis() + 30L * 86400000L); } else { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); validUntil = sdf.parse(configHolder.getMetadataValidity()); } String middlewareVersion = buildProperties.getVersion(); boolean requesterIdFlag = true; return EidasSaml.createMetaDataService("_eumiddleware", configHolder.getServerURLWithContextPath() + ContextPaths.METADATA, validUntil, signer.getSigCert(), configHolder.getDecryptionCert(), configHolder.getOrganization(), configHolder.getContactPerson(), configHolder.getContactPerson(), configHolder.getServerURLWithContextPath() + ContextPaths.REQUEST_RECEIVER, configHolder.getServerURLWithContextPath() + ContextPaths.REQUEST_RECEIVER, supportedNameIdTypes, list, signer, middlewareVersion, configHolder.isDoSignMetadata(), requesterIdFlag); } catch (ParseException | CertificateEncodingException | MarshallingException | SignatureException | TransformerFactoryConfigurationError | TransformerException | InitializationException | IOException | UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException e) { log.error("Cannot create metadata for this middleware", e); } return ArrayUtils.EMPTY_BYTE_ARRAY; } MetadataServiceImpl(ConfigHolder configHolder,
                             BuildProperties buildProperties,
                             HSMServiceHolder hsmServiceHolder); @Override byte[] getMetadata(); }
MetadataServiceImpl implements MetadataService { @Override public byte[] getMetadata() { ArrayList<EidasPersonAttributes> list = new ArrayList<>(); list.add(EidasNaturalPersonAttributes.FAMILY_NAME); list.add(EidasNaturalPersonAttributes.FIRST_NAME); list.add(EidasNaturalPersonAttributes.CURRENT_ADDRESS); list.add(EidasNaturalPersonAttributes.PERSON_IDENTIFIER); list.add(EidasNaturalPersonAttributes.BIRTH_NAME); list.add(EidasNaturalPersonAttributes.PLACE_OF_BIRTH); list.add(EidasNaturalPersonAttributes.DATE_OF_BIRTH); List<EidasNameIdType> supportedNameIdTypes = new ArrayList<>(); supportedNameIdTypes.add(EidasNameIdType.PERSISTENT); supportedNameIdTypes.add(EidasNameIdType.TRANSIENT); supportedNameIdTypes.add(EidasNameIdType.UNSPECIFIED); try { EidasSigner signer = getEidasSigner(); Date validUntil; if (configHolder.getMetadataValidity() == null) { validUntil = new Date(System.currentTimeMillis() + 30L * 86400000L); } else { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); validUntil = sdf.parse(configHolder.getMetadataValidity()); } String middlewareVersion = buildProperties.getVersion(); boolean requesterIdFlag = true; return EidasSaml.createMetaDataService("_eumiddleware", configHolder.getServerURLWithContextPath() + ContextPaths.METADATA, validUntil, signer.getSigCert(), configHolder.getDecryptionCert(), configHolder.getOrganization(), configHolder.getContactPerson(), configHolder.getContactPerson(), configHolder.getServerURLWithContextPath() + ContextPaths.REQUEST_RECEIVER, configHolder.getServerURLWithContextPath() + ContextPaths.REQUEST_RECEIVER, supportedNameIdTypes, list, signer, middlewareVersion, configHolder.isDoSignMetadata(), requesterIdFlag); } catch (ParseException | CertificateEncodingException | MarshallingException | SignatureException | TransformerFactoryConfigurationError | TransformerException | InitializationException | IOException | UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException e) { log.error("Cannot create metadata for this middleware", e); } return ArrayUtils.EMPTY_BYTE_ARRAY; } MetadataServiceImpl(ConfigHolder configHolder,
                             BuildProperties buildProperties,
                             HSMServiceHolder hsmServiceHolder); @Override byte[] getMetadata();  }