Sun Java System Identity Server 2004Q2
Sample
 

Main Page > Console Sample Page

Administration Console: Change User Password Sample


Purpose

Build a user interface that allows a user to change their password. This is done by removing the Password and Password Confirmation text fields from current user profile page and adding a hyperlink to bring up a new window where the password can be modified.


Files

1. UMChangeUserPasswordViewBean.java
2. UMSuccessfullyChangedPasswordViewBean.java
3. model/UMChangeUserPasswordModel.java
4. model/UMChangeUserPasswordModelImpl.java
5. jsp/UMChangeUserPassword.jsp
6. jsp/UMSuccessfullyChangedPassword.jsp


Directions

1. Copy all of the change user password JSP files to the web application.
cp /opt/SUNWam/samples/console/ChangeUserPassword/jsp/* /opt/SUNWam/web-src/applications/console/user

2. Remove the password textfield from the User Profile. This is done by removing the display keyword from the any string for the userpassword attribute. The userpassword attribute is found in /etc/opt/SUNWam/config/xml/amUser.xml

change

<AttributeSchema name="userpassword"
     type="single"
     syntax="password"
     any="required|display"
     i18nKey="u105">
</AttributeSchema>
to
<AttributeSchema name="userpassword"
     type="single"
     syntax="password"
     any="required"
     i18nKey="u105">
</AttributeSchema>

3. Add a new attribute to the User service which will display a hyperlink in the User Profile page. Selecting this link will invoke the new password class, /amconsole/user/UMChangeUserPassword, where the password can be modified. Edit /etc/opt/SUNWam/config/xml/amUser.xml and add the following entry to the User subschema.

<AttributeSchema name="ChangePassword"
     type="single"
     syntax="string"
     any="display"
     uitype="link"
     propertiesViewBeanURL="/amconsole/user/UMChangeUserPassword"
     i18nKey="u1051">
</AttributeSchema>

4. Add the new resource strings to the User service properties file. Edit /opt/SUNWam/locale/amUser.properties and add the following:

u1051=Password
u1051.link=click here to change password...

5. Add the new resource strings for the new change password dialog. Edit /opt/SUNWam/locale/amAdminModuleMsgs.properties and add the following:

changepassword.title=Change Password
oldpassword.label=Old Password:
password.label=New Password:
passwordconfirm.label=New Password (Confirm):
error.title=Password Mismatch:
error.message=Please enter the password again.
err.title=Password
err.message=The passwords cannot be changed.
error.message=The password field is null. Please enter the password again.
blankerror.message=The password field is blank. Please enter the password.

6. Reload the User service. This needs to be done because the userpassword attribute was modified, and a new attribute was added to the service definition. Execute the following two commands to reload the service.

/opt/SUNWam/bin/amadmin --runasdn <uid for amAdmin> --password <password> --deleteservice iPlanetAMUserService
/opt/SUNWam/bin/amadmin --runasdn <uid for amAdmin> --password <password> --schema /opt/SUNWam/config/xml/amUser.xml

7. Compile the Java files

gmake all /opt/SUNWam/samples/console/ChangeUserPassword

8. Create a new jar with the sample class files

cd /opt/SUNWam/samples/console
jar cf am_console_sample.jar com

9. Copy the am_console_sample.jar into

/opt/SUNWam/web-src/applications/WEB-INF/lib

10. Redeploy the console

Set the DEPLOY_LEVEL to 22 in the silent file
For webserver: run amws61config -s <silent file>
For application server: run amas70config -s <silent file>

11. Login to Console and view the User Profile page. Select the link to open the user password page.