*@return Map with the result of the service, the output parameters
*/
public static Map<String, Object> createUserLogin(DispatchContext ctx, Map<String, ?> context) {
Map<String, Object> result = FastMap.newInstance();
Delegator delegator = ctx.getDelegator();
Security security = ctx.getSecurity();
GenericValue loggedInUserLogin = (GenericValue) context.get("userLogin");
List<String> errorMessageList = FastList.newInstance();
Locale locale = (Locale) context.get("locale");
boolean useEncryption = "true".equals(UtilProperties.getPropertyValue("security.properties", "password.encrypt"));
String userLoginId = (String) context.get("userLoginId");
String partyId = (String) context.get("partyId");
String currentPassword = (String) context.get("currentPassword");
String currentPasswordVerify = (String) context.get("currentPasswordVerify");
String enabled = (String) context.get("enabled");
String passwordHint = (String) context.get("passwordHint");
String requirePasswordChange = (String) context.get("requirePasswordChange");
String externalAuthId = (String) context.get("externalAuthId");
String errMsg = null;
// security: don't create a user login if the specified partyId (if not empty) already exists
// unless the logged in user has permission to do so (same partyId or PARTYMGR_CREATE)
if (UtilValidate.isNotEmpty(partyId)) {
GenericValue party = null;
try {
party = delegator.findOne("Party", false, "partyId", partyId);
} catch (GenericEntityException e) {
Debug.logWarning(e, "", module);
}
if (party != null) {
if (loggedInUserLogin != null) {
// <b>security check</b>: userLogin partyId must equal partyId, or must have PARTYMGR_CREATE permission
if (!partyId.equals(loggedInUserLogin.getString("partyId"))) {
if (!security.hasEntityPermission("PARTYMGR", "_CREATE", loggedInUserLogin)) {
errMsg = UtilProperties.getMessage(resource,"loginservices.party_with_specified_party_ID_exists_not_have_permission", locale);
errorMessageList.add(errMsg);
}
}