1 |
1 |
package my.com.upass.maybank;
|
2 |
2 |
|
|
3 |
import java.util.UUID;
|
|
4 |
|
|
5 |
import javax.annotation.security.DeclareRoles;
|
|
6 |
import javax.annotation.security.RolesAllowed;
|
|
7 |
import javax.servlet.http.HttpServletRequest;
|
3 |
8 |
import javax.ws.rs.GET;
|
4 |
9 |
import javax.ws.rs.Path;
|
5 |
10 |
import javax.ws.rs.Produces;
|
6 |
11 |
import javax.ws.rs.QueryParam;
|
|
12 |
import javax.ws.rs.core.Context;
|
7 |
13 |
import javax.ws.rs.core.MediaType;
|
8 |
14 |
|
9 |
15 |
import my.com.upass.MinimalConstants;
|
10 |
16 |
import my.com.upass.util.MapWrapper;
|
11 |
17 |
|
|
18 |
@DeclareRoles("UPassRoot")
|
12 |
19 |
@Path("/MaybankFacade")
|
13 |
20 |
public class RESTfulMaybankFacade {
|
14 |
21 |
|
15 |
22 |
private MaybankFacade maybankFacade;
|
16 |
|
|
|
23 |
|
17 |
24 |
public RESTfulMaybankFacade() {
|
18 |
25 |
maybankFacade = new MaybankFacadeImpl();
|
19 |
26 |
}
|
20 |
|
|
|
27 |
|
21 |
28 |
@GET
|
22 |
29 |
@Path("/authenticateUser")
|
23 |
30 |
@Produces("text/plain")
|
... | ... | |
26 |
33 |
@QueryParam("hashedSecretKey") String hashedSecretKey,
|
27 |
34 |
@QueryParam("username") String username,
|
28 |
35 |
@QueryParam("hashedPassword") String hashedPassword) {
|
29 |
|
|
|
36 |
|
30 |
37 |
return String.valueOf(maybankFacade.authenticateUser(appAccessId, hashedSecretKey, username, hashedPassword));
|
31 |
38 |
}
|
32 |
|
|
|
39 |
|
33 |
40 |
@GET
|
34 |
41 |
@Path("/newTicketingUser")
|
35 |
42 |
@Produces("text/plain")
|
... | ... | |
39 |
46 |
@QueryParam("username") String username,
|
40 |
47 |
@QueryParam("hashedPassword") String hashedPassword,
|
41 |
48 |
@QueryParam("payeeCode") String payeeCode) {
|
42 |
|
|
43 |
|
return String.valueOf(maybankFacade.newTicketingUser(appAccessId, hashedSecretKey, username, hashedPassword, "", "", "", payeeCode));
|
|
49 |
|
|
50 |
return String.valueOf(maybankFacade.newTicketingUser(
|
|
51 |
appAccessId, hashedSecretKey, username, hashedPassword, "", "", "", payeeCode));
|
44 |
52 |
}
|
45 |
|
|
|
53 |
|
46 |
54 |
@GET
|
47 |
55 |
@Path("/deleteUser")
|
48 |
56 |
@Produces("text/plain")
|
... | ... | |
50 |
58 |
@QueryParam("appAccessId") String appAccessId,
|
51 |
59 |
@QueryParam("hashedSecretKey") String hashedSecretKey,
|
52 |
60 |
@QueryParam("username") String username) {
|
53 |
|
|
|
61 |
|
54 |
62 |
return String.valueOf(maybankFacade.deleteUser(appAccessId, hashedSecretKey, username));
|
55 |
63 |
}
|
56 |
|
|
|
64 |
|
57 |
65 |
@GET
|
58 |
66 |
@Path("/newIbccAdminUser")
|
59 |
67 |
@Produces("text/plain")
|
... | ... | |
62 |
70 |
@QueryParam("hashedSecretKey") String hashedSecretKey,
|
63 |
71 |
@QueryParam("username") String username,
|
64 |
72 |
@QueryParam("hashedPassword") String hashedPassword) {
|
65 |
|
|
|
73 |
|
66 |
74 |
return String.valueOf(maybankFacade.newIbccAdminUser(appAccessId, hashedSecretKey, username, hashedPassword));
|
67 |
75 |
}
|
68 |
|
|
|
76 |
|
69 |
77 |
@GET
|
70 |
78 |
@Path("/newIbccPublicUser")
|
71 |
79 |
@Produces("text/plain")
|
... | ... | |
75 |
83 |
@QueryParam("username") String username,
|
76 |
84 |
@QueryParam("hashedPassword") String hashedPassword,
|
77 |
85 |
@QueryParam("panCc") String panCc) {
|
78 |
|
|
79 |
|
return String.valueOf(maybankFacade.newIbccPublicUser(appAccessId, hashedSecretKey, username, hashedPassword, panCc));
|
|
86 |
|
|
87 |
return String.valueOf(maybankFacade.newIbccPublicUser(
|
|
88 |
appAccessId, hashedSecretKey, username, hashedPassword, panCc));
|
80 |
89 |
}
|
81 |
|
|
|
90 |
|
82 |
91 |
@GET
|
83 |
92 |
@Path("/lookupUsernameForApp")
|
84 |
93 |
@Produces(MediaType.APPLICATION_JSON)
|
... | ... | |
87 |
96 |
@QueryParam("hashedSecretKey") String hashedSecretKey,
|
88 |
97 |
@QueryParam("username") String username,
|
89 |
98 |
@QueryParam("appId") String appId) {
|
90 |
|
|
|
99 |
|
91 |
100 |
return maybankFacade.lookupUsernameForApp(appAccessId, hashedSecretKey, username, new Integer(appId));
|
92 |
101 |
}
|
93 |
|
|
|
102 |
|
94 |
103 |
@GET
|
95 |
104 |
@Path("/lookupIbccWithM2U")
|
96 |
105 |
@Produces(MediaType.APPLICATION_JSON)
|
... | ... | |
100 |
109 |
@QueryParam("username") String username,
|
101 |
110 |
@QueryParam("ibccAppId") String ibccAppId,
|
102 |
111 |
@QueryParam("m2uAppId") String m2uAppId) {
|
103 |
|
|
104 |
|
ResponseElement responseElement = maybankFacade.lookupUsernameForApp(appAccessId, hashedSecretKey, username, new Integer(ibccAppId));
|
105 |
|
if(MinimalConstants.ERR_SUCCESS == responseElement.getCode()){
|
106 |
|
ResponseElement responseElement2 = maybankFacade.lookupUsernameForApp(appAccessId, hashedSecretKey, username, new Integer(m2uAppId));
|
107 |
|
if(MinimalConstants.ERR_SUCCESS == responseElement2.getCode()){
|
|
112 |
|
|
113 |
ResponseElement responseElement = maybankFacade.lookupUsernameForApp(
|
|
114 |
appAccessId, hashedSecretKey, username, new Integer(ibccAppId));
|
|
115 |
|
|
116 |
if (MinimalConstants.ERR_SUCCESS == responseElement.getCode()) {
|
|
117 |
ResponseElement responseElement2 = maybankFacade.lookupUsernameForApp(
|
|
118 |
appAccessId, hashedSecretKey, username, new Integer(m2uAppId));
|
|
119 |
|
|
120 |
if (MinimalConstants.ERR_SUCCESS == responseElement2.getCode()) {
|
108 |
121 |
responseElement.getMap().put("isOnlineBanking", "Y");
|
109 |
|
}else if(MinimalConstants.ERR_USERALIAS_NOT_FOUND == responseElement2.getCode()){
|
|
122 |
|
|
123 |
} else if (MinimalConstants.ERR_USERALIAS_NOT_FOUND == responseElement2.getCode()) {
|
110 |
124 |
responseElement.getMap().put("isOnlineBanking", "N");
|
111 |
125 |
}
|
112 |
126 |
}
|
113 |
|
|
114 |
127 |
return responseElement;
|
115 |
128 |
}
|
116 |
|
|
|
129 |
|
117 |
130 |
@GET
|
118 |
131 |
@Path("/searchUserByFilter")
|
119 |
132 |
@Produces(MediaType.APPLICATION_JSON)
|
... | ... | |
123 |
136 |
|
124 |
137 |
return maybankFacade.searchUserByFilter(appAccessId, hashedSecretKey, new MapWrapper());
|
125 |
138 |
}
|
126 |
|
|
|
139 |
|
127 |
140 |
@GET
|
128 |
141 |
@Path("/lookupPan1")
|
129 |
142 |
@Produces(MediaType.APPLICATION_JSON)
|
... | ... | |
131 |
144 |
@QueryParam("appAccessId") String appAccessId,
|
132 |
145 |
@QueryParam("hashedSecretKey") String hashedSecretKey,
|
133 |
146 |
@QueryParam("pan1") String pan1) {
|
134 |
|
|
|
147 |
|
135 |
148 |
return maybankFacade.lookupPan1(appAccessId, hashedSecretKey, pan1);
|
136 |
149 |
}
|
137 |
|
|
|
150 |
|
138 |
151 |
@GET
|
139 |
152 |
@Path("/lookupPan2")
|
140 |
153 |
@Produces(MediaType.APPLICATION_JSON)
|
... | ... | |
142 |
155 |
@QueryParam("appAccessId") String appAccessId,
|
143 |
156 |
@QueryParam("hashedSecretKey") String hashedSecretKey,
|
144 |
157 |
@QueryParam("pan2") String pan2) {
|
145 |
|
|
|
158 |
|
146 |
159 |
return maybankFacade.lookupPan2(appAccessId, hashedSecretKey, pan2);
|
147 |
160 |
}
|
148 |
|
|
|
161 |
|
149 |
162 |
@GET
|
150 |
163 |
@Path("/changePassword")
|
151 |
164 |
@Produces("text/plain")
|
... | ... | |
156 |
169 |
@QueryParam("oldHashedPassword") String oldHashedPassword,
|
157 |
170 |
@QueryParam("newHashedPassword") String newHashedPassword) {
|
158 |
171 |
|
159 |
|
return String.valueOf(maybankFacade.changePassword(appAccessId, hashedSecretKey, username, oldHashedPassword, newHashedPassword));
|
|
172 |
return String.valueOf(maybankFacade.changePassword(
|
|
173 |
appAccessId, hashedSecretKey, username, oldHashedPassword, newHashedPassword));
|
|
174 |
}
|
|
175 |
|
|
176 |
@GET
|
|
177 |
@Path("/generateUUID")
|
|
178 |
@Produces("text/plain")
|
|
179 |
@RolesAllowed("UPassRoot")
|
|
180 |
public String generateUUID_rest(@Context HttpServletRequest request) {
|
|
181 |
|
|
182 |
return UUID.randomUUID().toString();
|
160 |
183 |
}
|
161 |
184 |
}
|