本文整理汇总了Java中org.brickred.socialauth.AuthProvider类的典型用法代码示例。如果您正苦于以下问题:Java AuthProvider类的具体用法?Java AuthProvider怎么用?Java AuthProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthProvider类属于org.brickred.socialauth包,在下文中一共展示了AuthProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showWall
import org.brickred.socialauth.AuthProvider; //导入依赖的package包/类
@RequestMapping(value = "/showwall")
public ModelAndView showWall(
@RequestParam(value = "providerId", required = true) final String providerId,
final HttpServletRequest request) throws Exception {
InputStream is = getClass().getClassLoader().getResourceAsStream(
providerId + "_accessGrant_file.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
ObjectMapper mapper = new ObjectMapper();
AccessGrant accessGrant = mapper.readValue(sb.toString(),
AccessGrant.class);
AuthProvider provider = socialAuthManager.connect(accessGrant);
List<Feed> feeds = new ArrayList<Feed>();
if (provider
.isSupportedPlugin(org.brickred.socialauth.plugin.FeedPlugin.class)) {
FeedPlugin p = provider
.getPlugin(org.brickred.socialauth.plugin.FeedPlugin.class);
feeds = p.getFeeds();
}
ModelAndView view = new ModelAndView("showwall", "feeds", feeds);
return view;
}
示例2: execute
import org.brickred.socialauth.AuthProvider; //导入依赖的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";
}
示例3: getRedirectURL
import org.brickred.socialauth.AuthProvider; //导入依赖的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;
}
示例4: registration
import org.brickred.socialauth.AuthProvider; //导入依赖的package包/类
private ModelAndView registration(final AuthProvider provider)
throws Exception {
Profile profile = provider.getUserProfile();
if (profile.getFullName() == null) {
String name = null;
if (profile.getFirstName() != null) {
name = profile.getFirstName();
}
if (profile.getLastName() != null) {
if (profile.getFirstName() != null) {
name += " " + profile.getLastName();
} else {
name = profile.getLastName();
}
}
if (name == null && profile.getDisplayName() != null) {
name = profile.getDisplayName();
}
if (name != null) {
profile.setFullName(name);
}
}
ModelAndView view = new ModelAndView("registrationForm", "profile",
profile);
return view;
}
示例5: importContacts
import org.brickred.socialauth.AuthProvider; //导入依赖的package包/类
private ModelAndView importContacts(final AuthProvider provider)
throws Exception {
List<Contact> contactsList = new ArrayList<Contact>();
contactsList = provider.getContactList();
if (contactsList != null && contactsList.size() > 0) {
for (Contact p : contactsList) {
if (!StringUtils.hasLength(p.getFirstName())
&& !StringUtils.hasLength(p.getLastName())) {
p.setFirstName(p.getDisplayName());
}
}
}
ModelAndView view = new ModelAndView("showImportContacts", "contacts",
contactsList);
return view;
}
示例6: getCurrentProvider
import org.brickred.socialauth.AuthProvider; //导入依赖的package包/类
/**
* Returns the last authenticated provider. Please use the SocialAuth API to
* find out about the methods available in this interface
*
* @return Provider object
*/
private AuthProvider getCurrentProvider() {
if (currentProvider != null) {
return socialAuthManager.getProvider(currentProvider.toString());
} else {
return null;
}
}
示例7: getProfile
import org.brickred.socialauth.AuthProvider; //导入依赖的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;
}
示例8: getContactList
import org.brickred.socialauth.AuthProvider; //导入依赖的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;
}
示例9: callback
import org.brickred.socialauth.AuthProvider; //导入依赖的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.");
}
}
示例10: execute
import org.brickred.socialauth.AuthProvider; //导入依赖的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";
}
示例11: share
import org.brickred.socialauth.AuthProvider; //导入依赖的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;
}
示例12: getCurrentProvider
import org.brickred.socialauth.AuthProvider; //导入依赖的package包/类
/**
* Returns the last authenticated provider. Please use the SocialAuth API to
* find out about the methods available in this interface
*
* @return Provider object
*/
public AuthProvider getCurrentProvider() {
if (currentProvider != null) {
return socialAuthManager.getProvider(currentProvider.toString());
} else {
return null;
}
}
示例13: setProvider
import org.brickred.socialauth.AuthProvider; //导入依赖的package包/类
@Override
public void setProvider(final AuthProvider provider) {
this.session.setAttribute(
DefaultSASFHelper.SESSION_SOCIAL_AUTH_PROVIDER, provider);
}
示例14: getProvider
import org.brickred.socialauth.AuthProvider; //导入依赖的package包/类
@Override
public AuthProvider getProvider() {
return (AuthProvider) this.getSession().getAttribute(
DefaultSASFHelper.SESSION_SOCIAL_AUTH_PROVIDER);
}
示例15: doFilter
import org.brickred.socialauth.AuthProvider; //导入依赖的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);
}
}