當前位置: 首頁>>代碼示例>>Java>>正文


Java SocialAuthManager類代碼示例

本文整理匯總了Java中org.brickred.socialauth.SocialAuthManager的典型用法代碼示例。如果您正苦於以下問題:Java SocialAuthManager類的具體用法?Java SocialAuthManager怎麽用?Java SocialAuthManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SocialAuthManager類屬於org.brickred.socialauth包,在下文中一共展示了SocialAuthManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
@Create
/**
 * Initializes the component
 */
public void init() {
	id = null;
	provider = null;
	config = new SocialAuthConfig();
	try {
		config.load();
		manager = new SocialAuthManager();
		manager.setSocialAuthConfig(config);
	} catch (Exception e) {
		e.printStackTrace();
	}

}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:18,代碼來源:SocialAuth.java

示例2: execute

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
/**
 * Update status for the given provider.
 * 
 * @return String where the action should flow
 * @throws Exception
 *             if an error occurs
 */
@Action(value = "/socialAuthUploadPhotoAction")
public String execute() throws Exception {

	SASFHelper helper = SASFStaticHelper.getHelper(request);
	SocialAuthManager manager = helper.getAuthManager();

	AuthProvider provider = null;
	if (manager != null) {
		provider = manager.getCurrentAuthProvider();
	}
	if (provider != null) {
		try {
			provider.uploadImage(statusMessage, imageFileFileName,
					new FileInputStream(imageFile));
			request.setAttribute("Message", "Status Updated successfully");
			return "success";
		} catch (SocialAuthException e) {
			request.setAttribute("Message", e.getMessage());
			e.printStackTrace();
		}
	}
	return "failure";

}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:32,代碼來源:SocialAuthUploadPhotoAction.java

示例3: execute

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
/**
 * creates a instance of the requested provider from AuthProviderFactory and
 * calls the getLoginRedirectURL() method to find the URL which the user
 * should be redirect to.
 * 
 * @return String where the action should flow
 * @throws Exception
 *             if an error occurs
 */

@Action(value = "/socialAuth")
public String execute() throws Exception {
	LOG.info("Given provider id :: " + id);

	SASFHelper helper = SASFStaticHelper.getHelper(request);
	if (mode == null) {
		url = "http://opensource.brickred.com/socialauth-struts-filter-demo/SAF/SocialAuth?id="
				+ id;
		return "forward";

	} else if ("signout".equals(mode)) {
		SocialAuthManager manager = null;
		if (helper != null) {
			manager = helper.getAuthManager();
			if (manager != null) {
				manager.disconnectProvider(id);
			}
		}
		return "home";
	}
	return "home";

}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:34,代碼來源:SocialAuthenticationAction.java

示例4: getRedirectURL

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
@RequestMapping(value = "/authSuccess")
public ModelAndView getRedirectURL(final HttpServletRequest request)
		throws Exception {
	SocialAuthManager manager = socialAuthTemplate.getSocialAuthManager();
	AuthProvider provider = manager.getCurrentAuthProvider();
	HttpSession session = request.getSession();
	String type = null;
	if (session.getAttribute(Constants.REQUEST_TYPE) != null) {
		type = (String) session.getAttribute(Constants.REQUEST_TYPE);
	}
	if (type != null) {
		if (Constants.REGISTRATION.equals(type)) {
			return registration(provider);
		} else if (Constants.IMPORT_CONTACTS.equals(type)) {
			return importContacts(provider);
		} else if (Constants.SHARE.equals(type)) {
			return new ModelAndView("shareForm", "connectedProvidersIds",
					manager.getConnectedProvidersIds());
		}
	}

	return null;
}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:24,代碼來源:SuccessController.java

示例5: shareForm

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
@RequestMapping(value = "/shareForm")
public ModelAndView shareForm(final HttpServletRequest request) {
	logger.info("Showing share form");
	HttpSession session = request.getSession();
	session.setAttribute(Constants.REQUEST_TYPE, Constants.SHARE);
	SocialAuthManager manager = socialAuthTemplate.getSocialAuthManager();
	List<String> connectedProvidersIds = new ArrayList<String>();
	if (manager != null) {
		connectedProvidersIds = manager.getConnectedProvidersIds();
	}

	ModelAndView modelAndView = new ModelAndView("shareForm",
			"connectedProvidersIds", connectedProvidersIds);
	return modelAndView;

}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:17,代碼來源:HomeController.java

示例6: getSocialAuthManager

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
/**
 * gets thread safe social auth manager - current solution: each call
 * produces a new instance
 */
@Override
public SocialAuthManager getSocialAuthManager()
		throws SASFSecurityException {
	try {
		SocialAuthManager socialAuthManager = new SocialAuthManager();
		socialAuthManager.setSocialAuthConfig(this.socialAuthConfig);
		return socialAuthManager;
	} catch (Exception e) {
		throw new SASFSecurityException(e);
	}
}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:16,代碼來源:DefaultSASFSocialAuthManager.java

示例7: getProfile

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
@Override
public Profile getProfile() {
	Profile profile = null;
	SocialAuthManager manager = getAuthManager();
	if (manager != null) {
		try {
			AuthProvider provider = manager.getCurrentAuthProvider();
			profile = provider.getUserProfile();

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	return profile;
}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:16,代碼來源:DefaultSASFHelper.java

示例8: getContactList

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
@Override
public List<Contact> getContactList() {
	List<Contact> contactsList = null;
	SocialAuthManager manager = getAuthManager();
	if (manager != null) {
		contactsList = new ArrayList<Contact>();
		try {
			AuthProvider provider = manager.getCurrentAuthProvider();
			contactsList = provider.getContactList();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	return contactsList;
}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:16,代碼來源:DefaultSASFHelper.java

示例9: init

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
public void init() {
	id = null;
	provider = null;
	config = new SocialAuthConfig();
	try {
		config.load();
		manager = new SocialAuthManager();
		manager.setSocialAuthConfig(config);
	} catch (Exception e) {
		e.printStackTrace();
	}

}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:14,代碼來源:SocialAuth.java

示例10: callback

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
private void callback(final HttpServletRequest request) {
	SocialAuthManager m = socialAuthTemplate.getSocialAuthManager();
	if (m != null) {
		try {
			AuthProvider provider = m.connect(SocialAuthUtil
					.getRequestParametersMap(request));
			LOG.debug("Connected Provider : " + provider.getProviderId());
		} catch (Exception e) {
			e.printStackTrace();
		}
	} else {
		LOG.debug("Unable to connect provider because SocialAuthManager object is null.");
	}
}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:15,代碼來源:SocialAuthWebController.java

示例11: execute

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
/**
 * Update status for the given provider.
 * 
 * @return String where the action should flow
 * @throws Exception
 *             if an error occurs
 */
@Action(value = "/socialAuthUpdateStatusAction")
public String execute() throws Exception {

	if (statusMessage == null || statusMessage.trim().length() == 0) {
		request.setAttribute("Message", "Status can't be left blank.");
		return "failure";
	}
	SASFHelper helper = SASFStaticHelper.getHelper(request);
	SocialAuthManager manager = helper.getAuthManager();
	AuthProvider provider = null;
	if (manager != null) {
		provider = manager.getCurrentAuthProvider();
	}
	if (provider != null) {
		try {
			provider.updateStatus(statusMessage);
			request.setAttribute("Message", "Status Updated successfully");
			return "success";
		} catch (SocialAuthException e) {
			request.setAttribute("Message", e.getMessage());
			e.printStackTrace();
		}
	}
	return "failure";

}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:34,代碼來源:SocialAuthUpdateStatusAction.java

示例12: share

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
@RequestMapping(value = "/share", method = RequestMethod.POST)
public ModelAndView share(
		@RequestParam(value = "message", required = true) final String message,
		final HttpServletRequest request) {
	logger.info("Showing share form");
	HttpSession session = request.getSession();
	session.setAttribute(Constants.REQUEST_TYPE, Constants.SHARE);
	SocialAuthManager manager = socialAuthTemplate.getSocialAuthManager();
	List<String> connectedProvidersIds = new ArrayList<String>();
	if (manager != null) {
		connectedProvidersIds = manager.getConnectedProvidersIds();
	}
	String providerIds = null;
	for (String id : connectedProvidersIds) {
		try {
			AuthProvider provider = manager.getProvider(id);
			provider.updateStatus(message);
			if (providerIds == null) {
				providerIds = provider.getProviderId();
			} else {
				providerIds += ", " + provider.getProviderId();
			}
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
	}
	ModelAndView modelAndView = new ModelAndView("shareForm");
	modelAndView.addObject("connectedProvidersIds", connectedProvidersIds);
	if (providerIds != null) {
		String str = "Status is updated on " + providerIds;
		if (providerIds.indexOf(',') != -1) {
			str += " providers.";
		} else {
			str += " provider.";
		}
		modelAndView.addObject("message", str);
	}
	return modelAndView;

}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:41,代碼來源:HomeController.java

示例13: setAuthManager

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
@Override
public void setAuthManager(final SocialAuthManager socialAuthManager) {
	this.session.setAttribute(
			DefaultSASFHelper.SESSION_SOCIAL_AUTH_MANAGER,
			socialAuthManager);
}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:7,代碼來源:DefaultSASFHelper.java

示例14: getAuthManager

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
@Override
public SocialAuthManager getAuthManager() {
	return (SocialAuthManager) this.getSession().getAttribute(
			DefaultSASFHelper.SESSION_SOCIAL_AUTH_MANAGER);
}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:6,代碼來源:DefaultSASFHelper.java

示例15: doFilter

import org.brickred.socialauth.SocialAuthManager; //導入依賴的package包/類
public void doFilter(final HttpServletRequest req,
		final HttpServletResponse res, final FilterChain fc)
		throws Exception {
	SASFHelper h = new DefaultSASFHelper(req, this.props,
			this.sdbSocialAuthManager, req.getSession());
	String path = lookupPath(req);
	if (path != null && path.startsWith(h.getServletMain())) {
		try {
			if (path.equals(h.getServletSuccess())) {
				SocialAuthManager manager = h.getAuthManager();
				AuthProvider provider = manager.connect(SocialAuthUtil
						.getRequestParametersMap(req));
				h.setProvider(provider);
				res.sendRedirect(h.getWebappSuccessAction());
				return;
			} else {
				String id = req.getParameter("id");
				SocialAuthManager socialAuthManager = null;
				synchronized (req.getSession()) {
					if (h.getAuthManager() != null) {
						socialAuthManager = h.getAuthManager();
					} else {
						socialAuthManager = h.getMgr()
								.getSocialAuthManager();
						h.setAuthManager(socialAuthManager);
					}
				}

				res.sendRedirect(socialAuthManager.getAuthenticationUrl(id,
						h.getOpenidReturnUrl()));
				return;

			}
		} catch (Throwable t) {
			h.setError(t.getMessage(), t);
			res.sendRedirect(h.getErrorPage());
			return;
		}
	}
	if (!res.isCommitted()) {
		fc.doFilter(req, res);
	}
}
 
開發者ID:3pillarlabs,項目名稱:socialauth,代碼行數:44,代碼來源:SocialAuthSecurityFilter.java


注:本文中的org.brickred.socialauth.SocialAuthManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。