All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.shawven.security.app.connect.AppConnectionStatusView Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version

package com.github.shawven.security.app.connect;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.social.connect.Connection;
import org.springframework.web.servlet.view.AbstractView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 社交账号绑定状态视图
 *
 */
public class AppConnectionStatusView extends AbstractView {

	@SuppressWarnings("unchecked")
	@Override
	protected void renderMergedOutputModel(Map model, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		Map>> connections = (Map>>) model.get("connectionMap");

		Map result = new HashMap<>();
		for (String key : connections.keySet()) {
			result.put(key, !connections.get(key).isEmpty());
		}
        response.setCharacterEncoding("UTF-8");
		response.setContentType("application/json;charset=UTF-8");
		response.getWriter().write(new ObjectMapper().writeValueAsString(result));
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy