diff -r b64d87c6b708 -r 2ec454f2a9ad reset-pass/account-validator-api/pom.xml --- a/reset-pass/account-validator-api/pom.xml Thu Sep 04 15:06:44 2014 +0800 +++ b/reset-pass/account-validator-api/pom.xml Thu Sep 04 15:08:54 2014 +0800 @@ -41,6 +41,13 @@ + ${basedir}/src/bundle + + **/*.xml + + false + + ${basedir}/src/java **/*.xml diff -r b64d87c6b708 -r 2ec454f2a9ad reset-pass/account-validator-api/src/bundle/validate_existingUser.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reset-pass/account-validator-api/src/bundle/validate_existingUser.xml Thu Sep 04 15:08:54 2014 +0800 @@ -0,0 +1,69 @@ + + + validate.existinguser + + Please Validate your ${localSakaiName} Account + Dear ${displayName}, + +You currently have a guest account on ${localSakaiName} with access to the following sites: + +${memberSites} + +If you still require access to these sites using your current login details ${userEid}, +or if you would like to access these sites through your staff/student account or another guest, please follow this link to: ${url} + +If you no longer require access to ${localSakaiName} using this login, simply ignore this email and your account will be deactivated. +If you wish to reactivate your account, please contact ${localSupportMail}. + +*Please note*: Accounts that have been deactivated for longer than 90 days will be deleted. + + + <p>Dear ${displayName}<p> + +<p>You currently have a guest account on ${localSakaiName} with access to the following sites: <br/> + +${memberSites} +</p> + +<p>If you still require access to these sites using your current login details ${userEid}, or if you would like to access these sites through your staff/student account or another guest, please follow this <a href="${url}">link</a></p> + +</p>If you no longer require access to ${localSakaiName} using this login, simply ignore this email and your account will be deactivated. If you wish to reactivate your account, please contact ${supportemail} </p> + +<p><strong>Please note</strong>: Accounts that have been deactivated for longer than 90 days will be deleted.</p> + + + + 请验证您的 ${localSakaiName} 帐号 + ${displayName},您好: + +您在 ${localSakaiName} 上有一个关联下列站点的帐号: + +${memberSites} + +如果您依旧希望使用当前帐号 ${userEid} 访问这些站点,或者您希望通过您的教师/学生帐号或其他访客帐号,请点击此链接:${url} + +如果您不再需要通过此帐号访问 ${localSakaiName},请忽略此邮件,您的帐号将失效。如果您希望重新启用您的帐号,请咨询 ${localSupportMail}。 + +*请注意*: 超过90天的失效帐号将被删除。 + + + +${displayName},您好:

+ +

您在 ${localSakaiName} 上有一个关联下列站点的帐号:
+ +${memberSites} +

+ +

如果您依旧希望使用当前帐号 ${userEid} 访问这些站点,或者您希望通过您的教师/学生帐号或其他访客帐号,请点击此链接

+ + + +

请注意: 超过90天的失效帐号将被删除。

+]]> +
+ zh_CN +
+ +
diff -r b64d87c6b708 -r 2ec454f2a9ad reset-pass/account-validator-api/src/bundle/validate_legacyUser.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reset-pass/account-validator-api/src/bundle/validate_legacyUser.xml Thu Sep 04 15:08:54 2014 +0800 @@ -0,0 +1,51 @@ + + + validate.legacyuser + + Please verify your details for ${localSakaiName} + +Dear ${displayName}, + +${addedBy} (${addedByEmail}) invited you to join ${localSakaiName}. + +Please confirm your details on ${url} + +What is ${localSakaiName}? +${localSakaiName} is the ${institution}'s web-based learning management system. It is home to many course sites, as well as a host of other sites including those +used for administration, research and project groups, libraries, and student societies. As a guest user, you have been invited to join a ${localSakaiName} site. +On the site you will have rights to read content but you also may be able to create and/or edit content (depending on your assigned role). + +What if I already have another ${localSakaiName} account? +If you have used ${localSakaiName} with another ${localSakaiName} account, we strongly suggest that you accept the above invitation and then +indicate which existing ${localSakaiName} account you wish to use to access this site. This will avoid you having multiple accounts, each with a different set of +associated sites. If you do not choose to associate this site with an existing account, a new guest account will be created for you using this email +address. In the future, login to ${localSakaiName} using the guest account username and its associated password. + + + + + + 请确认您在 ${localSakaiName}的相关信息 + +${displayName},您好: + +${addedBy} (${addedByEmail}) 邀请您加入 ${localSakaiName}。 + +请在 ${url} 确定您的相关信息 + +${localSakaiName} 是什么? +${localSakaiName} 是 ${institution} 的学习管理系统。其中包含了很多课程站点、 +管理站点、研究小组、图书馆以及学生社群。作为访客,您被邀请加入一个 ${localSakaiName} 站点。 +在此站点中,您可以浏览相关材料,您或许也可以创建或编辑相关材料(这取决于您被赋予的角色)。 + +如果我已经有 ${localSakaiName} 帐号了,该怎么办? +如果您曾使用另一个帐号登录过 ${localSakaiName},我们强烈建议您接受上面的邀请, +然后指定您准备使用哪个 ${localSakaiName} 帐号。这可以避免您使用多个帐号, +而每个帐号关联着不同的站点的情况。如果您不将此站点关联到已有帐号,那么将会为您创建新访客帐号, +并以此email地址为用户名。今后,您可以使用这个访客帐号及相关密码访问 ${localSakaiName} 。 + + zh_CN + + + + diff -r b64d87c6b708 -r 2ec454f2a9ad reset-pass/account-validator-api/src/bundle/validate_newPassword.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reset-pass/account-validator-api/src/bundle/validate_newPassword.xml Thu Sep 04 15:08:54 2014 +0800 @@ -0,0 +1,41 @@ + + + validate.passwordreset + + ${localSakaiName}: Password Reset Request + + You have requested to reset the password for your ${localSakaiName} account (${userEid}). + + Please use the following link to reset your password on ${localSakaiName}: + + ${url} + + For security purposes, this link is only valid for a limited time. + + If you did not request this change, please ignore this message. + + Regards, + + The ${localSakaiName} Administrators + ${institution} + + + + + + ${localSakaiName}:密码重置申请 + ${displayName},您好: +请使用下面的链接来重置您在 ${localSakaiName} 的账号(${userEid})密码: + +${url} + +基于安全性考量,此链接将在不久后失效。 + +如果您不需要修改密码,请忽略此信息。 + +${localSakaiName} 系统管理员 +${institution} + + zh_CN + + diff -r b64d87c6b708 -r 2ec454f2a9ad reset-pass/account-validator-api/src/bundle/validate_newUser.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reset-pass/account-validator-api/src/bundle/validate_newUser.xml Thu Sep 04 15:08:54 2014 +0800 @@ -0,0 +1,92 @@ + + + validate.newUser + + Welcome To ${localSakaiName}! + You have been invited to one or more sites in {localSakaiName}. + +Accept this invitation: + +${url} + +What is ${localSakaiName}? +${localSakaiName} is the ${institution}'s web-based learning management system. It is home to many course sites, +as well as a host of other sites including those used for administration, research and project groups, libraries, +and student societies. As a guest user, you have been invited to join a ${localSakaiName} site. On the site, you +will have rights to read content. You may also be able to create and/or edit content (depending on your assigned role). + +What if I already have a ${localSakaiName} account? +If you have used ${localSakaiName} in the past, then you already have an account on ${localSakaiName}. +We strongly suggest that you accept the above invitation and then +transfer your memberships to your existing ${localSakaiName} account. This +will help prevent you from having multiple accounts, each with a different set of +associated sites. + +If you do not choose to associate this site with an existing account, +a new guest account will be activated for you, and its login ID will be ${userEid}. +Afterwards, you may log in to ${localSakaiName} using ${userEid} as your login ID and its associated password. + <p>You have been invited to one or more sites in ${localSakaiName}.</p> + +<p><a href="${url}">Accept this invitation</a></p> + +<h2>What is ${localSakaiName}?</h2> +<p>${localSakaiName} is the ${institution}'s web-based learning management system. It is home to many course sites, +as well as a host of other sites including those used for administration, research and project groups, libraries, +and student societies. As a guest user, you have been invited to join a ${localSakaiName} site. On the site, you will +have rights to read content but you also may be able to create and/or edit content (depending on your assigned role).</p> + +<h2>What if I already have a ${localSakaiName} account?</h2> +<p>If you have used ${localSakaiName} in the past, then you already have an account on ${localSakaiName}. +We strongly suggest that you accept the above invitation and then +transfer your memberships to your existing ${localSakaiName} account. This +will help prevent you from having multiple accounts, each with a different set of +associated sites. </p> + +<p>If you do not choose to associate this site with an existing account, +a new guest account will be activated for you, and its login ID will be ${userEid}. +Afterwards you may log in to ${localSakaiName} using ${userEid} as your login ID and its associated password. </p> + + + + + 欢迎加入 ${localSakaiName} ! + ${addedBy} (${addedByEmail}) 邀请您加入 ${localSakaiName} 中的 ${memberSites} 站点。 + +您可以通过下面的地址接受邀请: +${url} + +${localSakaiName} 是什么? +${localSakaiName} 是 ${institution} 的学习管理系统。其中包含了很多课程站点、 +管理站点、研究小组、图书馆以及学生社群。作为访客,您被邀请加入一个 ${localSakaiName} 站点。 +在此站点中,您可以浏览相关材料,您或许也可以创建或编辑相关材料(这取决于您被赋予的角色)。 + +如果我已经有 ${localSakaiName} 帐号了,该怎么办? +如果您曾使用过 ${localSakaiName},那么您已经拥有了一个 ${localSakaiName} 帐号。 +如此,我们强烈建议您接受上面的邀请,然后指定您准备使用哪个 ${localSakaiName} 帐号。 +这可以避免您使用多个帐号,而每个帐号关联着不同的站点的情况。如果您不将此站点关联到已有帐号, +那么将会为您创建新访客帐号,并以此email地址为用户名。今后,您可以使用这个访客帐号及相 +关密码访问 ${localSakaiName} 。 + + +${addedBy} (${addedByEmail}) 邀请您加入 ${localSakaiName} 中的 ${memberSites} 站点。

+ +

您可以通过 ${url} 接受本邀请。

+ +

${localSakaiName} 是什么?

+

${localSakaiName} 是 ${institution} 的学习管理系统。其中包含了很多课程站点、 +管理站点、研究小组、图书馆以及学生社群。作为访客,您被邀请加入一个 ${localSakaiName} 站点。 +在此站点中,您可以浏览相关材料,您或许也可以创建或编辑相关材料(这取决于您被赋予的角色)。

+ +

如果我已经有 ${localSakaiName} 帐号了,该怎么办?

+

如果您曾使用过 ${localSakaiName},那么您已经拥有了一个 ${localSakaiName} 帐号。 +如此,我们强烈建议您接受上面的邀请,然后指定您准备使用哪个 ${localSakaiName} 帐号。 +这可以避免您使用多个帐号,而每个帐号关联着不同的站点的情况。如果您不将此站点关联到已有帐号, +那么将会为您创建新访客帐号,并以此email地址为用户名。今后,您可以使用这个访客帐号及相 +关密码访问 ${localSakaiName} 。

+]]> +
+ zh_CN +
+ +
diff -r b64d87c6b708 -r 2ec454f2a9ad reset-pass/account-validator-impl/pom.xml --- a/reset-pass/account-validator-impl/pom.xml Thu Sep 04 15:06:44 2014 +0800 +++ b/reset-pass/account-validator-impl/pom.xml Thu Sep 04 15:08:54 2014 +0800 @@ -176,14 +176,6 @@ - ${basedir}/src/bundle - - **/*.properties - **/*.xml - - false - - ${basedir}/src/java **/*.xml diff -r b64d87c6b708 -r 2ec454f2a9ad reset-pass/account-validator-impl/src/bundle/validate_existingUser.xml --- a/reset-pass/account-validator-impl/src/bundle/validate_existingUser.xml Thu Sep 04 15:06:44 2014 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ - - - - Please Validate your ${localSakaiName} Account - Dear ${displayName}, - -You currently have a guest account on ${localSakaiName} with access to the following sites: - -${memberSites} - -If you still require access to these sites using your current login details ${userEid}, -or if you would like to access these sites through your staff/student account or another guest, please follow this link to: ${url} - -If you no longer require access to ${localSakaiName} using this login, simply ignore this email and your account will be deactivated. -If you wish to reactivate your account, please contact ${localSupportMail}. - -*Please note*: Accounts that have been deactivated for longer than 90 days will be deleted. - - - <p>Dear ${displayName}<p> - -<p>You currently have a guest account on ${localSakaiName} with access to the following sites: <br/> - -${memberSites} -</p> - -<p>If you still require access to these sites using your current login details ${userEid}, or if you would like to access these sites through your staff/student account or another guest, please follow this <a href="${url}">link</a></p> - -</p>If you no longer require access to ${localSakaiName} using this login, simply ignore this email and your account will be deactivated. If you wish to reactivate your account, please contact ${supportemail} </p> - -<p><strong>Please note</strong>: Accounts that have been deactivated for longer than 90 days will be deleted.</p> - - - - 请验证您的 ${localSakaiName} 帐号 - ${displayName},您好: - -您在 ${localSakaiName} 上有一个关联下列站点的帐号: - -${memberSites} - -如果您依旧希望使用当前帐号 ${userEid} 访问这些站点,或者您希望通过您的教师/学生帐号或其他访客帐号,请点击此链接:${url} - -如果您不再需要通过此帐号访问 ${localSakaiName},请忽略此邮件,您的帐号将失效。如果您希望重新启用您的帐号,请咨询 ${localSupportMail}。 - -*请注意*: 超过90天的失效帐号将被删除。 - - - <p>${displayName},您好:<p> - -<p>您在 ${localSakaiName} 上有一个关联下列站点的帐号: <br/> - -${memberSites} -</p> - -<p>如果您依旧希望使用当前帐号 ${userEid} 访问这些站点,或者您希望通过您的教师/学生帐号或其他访客帐号,请点击此<a href="${url}">链接</a></p> - -<p如果您不再需要通过此帐号访问 ${localSakaiName},请忽略此邮件,您的帐号将失效。如果您希望重新启用您的帐号,请咨询 ${localSupportMail}。 </p> - -<p><strong>请注意</strong>: 超过90天的失效帐号将被删除。</p> - zh_CN - - - diff -r b64d87c6b708 -r 2ec454f2a9ad reset-pass/account-validator-impl/src/bundle/validate_legacyUser.xml --- a/reset-pass/account-validator-impl/src/bundle/validate_legacyUser.xml Thu Sep 04 15:06:44 2014 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ - - - - Please verify your details for ${localSakaiName} - -Dear ${displayName}, - -${addedBy} (${addedByEmail}) invited you to join ${localSakaiName}. - -Please confirm your details on ${url} - -What is ${localSakaiName}? -${localSakaiName} is the ${institution}'s web-based learning management system. It is home to many course sites, as well as a host of other sites including those -used for administration, research and project groups, libraries, and student societies. As a guest user, you have been invited to join a ${localSakaiName} site. -On the site you will have rights to read content but you also may be able to create and/or edit content (depending on your assigned role). - -What if I already have another ${localSakaiName} account? -If you have used ${localSakaiName} with another ${localSakaiName} account, we strongly suggest that you accept the above invitation and then -indicate which existing ${localSakaiName} account you wish to use to access this site. This will avoid you having multiple accounts, each with a different set of -associated sites. If you do not choose to associate this site with an existing account, a new guest account will be created for you using this email -address. In the future, login to ${localSakaiName} using the guest account username and its associated password. - - - - - - 请确认您的相关信息 - -${displayName},您好: - -${addedBy} (${addedByEmail}) 邀请您加入 ${localSakaiName}。 - -请在 ${url} 确定您的相关信息 - -${localSakaiName} 是什么? -${localSakaiName} 是 ${institution} 的学习管理系统。其中包含了很多课程站点、 -管理站点、研究小组、图书馆以及学生社群。作为访客,您被邀请加入一个 ${localSakaiName} 站点。 -在此站点中,您可以浏览相关材料,您或许也可以创建或编辑相关材料(这取决于您被赋予的角色)。 - -What if I already have another ${localSakaiName} account? -If you have used${localSakaiName} with another ${localSakaiName} account, we strongly suggest that you accept the above invitation and then -indicate which existing ${localSakaiName} account you wish to use to access this site. This will avoid you having multiple accounts, each with a different set of -associated sites. If you do not choose to associate this site with an existing account, a new guest account will be created for you using this email -address. In the future, login to ${localSakaiName} using the guest account username and its associated password. -如果我已经有 ${localSakaiName} 帐号了,该怎么办? -如果您曾使用另一个帐号登录过 ${localSakaiName},我们强烈建议您接受上面的邀请, -然后指定您准备使用哪个 ${localSakaiName} 帐号。这可以避免您使用多个帐号, -而每个帐号关联着不同的站点的情况。如果您不将此站点关联到已有帐号,那么将会为您创建新访客帐号, -并以此email地址为用户名。今后,您可以使用这个访客帐号及相关密码访问 ${localSakaiName} 。 - - zh_CN - - - - diff -r b64d87c6b708 -r 2ec454f2a9ad reset-pass/account-validator-impl/src/bundle/validate_newPassword.xml --- a/reset-pass/account-validator-impl/src/bundle/validate_newPassword.xml Thu Sep 04 15:06:44 2014 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ - - - - ${localSakaiName}: Password Reset Request - - You have requested to reset the password for your ${localSakaiName} account (${userEid}). - - Please use the following link to reset your password on ${localSakaiName}: - - ${url} - - For security purposes, this link is only valid for a limited time. - - If you did not request this change, please ignore this message. - - Regards, - - The ${localSakaiName} Administrators - ${institution} - - - - - - New Password Request - ${displayName},您好: -请使用下面的链接来充值您在 ${localSakaiName} 的密码: - -${url} - -您的用户名是: ${userEid} - -${localSakaiName} 维护组 -${institution} - - zh_CN - - diff -r b64d87c6b708 -r 2ec454f2a9ad reset-pass/account-validator-impl/src/bundle/validate_newUser.xml --- a/reset-pass/account-validator-impl/src/bundle/validate_newUser.xml Thu Sep 04 15:06:44 2014 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ - - - - Welcome To ${localSakaiName}! - You have been invited to one or more sites in {localSakaiName}. - -Accept this invitation: - -${url} - -What is ${localSakaiName}? -${localSakaiName} is the ${institution}'s web-based learning management system. It is home to many course sites, -as well as a host of other sites including those used for administration, research and project groups, libraries, -and student societies. As a guest user, you have been invited to join a ${localSakaiName} site. On the site, you -will have rights to read content. You may also be able to create and/or edit content (depending on your assigned role). - -What if I already have a ${localSakaiName} account? -If you have used ${localSakaiName} in the past, then you already have an account on ${localSakaiName}. -We strongly suggest that you accept the above invitation and then -transfer your memberships to your existing ${localSakaiName} account. This -will help prevent you from having multiple accounts, each with a different set of -associated sites. - -If you do not choose to associate this site with an existing account, -a new guest account will be activated for you, and its login ID will be ${userEid}. -Afterwards, you may log in to ${localSakaiName} using ${userEid} as your login ID and its associated password. - <p>You have been invited to one or more sites in ${localSakaiName}.</p> - -<p><a href="${url}">Accept this invitation</a></p> - -<h2>What is ${localSakaiName}?</h2> -<p>${localSakaiName} is the ${institution}'s web-based learning management system. It is home to many course sites, -as well as a host of other sites including those used for administration, research and project groups, libraries, -and student societies. As a guest user, you have been invited to join a ${localSakaiName} site. On the site, you will -have rights to read content but you also may be able to create and/or edit content (depending on your assigned role).</p> - -<h2>What if I already have a ${localSakaiName} account?</h2> -<p>If you have used ${localSakaiName} in the past, then you already have an account on ${localSakaiName}. -We strongly suggest that you accept the above invitation and then -transfer your memberships to your existing ${localSakaiName} account. This -will help prevent you from having multiple accounts, each with a different set of -associated sites. </p> - -<p>If you do not choose to associate this site with an existing account, -a new guest account will be activated for you, and its login ID will be ${userEid}. -Afterwards you may log in to ${localSakaiName} using ${userEid} as your login ID and its associated password. </p> - - - - - 欢迎加入 ${localSakaiName} ! - ${addedBy} (${addedByEmail}) 邀请您加入 ${localSakaiName} 中的 ${memberSites} 站点。 - -您可以通过 ${url} 接受本邀请。 - -${localSakaiName} 是什么? -${localSakaiName} 是 ${institution} 的学习管理系统。其中包含了很多课程站点、 -管理站点、研究小组、图书馆以及学生社群。作为访客,您被邀请加入一个 ${localSakaiName} 站点。 -在此站点中,您可以浏览相关材料,您或许也可以创建或编辑相关材料(这取决于您被赋予的角色)。 - -如果我已经有 ${localSakaiName} 帐号了,该怎么办? -如果您曾使用过 ${localSakaiName},那么您已经拥有了一个 ${localSakaiName} 帐号。 -如此,我们强烈建议您接受上面的邀请,然后指定您准备使用哪个 ${localSakaiName} 帐号。 -这可以避免您使用多个帐号,而每个帐号关联着不同的站点的情况。如果您不将此站点关联到已有帐号, -那么将会为您创建新访客帐号,并以此email地址为用户名。今后,您可以使用这个访客帐号及相 -关密码访问 ${localSakaiName} 。 - - <p>${addedBy} (${addedByEmail}) 邀请您加入 <strong>${localSakaiName}</strong> 中的 ${memberSites} 站点。</p> - -<p><a href=${url}>您可以通过 ${url} 接受本邀请。</a></p> - -<h2> ${localSakaiName} 是什么?</h2> -<p>${localSakaiName} 是 ${institution} 的学习管理系统。其中包含了很多课程站点、 -管理站点、研究小组、图书馆以及学生社群。作为访客,您被邀请加入一个 ${localSakaiName} 站点。 -在此站点中,您可以浏览相关材料,您或许也可以创建或编辑相关材料(这取决于您被赋予的角色)。</p> - - -<h2>如果我已经有 ${localSakaiName} 帐号了,该怎么办?</h2> -<p>如果您曾使用过 ${localSakaiName},那么您已经拥有了一个 ${localSakaiName} 帐号。 -如此,我们强烈建议您接受上面的邀请,然后指定您准备使用哪个 ${localSakaiName} 帐号。 -这可以避免您使用多个帐号,而每个帐号关联着不同的站点的情况。如果您不将此站点关联到已有帐号, -那么将会为您创建新访客帐号,并以此email地址为用户名。今后,您可以使用这个访客帐号及相 -关密码访问 ${localSakaiName} 。</p> - zh_CN - - - diff -r b64d87c6b708 -r 2ec454f2a9ad reset-pass/account-validator-impl/src/java/org/sakaiproject/accountvalidator/logic/impl/ValidationLogicImpl.java --- a/reset-pass/account-validator-impl/src/java/org/sakaiproject/accountvalidator/logic/impl/ValidationLogicImpl.java Thu Sep 04 15:06:44 2014 +0800 +++ b/reset-pass/account-validator-impl/src/java/org/sakaiproject/accountvalidator/logic/impl/ValidationLogicImpl.java Thu Sep 04 15:08:54 2014 +0800 @@ -20,28 +20,19 @@ package org.sakaiproject.accountvalidator.logic.impl; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URLDecoder; import java.util.ArrayList; +import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jdom.input.SAXBuilder; import org.sakaiproject.accountvalidator.logic.ValidationException; import org.sakaiproject.accountvalidator.logic.ValidationLogic; import org.sakaiproject.accountvalidator.logic.dao.ValidationDao; @@ -54,11 +45,9 @@ import org.sakaiproject.authz.api.Member; import org.sakaiproject.authz.api.SecurityAdvisor; import org.sakaiproject.authz.api.SecurityService; -import org.sakaiproject.authz.api.SecurityAdvisor.SecurityAdvice; import org.sakaiproject.component.api.ServerConfigurationService; import org.sakaiproject.component.cover.ComponentManager; import org.sakaiproject.emailtemplateservice.service.EmailTemplateService; -import org.sakaiproject.emailtemplateservice.model.EmailTemplate; import org.sakaiproject.entitybroker.DeveloperHelperService; import org.sakaiproject.entitybroker.EntityReference; import org.sakaiproject.exception.IdUnusedException; @@ -67,7 +56,6 @@ import org.sakaiproject.id.api.IdManager; import org.sakaiproject.site.api.Site; import org.sakaiproject.site.api.SiteService; -import org.sakaiproject.tool.api.Session; import org.sakaiproject.tool.api.SessionManager; import org.sakaiproject.user.api.User; import org.sakaiproject.user.api.UserDirectoryService; @@ -86,6 +74,11 @@ private static final String TEMPLATE_KEY_LEGACYUSER = "validate.legacyuser"; private static final String TEMPLATE_KEY_PASSWORDRESET = "validate.passwordreset"; + private static final String TEMPLATE_FILE_EXISTINGUSER = "validate_existingUser.xml"; + private static final String TEMPLATE_FILE_NEW_USER = "validate_newUser.xml"; + private static final String TEMPLATE_FILE_LEGACYUSER = "validate_legacyUser.xml"; + private static final String TEMPLATE_FILE_PASSWORDRESET = "validate_newPassword.xml"; + private static final int VALIDATION_PERIOD_MONTHS = -36; private static Log log = LogFactory.getLog(ValidationLogicImpl.class); @@ -94,10 +87,12 @@ public void init(){ log.info("init()"); //need to populate the templates - loadTemplate("validate_newUser.xml", TEMPLATE_KEY_NEW_USER); - loadTemplate("validate_existingUser.xml", TEMPLATE_KEY_EXISTINGUSER); - loadTemplate("validate_legacyUser.xml", TEMPLATE_KEY_LEGACYUSER); - loadTemplate("validate_newPassword.xml", TEMPLATE_KEY_PASSWORDRESET); + loadTemplates( + TEMPLATE_FILE_EXISTINGUSER, + TEMPLATE_FILE_NEW_USER, + TEMPLATE_FILE_LEGACYUSER, + TEMPLATE_FILE_PASSWORDRESET + ); //seeing the GroupProvider is optional we need to load it here if (groupProvider == null) { @@ -109,60 +104,10 @@ * Load and register one or more email templates (contained in the given * .xml file) with the email template service * - * @param fileName - the name of the .xml file to load - * @param templateKey - the key (name) of the template to be saved to the service + * @param fileNames - the name of the .xml files to load */ - private void loadTemplate(String fileName, String templateKey) { - //Create the SecurityAdvisor (elevated permissions needed to use EmailTemplateService) - org.sakaiproject.authz.api.SecurityService securityService = (org.sakaiproject.authz.api.SecurityService) ComponentManager.get( org.sakaiproject.authz.api.SecurityService.class ); - SecurityAdvisor yesMan = new SecurityAdvisor() - { - public SecurityAdvice isAllowed( String userId, String function, String reference ) - { - return SecurityAdvice.ALLOWED; - } - }; - - try - { - // Push the yesMan SA on the stack and perform the necessary actions - securityService.pushAdvisor( yesMan ); - - // Load up the resource as an input stream - InputStream input = ValidationLogicImpl.class.getClassLoader().getResourceAsStream( fileName ); - if ( input == null ) - { - log.error( "Could not load resource from '" + fileName + "'. Skipping ..." ); - } - else - { - // Parse the XML, get all the child templates - Document document = new SAXBuilder().build( input ); - List childTemplates = document.getRootElement().getChildren( "emailTemplate" ); - Iterator iter = childTemplates.iterator(); - - // Create and register a template with the service for each one found in the XML file - while ( iter.hasNext() ) - { - xmlToTemplate( (Element) iter.next(), templateKey ); - } - } - } - catch ( JDOMException e ) - { - log.error( e.getMessage(), e); - } - catch ( IOException e ) - { - log.error( e.getMessage(), e); - } - - // Pop the yesMan SA off the stack (remove elevated permissions) - finally - { - securityService.popAdvisor( yesMan ); - } - + private void loadTemplates(String... fileNames) { + emailTemplateService.processEmailTemplates(Arrays.asList(fileNames)); } private IdManager idManager; @@ -580,40 +525,6 @@ } - - private void xmlToTemplate(Element xmlTemplate, String key) { - String subject = xmlTemplate.getChildText("subject"); - String body = xmlTemplate.getChildText("message"); - String bodyHtml = xmlTemplate.getChildText("messagehtml"); - String locale = xmlTemplate.getChildText("locale"); - String versionString = xmlTemplate.getChildText("version"); - - - if (emailTemplateService.getEmailTemplate(key, new Locale(locale)) == null) - { - EmailTemplate template = new EmailTemplate(); - template.setSubject(subject); - template.setMessage(body); - if (bodyHtml != null) { - String decodedHtml; - try { - decodedHtml = URLDecoder.decode(bodyHtml, "utf8"); - } catch (UnsupportedEncodingException e) { - decodedHtml = bodyHtml; - e.printStackTrace(); - } - template.setHtmlMessage(decodedHtml); - } - template.setLocale(locale); - template.setKey(key); - template.setVersion(Integer.valueOf(1));//setVersion(versionString != null ? Integer.valueOf(versionString) : Integer.valueOf(0)); // set version - template.setOwner("admin"); - template.setLastModified(new Date()); - this.emailTemplateService.saveTemplate(template); - log.info(this + " user notification tempalte " + key + " added"); - } - } - public void resendValidation(String token) { ValidationAccount account = this.getVaLidationAcountBytoken(token);