@Test
    void verifyEncryptedAttributeDefinitions() {
        val service = CoreAuthenticationTestUtils.getRegisteredService();
        val servicePublicKey = new RegisteredServicePublicKeyImpl("classpath:keys/RSA1024Public.key", "RSA");
        when(service.getPublicKey()).thenReturn(servicePublicKey);

        try (val store = new DefaultAttributeDefinitionStore()) {
            store.setScope("example.org");
            val defn = DefaultAttributeDefinition.builder()
                .key("cn")
                .scoped(true)
                .encrypted(true)
                .build();
            store.registerAttributeDefinition(defn);
            assertTrue(store.locateAttributeDefinition("cn", DefaultAttributeDefinition.class).isPresent());
            assertFalse(store.locateAttributeDefinition("unknown", DefaultAttributeDefinition.class).isPresent());
            val attributes = CoreAuthenticationTestUtils.getAttributes();
            val attrs = store.resolveAttributeValues(attributes.keySet(), attributes,
                CoreAuthenticationTestUtils.getPrincipal(),
                service, CoreAuthenticationTestUtils.getService());
            assertFalse(attrs.isEmpty());
            assertTrue(attrs.containsKey("cn"));
            val values = CollectionUtils.toCollection(attrs.get("cn"));
            assertFalse(values.stream()
                .anyMatch(value -> value.toString().equalsIgnoreCase(CoreAuthenticationTestUtils.CONST_USERNAME)));
        }
    }
This is {@link DefaultAttributeDefinitionStoreTests}.

@author Misagh Moayyed
@since 6.2.0
support/cas-server-support-person-directory/src/test/java/org/apereo/cas/DefaultAttributeDefinitionStoreTests.java