Get the attribute map of String keys to Set&lt;String&gt; values
This method will not return a null
@param subject
@return Map&lt;String, Set&lt;String&gt;&gt;
775657
@SuppressWarnings("unchecked")
    public static Map<String, Set<String>> getAttributes(Subject subject) {
        Map<String, Set<String>> attributes = null;

        if (subject.getPublicCredentials() == null) {
            return new HashMap<String, Set<String>>();
        }

        @SuppressWarnings("rawtypes")
        Iterator<HashMap> credentialObjects = subject.getPublicCredentials(HashMap.class).iterator();
        while (attributes == null && credentialObjects.hasNext()) {
            HashMap<?,?> credentialObject = credentialObjects.next();

            if (logger.isDebugEnabled()) {
                logger.debug("checking for attributes (class name): "
                        + credentialObject.getClass().getName());
            }

            Object key = null;
            Iterator<?> keys = null;

            keys = credentialObject.keySet().iterator();
            if (!keys.hasNext()) {
                continue;
            }

            key = keys.next();

            if (logger.isDebugEnabled()) {
                logger.debug("checking for attributes (key object name): "
                        + key.getClass().getName());
            }

            if (!(key instanceof String)) {
                continue;
            }

            keys = credentialObject.values().iterator();
            if (!keys.hasNext()) {
                continue;
            }

            key = keys.next();

            if (logger.isDebugEnabled()) {
                logger.debug("checking for attributes (value object name): "
                        + key.getClass().getName());
            }

            if (!(key instanceof HashSet)) {
                continue;
            }

            attributes = (Map<String, Set<String>>) credentialObject;
        }

        if (attributes == null) {
            attributes = new HashMap<String, Set<String>>();
            subject.getPublicCredentials().add(attributes);
        }

        return attributes;
    }
280783
@SuppressWarnings("unchecked")
    public <T> Set<T> getSet(String key) {
        return Reflection.toType(get(key), Set.class);
    }
417011
private Map<String, String> getMBeanAttributes(ObjectName objName) throws Exception  {
        Map<String, String> response = Maps.newLinkedHashMap();
        // Look for the object
        MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(objName);
        if (mBeanInfo != null) {
            
            // Does it have attributes?
            MBeanAttributeInfo[] attrs = mBeanInfo.getAttributes();
            if (attrs != null) {
                // List all attributes
                List<String> attrNames = Lists.newArrayList();
                for (MBeanAttributeInfo attr : attrs) {
                    attrNames.add(attr.getName());
                }
                AttributeList attrList = mBeanServer.getAttributes(objName, attrNames.toArray(new String[0]));
                
                // Process each attribute
                for (Attribute attr : attrList.asList()) {
                    String attrName = attr.getName();
                    Object value    = attr.getValue();
                    String attrValue = null;
                    
                    // Attribute has data
                    if (value != null) {
                        // Special case of CompositeDataSuppert
                        if (value instanceof CompositeDataSupport) {
                            CompositeDataSupport compositeValue = (CompositeDataSupport) value;
                            if (compositeValue != null) {
                                try {
                                    if (compositeValue.containsKey(CURRENT_VALUE)) {
                                        Object curValue = compositeValue.get(CURRENT_VALUE);
                                        attrValue = (curValue == null ? "null" : curValue.toString());
                                    }
                                }
                                catch (Exception e) {
                                    attrValue = compositeValue.toString();
                                }
                            }
                        } 
                        if (attrValue == null) {
                            attrValue = value.toString();
                        }
                    }
                    else {
                        value = "none";
                    }
                    
                    response.put(attrName, attrValue);
                }
            }
        }
        return response;
    }
603205
public java.util.Map<String, IdentityDkimAttributes> getDkimAttributes() {
        if (dkimAttributes == null) {
            dkimAttributes = new com.amazonaws.internal.SdkInternalMap<String, IdentityDkimAttributes>();
        }
        return dkimAttributes;
    }
900865
@SuppressWarnings("unchecked")
    public <T> T getAttributeSet(final String _setName)
        throws EFapsException
    {
        final OneSelect oneselect = this.attr2OneSelect.get(_setName);
        Map<String, Object> ret = null;
        if (oneselect == null || oneselect.getFromSelect() == null) {
            AbstractPrintQuery.LOG.error("Could not get an AttributeSet for the name: '{}' in PrintQuery '{]'",
                            _setName, this);
        } else if (oneselect.getFromSelect().hasResult()) {
            ret = new HashMap<>();
            // in an attributset the first one is fake
            boolean first = true;
            for (final OneSelect onsel : oneselect.getFromSelect().getAllSelects()) {
                if (first) {
                    first = false;
                } else {
                    final ArrayList<Object> list = new ArrayList<>();
                    final Object object = onsel.getObject();
                    if (object instanceof List<?>) {
                        list.addAll((List<?>) object);
                    } else {
                        list.add(object);
                    }
                    ret.put(onsel.getAttribute().getName(), list);
                }
            }
        }
        return (T) ret;
    }
59808
@Override
    public Object mapFromAttributes(final Attributes attributes) throws NamingException {
        final int attributeCount = attributes.size();
        final Map<String, Object> mapOfAttrValues = this.createAttributeMap(attributeCount);

        for (final NamingEnumeration<? extends Attribute> attributesEnum = attributes.getAll(); attributesEnum.hasMore(); ) {
            final Attribute attribute = attributesEnum.next();

            if (!this.ignoreNull || attribute.size() > 0) {
                final String attrName = attribute.getID();
                final String key = this.getAttributeKey(attrName);

                final NamingEnumeration<?> valuesEnum = attribute.getAll();
                final List<?> values = this.getAttributeValues(valuesEnum);

                mapOfAttrValues.put(key, values);
            }
        }

        return mapOfAttrValues;
    }
266473
public static String subjectToString(final Subject subject) {

        final String result;

        if (subject == null) {
            
            result = "null";
            
        } else {
            
            final StringBuffer buffer = startToString(subject);
            addFieldToString(buffer, "principals", subject.getPrincipals());
            endToString(buffer);
            result = buffer.toString();
            
        }

        return result;

    }
113483
@SuppressWarnings("unchecked")
  public <T> T getAttribute(String key) {
    return (T) attrs.get(key);
  }
1000413
public Map<String, Object> getAttributes() {

        Map<String, Object> attrs = CmsRequestUtil.getAtrributeMap(m_request);

        if (attrs.size() == 0) {
            return null;
        }
        return attrs;
    }
818532
protected Map<String, String> getElementAttributes() {
        // Preserve order of attributes
        Map<String, String> attrs = new HashMap<>();

        if (this.getRole() != null) {
            attrs.put("role", this.getRole());
        }

        return attrs;
    }
1125174
protected Map<String, String> getElementAttributes() {
        // Preserve order of attributes
        Map<String, String> attrs = new HashMap<>();

        if (this.getLevel() != null) {
            attrs.put("level", this.getLevel().toString());
        }

        return attrs;
    }
488716
public static Map<String, Object> getAttributeMap(ServletRequest req) {

        if (req instanceof CmsFlexRequest) {
            return ((CmsFlexRequest)req).getAttributeMap();
        }
        Map<String, Object> attrs = new HashMap<String, Object>();
        Enumeration<String> atrrEnum = CmsCollectionsGenericWrapper.enumeration(req.getAttributeNames());
        while (atrrEnum.hasMoreElements()) {
            String key = atrrEnum.nextElement();
            Object value = req.getAttribute(key);
            attrs.put(key, value);
        }
        return attrs;
    }
989785
public Map<Object, Object> getAttributes() {

        if (null == attributes) {
            attributes = new HashMap<Object,Object>();
        }
        return attributes;

    }
1166624
private Attributes toAttributes(Map<String,String> attrs){
        AttributesImpl impl = new AttributesImpl();
        for (Map.Entry<String,String> attr : attrs.entrySet()){
        	impl.addAttribute("", attr.getKey(), "", "CDATA", attr.getValue());
        }
        return impl;
    }
951349
public Map<String, String> values(Object context) {

		if (this.attributes.isEmpty()) {
			return Collections.emptyMap();
		}
		Map<String, String> map = new HashMap<String, String>();
		for (KAttribute attribute : this.attributes) {
			String value = attribute.value(context);
			if (value != null) {
				map.put(attribute.getName(), value);
			}
		}
		return map;
	}
250909
private String _serializeMap(Map map, Set<Object> done) throws ConverterException {
	StringBuilder sb = new StringBuilder(goIn() + "<struct>");

	Iterator it = map.keySet().iterator();

	deep++;
	while (it.hasNext()) {
	    Object key = it.next();
	    sb.append(goIn() + "<var name=" + del + XMLUtil.escapeXMLString(key.toString()) + del + ">");
	    sb.append(_serialize(map.get(key), done));
	    sb.append(goIn() + "</var>");
	}
	deep--;

	sb.append(goIn() + "</struct>");
	return sb.toString();
    }
425694
public static String getUserNameFromSubject(Subject subject) {
        Iterator<Principal> it = subject.getPrincipals().iterator();
        String username = it.next().getName();
        return username;
    }