class SubjectUtil {

    public static List<String> getUsernamesFromSubject(Subject subject) {

        List<String> userList = new ArrayList<String>();

        Set<Principal> princSet = null;

        if (subject != null) {

            princSet = subject.getPrincipals();
            for (Principal p : princSet) {
                if ((p != null) && (
                  p.getClass().isAssignableFrom(PrincipalImpl.class)  ||
                  "weblogic.security.principal.WLSUserImpl".equals(p.getClass().getCanonicalName())
                		)) {
                    String uName = p.getName();
                    userList.add(uName);
                }
            }
        }

        return userList;
    }

}