private void copyAssertionAttributesToUserAttributes(Assertion assertion) {
        if (!copyAssertionAttributesToUserAttributes) {
            return;
        }

        // skip this if there are no attributes or if the attribute set is empty.
        if (assertion.getPrincipal().getAttributes() == null
                || assertion.getPrincipal().getAttributes().isEmpty()) {
            return;
        }

        Map<String, List<Object>> attributes = new HashMap<>();
        // loop over the set of person attributes from CAS...
        for (Map.Entry<String, Object> attrEntry :
                assertion.getPrincipal().getAttributes().entrySet()) {
            log.debug(
                    "Adding attribute '{}' from Assertion with value '{}'; runtime type of value is {}",
                    attrEntry.getKey(),
                    attrEntry.getValue(),
                    attrEntry.getValue().getClass().getName());

            // Check for credential
            if (decryptCredentialToPassword
                    && key != null
                    && cipher != null
                    && attrEntry.getKey().equals(CREDENTIAL_KEY)) {
                try {
                    final String encPwd =
                            (String)
                                    (attrEntry.getValue() instanceof List
                                            ? ((List) attrEntry.getValue()).get(0)
                                            : attrEntry.getValue());
                    byte[] cred64 = DatatypeConverter.parseBase64Binary(encPwd);
                    cipher.init(Cipher.DECRYPT_MODE, key);
                    final byte[] cipherData = cipher.doFinal(cred64);
                    final Object pwd = new String(cipherData, UTF_8);
                    attributes.put(PASSWORD_KEY, Collections.singletonList(pwd));
                } catch (Exception e) {
                    log.warn("Cannot decipher credential", e);
                }
            }

            // convert each attribute to a list, if necessary...
            List<Object> valueList;
            if (attrEntry.getValue() instanceof List) {
                valueList = (List<Object>) attrEntry.getValue();
            } else {
                valueList = Collections.singletonList(attrEntry.getValue());
            }

            // add the attribute...
            attributes.put(attrEntry.getKey(), valueList);
        }

        // get the attribute descriptor from Spring...
        IAdditionalDescriptors additionalDescriptors =
                (IAdditionalDescriptors)
                        applicationContext.getBean(SESSION_ADDITIONAL_DESCRIPTORS_BEAN);

        // add the new properties...
        additionalDescriptors.addAttributes(attributes);
    }
private void copyAssertionAttributesToUserAttributes ( Assertion assertion ) { if ( ! copyAssertionAttributesToUserAttributes ) { return ; } if ( assertion . getPrincipal ( ) . getAttributes ( ) == null || assertion . getPrincipal ( ) . getAttributes ( ) . isEmpty ( ) ) { return ; } Map < String , List < Object > > attributes = new HashMap < > ( ) ; for ( Map . Entry < String , Object > attrEntry : assertion . getPrincipal ( ) . getAttributes ( ) . entrySet ( ) ) { log . debug ( "Adding attribute '{}' from Assertion with value '{}'; runtime type of value is {}" , attrEntry . getKey ( ) , attrEntry . getValue ( ) , attrEntry . getValue ( ) . getClass ( ) . getName ( ) ) ; if ( decryptCredentialToPassword && key != null && cipher != null && attrEntry . getKey ( ) . equals ( CREDENTIAL_KEY ) ) { try { final String encPwd = ( String ) ( attrEntry . getValue ( ) instanceof List ? ( ( List ) attrEntry . getValue ( ) ) . get ( 0 ) : attrEntry . getValue ( ) ) ; byte [ ] cred64 = DatatypeConverter . parseBase64Binary ( encPwd ) ; cipher . init ( Cipher . DECRYPT_MODE , key ) ; final byte [ ] cipherData = cipher . doFinal ( cred64 ) ; final Object pwd = new String ( cipherData , UTF_8 ) ; attributes . put ( PASSWORD_KEY , Collections . singletonList ( pwd ) ) ; } catch ( Exception e ) { log . warn ( "Cannot decipher credential" , e ) ; } } List < Object > valueList ; if ( attrEntry . getValue ( ) instanceof List ) { valueList = ( List < Object > ) attrEntry . getValue ( ) ; } else { valueList = Collections . singletonList ( attrEntry . getValue ( ) ) ; } attributes . put ( attrEntry . getKey ( ) , valueList ) ; } IAdditionalDescriptors additionalDescriptors = ( IAdditionalDescriptors ) applicationContext . getBean ( SESSION_ADDITIONAL_DESCRIPTORS_BEAN ) ; additionalDescriptors . addAttributes ( attributes ) ; }
If enabled, convert CAS assertion person attributes into uPortal user attributes.

@param assertion the Assertion that was retrieved from the ThreadLocal. CANNOT be NULL.