protected U convertAttributesToProfile(final List<Map<String, Object>> listStorageAttributes, final String username) {
        if (listStorageAttributes == null || listStorageAttributes.size() == 0) {
            return null;
        }
        final Map<String, Object> storageAttributes = listStorageAttributes.get(0);

        final String linkedId = (String) storageAttributes.get(LINKEDID);
        // legacy mode: only read the defined attributes
        if (isLegacyMode()) {
            final U profile = getProfileDefinition().newProfile();
            for (final String attributeName : attributeNames) {
                getProfileDefinition().convertAndAdd(profile, PROFILE_ATTRIBUTE, attributeName, storageAttributes.get(attributeName));
            }
            final Object retrievedUsername = storageAttributes.get(getUsernameAttribute());
            if (retrievedUsername != null) {
                profile.setId(ProfileHelper.sanitizeIdentifier(profile, retrievedUsername));
            } else {
                profile.setId(username);
            }
            if (isNotBlank(linkedId)) {
                profile.setLinkedId(linkedId);
            }
            return profile;
        } else {
            // new behaviour (>= v2.0): read the serialized profile
            final String serializedProfile = (String) storageAttributes.get(SERIALIZED_PROFILE);
            if (serializedProfile == null) {
                throw new TechnicalException("No serialized profile found. You should certainly define the explicit attribute names you " +
                    "want to retrieve");
            }
            final U profile = (U) javaSerializationHelper.deserializeFromBase64(serializedProfile);
            if (profile == null) {
                throw new TechnicalException("No deserialized profile available. You should certainly define the explicit attribute " +
                    "names you want to retrieve");
            }
            final Object id = storageAttributes.get(getIdAttribute());
            if (isBlank(profile.getId()) && id != null) {
                profile.setId(ProfileHelper.sanitizeIdentifier(profile, id));
            }
            if (isBlank(profile.getLinkedId()) && isNotBlank(linkedId)) {
                profile.setLinkedId(linkedId);
            }
            return profile;
        }
    }
protected U convertAttributesToProfile ( final List < Map < String , Object > > listStorageAttributes , final String username ) { if ( listStorageAttributes == null || listStorageAttributes . size ( ) == 0 ) { return null ; } final Map < String , Object > storageAttributes = listStorageAttributes . get ( 0 ) ; final String linkedId = ( String ) storageAttributes . get ( LINKEDID ) ; if ( isLegacyMode ( ) ) { final U profile = getProfileDefinition ( ) . newProfile ( ) ; for ( final String attributeName : attributeNames ) { getProfileDefinition ( ) . convertAndAdd ( profile , PROFILE_ATTRIBUTE , attributeName , storageAttributes . get ( attributeName ) ) ; } final Object retrievedUsername = storageAttributes . get ( getUsernameAttribute ( ) ) ; if ( retrievedUsername != null ) { profile . setId ( ProfileHelper . sanitizeIdentifier ( profile , retrievedUsername ) ) ; } else { profile . setId ( username ) ; } if ( isNotBlank ( linkedId ) ) { profile . setLinkedId ( linkedId ) ; } return profile ; } else { final String serializedProfile = ( String ) storageAttributes . get ( SERIALIZED_PROFILE ) ; if ( serializedProfile == null ) { throw new TechnicalException ( "No serialized profile found. You should certainly define the explicit attribute names you " + "want to retrieve" ) ; } final U profile = ( U ) javaSerializationHelper . deserializeFromBase64 ( serializedProfile ) ; if ( profile == null ) { throw new TechnicalException ( "No deserialized profile available. You should certainly define the explicit attribute " + "names you want to retrieve" ) ; } final Object id = storageAttributes . get ( getIdAttribute ( ) ) ; if ( isBlank ( profile . getId ( ) ) && id != null ) { profile . setId ( ProfileHelper . sanitizeIdentifier ( profile , id ) ) ; } if ( isBlank ( profile . getLinkedId ( ) ) && isNotBlank ( linkedId ) ) { profile . setLinkedId ( linkedId ) ; } return profile ; } }
Convert the list of map of attributes from the storage into a profile.

@param listStorageAttributes the list of map of attributes
@param username the username used for login
@return the profile