Revision 80:647ee4e00dc1

View differences:

src/main/java/my/com/upass/MinimalUPassControllerV2.java
807 807
		return null;
808 808
	}
809 809

  
810
	public Character getAppAccessType(
811
			String username, Integer appId, final Session txSession) {
812

  
813
		return appAccessMgtService.getAppAccessType(username, appId, txSession);
814
	}
815

  
810 816
	public List/* <UserProfile> */listProfilesByExamples(
811 817
			String appAccessId, String hashedSecretKey,
812 818
			List/* <UserProfile> */exampleProfiles, Session txSession)
src/main/java/my/com/upass/maybank/MinimalMaybankFacade.java
1 1
package my.com.upass.maybank;
2 2

  
3

  
4 3
public interface MinimalMaybankFacade {
5 4

  
6 5
	int authenticateUser(
......
31 30
	Response lookupUsername_internal(
32 31
			String appAccessId, String hashedSecretKey, String username);
33 32

  
33
	Response lookupUsername_internal(
34
			String appAccessId, String hashedSecretKey,
35
			String username, Integer appId);
36

  
34 37
	Response lookupPublicUsername_internal(
35 38
			String appAccessId, String hashedSecretKey, String username);
36 39

  
src/main/java/my/com/upass/maybank/MinimalMaybankFacadeImpl.java
1 1
package my.com.upass.maybank;
2 2

  
3
import java.util.Iterator;
3 4
import java.util.LinkedList;
4 5
import java.util.List;
5 6
import java.util.Map;
......
89 90
	public Response lookupUsername_internal(
90 91
			String appAccessId, String hashedSecretKey, String username) {
91 92

  
93
		return lookupUsername_internal(appAccessId, hashedSecretKey, username, null);
94
	}
95

  
96
	public Response lookupUsername_internal(
97
			String appAccessId, String hashedSecretKey,
98
			String username, Integer appId) {
99

  
92 100
		Response res = new Response();
93 101
		Session session = null;
94 102
		try {
95 103
			session = HibernateUtils.currentSession();
96 104

  
97 105
			UserProfile profile = minUpcV2.findProfile(
98
					appAccessId, hashedSecretKey, username, session);
106
					appAccessId, hashedSecretKey, username, appId, session);
99 107

  
100 108
			if (profile != null) {
101 109
				final Map map = profile.propertiesToMap();
102 110
				res.setMap(map);
103 111
				res.setCode(MinimalConstants.ERR_SUCCESS);
104 112

  
113
				if (appId != null)
114
					map.put("accessType", minUpcV2.getAppAccessType(username, appId, session));
115

  
105 116
			} else {
106 117
				res.setCode(MinimalConstants.ERR_USERALIAS_NOT_FOUND);
107 118
			}
src/main/java/my/com/upass/services/AppAccessMgtService.java
129 129
		return appId;
130 130
	}
131 131

  
132
	public List/* <Integer> */listAppIdsForUser(String username, Session txSession)
133
			throws MultipleAppAccessesFound {
132
	public List/* <Integer> */listAppIdsForUser(String username, Session txSession) {
134 133

  
135 134
		List appIds = new ArrayList(5);
136 135
		try {
......
163 162
		return appIds;
164 163
	}
165 164

  
165
	public Character getAppAccessType(String username, Integer appId, Session txSession) {
166
		try {
167
			UserDAO userDao = MinimalDAOFactory.minimalInstance().getUserDAO();
168

  
169
			List accessList = userDao.listUserAppAccesses(username, txSession);
170
			for (Iterator iterator = accessList.iterator(); iterator.hasNext();) {
171
				UserAppAccess access = (UserAppAccess) iterator.next();
172
				if (access.getAppId() == appId.intValue())
173
					return new Character(access.getAccessType());
174
			}
175
		} catch (Exception e) {
176
			e.printStackTrace();
177
		}
178
		return null;
179
	}
180

  
166 181
	public boolean grantAppAccessToUser(
167 182
			long userId, int applicationId, char accessType, Session txSession) {
168 183

  

Also available in: Unified diff