private void mapUser(final User user, final Principal principal, final Credential credential) {
        user.setUserName(principal.getId());
        if (credential instanceof final UsernamePasswordCredential instance) {
            user.setPassword(instance.toPassword());
        }
        user.setActive(Boolean.TRUE);
        /*
            In SCIM specification, where the groups attribute is typically marked as read-only.
            This means that we cannot assign groups directly to a user by setting the groups attribute.
            The groups attribute is a derived attribute that reflects the groups to which the user belongs,
            and it is managed by the SCIM service provider. You should assign a user to a group by updating
            the group resource itself rather than trying to modify the groups attribute of the user.
         */
        user.setGroups(List.of());

        mapAttributeToSchema(principal, ScimUserSchema.NICKNAME, user::setNickName);
        mapAttributeToSchema(principal, ScimUserSchema.DISPLAY_NAME, user::setDisplayName);
        mapAttributeToSchema(principal, ScimUserSchema.EXTERNAL_ID, user::setExternalId);

        val name = new Name();
        mapAttributeToSchema(principal, ScimUserSchema.GIVEN_NAME, name::setGivenName);
        mapAttributeToSchema(principal, ScimUserSchema.FAMILY_NAME, name::setFamilyName);
        mapAttributeToSchema(principal, ScimUserSchema.MIDDLE_NAME, name::setMiddleName);
        if (!name.isEmpty()) {
            user.setName(name);
        }

        mapAttributesToSchema(principal, ScimUserSchema.EMAIL, value -> {
            val email = new Email();
            email.setValue(value);
            user.addEmail(email);
        });
        mapAttributesToSchema(principal, ScimUserSchema.PHONE_NUMBER, value -> {
            val phone = new PhoneNumber();
            phone.setValue(value);
            user.addPhoneNumber(phone);
        });
        mapAttributesToSchema(principal, ScimUserSchema.ENTITLEMENTS, value ->
            user.addEntitlement(new Entitlement.EntitlementBuilder().value(value).build()));
        mapAttributesToSchema(principal, ScimUserSchema.ROLES, value ->
            user.addRole(new PersonRole.PersonRoleBuilder().value(value).build()));
        mapAttributesToSchema(principal, ScimUserSchema.ADDRESSES, value ->
            user.addAddress(new Address.AddressBuilder().formatted(value).build()));
        mapAttributesToSchema(principal, ScimUserSchema.IMS, value ->
            user.addIms(Ims.builder().value(value).build()));

        val enterpriseUserBuilder = EnterpriseUser.builder();
        mapAttributeToSchema(principal, ScimUserSchema.ENTERPRISE_COST_CENTER, enterpriseUserBuilder::costCenter);
        mapAttributeToSchema(principal, ScimUserSchema.ENTERPRISE_DIVISION, enterpriseUserBuilder::division);
        mapAttributeToSchema(principal, ScimUserSchema.ENTERPRISE_DEPARTMENT, enterpriseUserBuilder::department);
        mapAttributeToSchema(principal, ScimUserSchema.ENTERPRISE_ORGANIZATION, enterpriseUserBuilder::organization);
        mapAttributeToSchema(principal, ScimUserSchema.ENTERPRISE_EMPLOYEE_NUMBER, enterpriseUserBuilder::employeeNumber);
        val enterpriseUser = enterpriseUserBuilder.build();
        if (!enterpriseUser.isEmpty()) {
            user.setEnterpriseUser(enterpriseUser);
        }
        if (user.getMeta().isEmpty()) {
            val meta = new Meta();
            meta.setCreated(LocalDateTime.now(Clock.systemUTC()));
            mapAttributeToSchema(principal, ScimUserSchema.RESOURCE_TYPE, meta::setResourceType);
            user.setMeta(meta);
        }
    }
This is {@link DefaultScimPrincipalAttributeMapper}.

@author Misagh Moayyed
@since 5.1.0
support/cas-server-support-scim-core/src/main/java/org/apereo/cas/scim/v2/provisioning/DefaultScimPrincipalAttributeMapper.java