Revision 44:7a7fb8fcfd6e src/my/com/upass/UPassControllerV2.java

View differences:

src/my/com/upass/UPassControllerV2.java
15 15
import java.util.Date;
16 16
import java.util.HashMap;
17 17

  
18
import my.com.upass.MinimalUPassControllerV2.AccessCheckResult;
18 19
import my.com.upass.factory.UPassFactory;
19 20
import my.com.upass.pojo.ClientApp;
20 21
import my.com.upass.services.ActivateUserService;
......
736 737
		if (rc != Constants.ERR_SUCCESS) {
737 738
			return rc;
738 739
		}
739
		rc = deleteUserService.deleteUser(userAlias);
740
		rc = deleteUserService.deleteUser(userAlias, null);
740 741
		logger.info("UA_DeleteUser - admin user alias: [" + userAlias + "] Return: " + rc);
741 742
		return rc;
742 743
	}
......
745 746
	 * Because of the ability to choose the target app,
746 747
	 * this method is meant for USS only.
747 748
	 * 
748
	 * @see #deleteUser(String, String, String, Session)
749
	 * @see #deleteUserWithTheProfile(String, String, String, Session)
749 750
	 */
750
	public int deleteUser(
751
	public int deleteUserWithTheProfile(
751 752
			String adminUsername, String adminPassword,
752
			String username, int targetAppId, Session txSession) {
753
			String username, int targetAppId, Session txSession)
754
			throws UPassException {
753 755

  
754 756
		int rc;
755 757
		try {
......
759 761
				rc = MinimalConstants.ERR_APP_SERV_NOT_PERMITTED;
760 762

  
761 763
			else {
762
				// rc = deleteUserService.deleteUser(username, targetAppId, txSession);
763
				throw new NotImplementedException();
764
				boolean revoked = appAccessMgtService.revokeAppAccessForUser(username, targetAppId, txSession);
765
				rc = revoked ?
766
						deleteUserService.deleteUser(username, targetAppId, txSession)
767
						: MinimalConstants.ERR_SYSTEM_NOT_READY;
764 768
			}
765

  
766 769
		} catch (MultipleAppAccessesFound e) {
767 770
			rc = MinimalConstants.ERR_APP_SERV_NOT_PERMITTED;
768 771
			e.printStackTrace();
769

  
770
		} catch (UPassException e) {
771
			rc = e.getErrorCode();
772
			e.printStackTrace();
773 772
		}
774 773
		logger.info("deleteUser - user alias: [" + username + "] Return: " + rc);
775 774
		return rc;
......
779 778
	 * This methods identifies the target app using <code>appAccessId</code>,
780 779
	 * hence meant for {@link ClientApp}s
781 780
	 * 
782
	 * @see #deleteUser(String, String, String, int, Session)
781
	 * @see #deleteUserWithTheProfile(String, String, String, int, Session)
783 782
	 */
784
	public int deleteUser(
783
	public int deleteUserWithTheProfile(
785 784
			String appAccessId, String hashedSecretKey,
786
			String username, Session txSession) {
785
			String username, Session txSession)
786
			throws UPassException {
787 787

  
788
		throw new NotImplementedException();
788
		int rc;
789
		try {
790
			AccessCheckResult checkResult = checkAppAccess(appAccessId, hashedSecretKey, txSession);
791

  
792
			final Integer targetAppId = checkResult.invokerAppId;
793
			if (targetAppId == null) {
794
				rc = MinimalConstants.ERR_APP_SERV_NOT_PERMITTED;
795

  
796
			} else {
797
				boolean revoked = appAccessMgtService.revokeAppAccessForUser(username, targetAppId, txSession);
798
				rc = revoked ?
799
						deleteUserService.deleteUser(username, targetAppId, txSession)
800
						: MinimalConstants.ERR_SYSTEM_NOT_READY;
801
			}
802
		} catch (MultipleAppAccessesFound e) {
803
			rc = MinimalConstants.ERR_APP_SERV_NOT_PERMITTED;
804
			e.printStackTrace();
805
		}
806
		logger.info("deleteUser - user alias: [" + username + "] Return: " + rc);
807
		return rc;
789 808
	}
790 809

  
791 810
	// ///////////////////////////////////////////////////////////////////////////////
......
1218 1237
	 *         ERR_INVALID_USERALIAS - User alias does not match with defined pattern <br/>
1219 1238
	 *         ERR_PASSWORD_SAMEAS_USERALIAS - password is same is user name error <br/>
1220 1239
	 */
1221
	public int AD_AddUser(String rootAlias, String rootPassword, String adminUserAlias,
1222
			String adminDesc, String adminUserPassword) {
1240
	public int AD_AddUser(
1241
			String rootAlias, String rootPassword,
1242
			String adminUserAlias, String adminDesc, String adminUserPassword) {
1243

  
1223 1244
		// check if password is similar to user alias
1224 1245
		if (rootAlias.equalsIgnoreCase(rootPassword)) {
1225 1246
			return MinimalConstants.ERR_PASSWORD_SAMEAS_USERALIAS;
1226 1247
		}
1227

  
1228 1248
		int rc = verifyStaticPasswordService.verifyStaticPassword(
1229 1249
				rootAlias, rootPassword, true, MinimalConstants.UTYPE_STATE_ROOT);
1230 1250

  
1231
		if (rc != MinimalConstants.ERR_SUCCESS)
1232
		{
1251
		if (rc != MinimalConstants.ERR_SUCCESS) {
1233 1252
			return rc;
1234 1253
		}
1235

  
1236 1254
		rc = createUserService.addUser(adminUserAlias,
1237 1255
				MinimalConstants.UTYPE_STATE_ADMIN, adminDesc, adminUserPassword,
1238 1256
				MinimalConstants.UID_STATE_ACTIVE, MinimalConstants.SYSTEM_ID);
1239 1257

  
1240
		logger.info("AD_AddUser - admin user alias: [" + adminUserAlias
1241
				+ "] Return: " + rc);
1258
		logger.info("AD_AddUser - admin user alias: [" + adminUserAlias + "] Return: " + rc);
1242 1259

  
1243 1260
		return rc;
1244 1261
	}
1245

  
1246 1262
}

Also available in: Unified diff