moto web application
リビジョン | e5039c95fa634af9a3230543b8368f16de196565 (tree) |
---|---|
日時 | 2014-02-07 18:26:09 |
作者 | astoria-d <astoria-d@mail...> |
コミッター | astoria-d |
google account supported.
@@ -20,6 +20,7 @@ import org.openid4java.discovery.DiscoveryException; | ||
20 | 20 | |
21 | 21 | import java.io.IOException; |
22 | 22 | import java.util.List; |
23 | + import java.util.Map; | |
23 | 24 | |
24 | 25 | import javax.servlet.http.HttpSession; |
25 | 26 |
@@ -32,7 +33,10 @@ public class OpenIdBean implements Serializable { | ||
32 | 33 | @Inject |
33 | 34 | private FacesContext context; |
34 | 35 | |
35 | - | |
36 | + private String openid; | |
37 | + public void setOpenid (String openid) { this.openid = openid; } | |
38 | + public String getOpenid () { return openid; } | |
39 | + | |
36 | 40 | private static ConsumerManager consumerManager; |
37 | 41 | public static ConsumerManager getConsumerManager() { |
38 | 42 | // try { |
@@ -89,11 +93,26 @@ public class OpenIdBean implements Serializable { | ||
89 | 93 | return ret; |
90 | 94 | } |
91 | 95 | |
92 | - public void yahooLogin() { | |
93 | - log.info("yahoo log in!"); | |
96 | + public void doLogin() { | |
97 | + | |
98 | + String userSuppliedIdentifier; | |
99 | + | |
100 | + Map map = context.getExternalContext().getRequestParameterMap(); | |
101 | + String loginTo = (String) map.get("loginTo"); | |
102 | + log.info("loginTo: " + loginTo); | |
103 | + | |
104 | + if (loginTo.equals("yahoo")) { | |
105 | + userSuppliedIdentifier = "yahoo.co.jp"; | |
106 | + } | |
107 | + else if (loginTo.equals("google")) { | |
108 | + userSuppliedIdentifier = "https://www.google.com/accounts/o8/id"; | |
109 | + } | |
110 | + else { | |
111 | + userSuppliedIdentifier = openid; | |
112 | + } | |
113 | + //log.info("yahoo log in!"); | |
94 | 114 | |
95 | 115 | // Delegate to Open ID code |
96 | - String userSuppliedIdentifier = "yahoo.co.jp"; | |
97 | 116 | String returnToUrl = getReturnUrl(); |
98 | 117 | /* |
99 | 118 | */ |
@@ -76,6 +76,7 @@ | ||
76 | 76 | <fileset dir="${faceletsrc}"> |
77 | 77 | <include name="javascript/*.js"/> |
78 | 78 | <include name="**/*.html"/> |
79 | + <include name="**/*.png"/> | |
79 | 80 | <include name="**/*.xhtml"/> |
80 | 81 | <include name="**/*.properties"/> |
81 | 82 | </fileset> |
@@ -28,8 +28,23 @@ password : <h:inputSecret value="#{userBean.pwd}"/> | ||
28 | 28 | Open ID log in: |
29 | 29 | <br /> |
30 | 30 | <h:form> |
31 | - <h:commandLink action="#{openIdBean.yahooLogin}"> | |
31 | + <h:commandLink action="#{openIdBean.doLogin}"> | |
32 | 32 | <img src="http://i.yimg.jp/images/login/btn/btnXSYid.gif" width="241" height="28" alt="Yahoo! JAPAN IDでログイン" border="0" /> |
33 | + <f:param name="loginTo" value="yahoo" /> | |
34 | + </h:commandLink> | |
35 | + | |
36 | +<br /> | |
37 | + | |
38 | + <h:commandLink action="#{openIdBean.doLogin}"> | |
39 | + <img src="img/Red-signin-Long-press-44dp.png" alt="Google Accountでログイン" border="0" /> | |
40 | + <f:param name="loginTo" value="google" /> | |
41 | + </h:commandLink> | |
42 | + | |
43 | +<br /> | |
44 | + | |
45 | + <h:inputText value="#{openIdBean.openid}" /> | |
46 | + <h:commandLink action="#{openIdBean.doLogin}" value="ELSE" > | |
47 | + <f:param name="loginTo" value="else" /> | |
33 | 48 | </h:commandLink> |
34 | 49 | </h:form> |
35 | 50 |