Revision 127:051afa591f4e

View differences:

.hgignore
6 6
syntax: regexp
7 7
^\.classpath$
8 8
syntax: regexp
9
^\.project$
9
^\.project$
10
syntax: regexp
11
^\.externalToolBuilders$
WebContent/WEB-INF/config/ss101_access/struts-config.xml
10 10
	<action-mappings>
11 11
		<!-- Login -->
12 12
		<action name="ibssLoginForm" path="/ss101/PortalAccess" scope="request"
13
			type="com.ib.ibss.controller.actions.ss101_access.IBSSPortalAccessAction"
14
			validate="false">
13
			type="com.ib.ibss.controller.actions.ss101_access.IBSSPortalAccessAction" validate="false">
15 14
			<forward name="success" path=".ibss.login" />
16 15
			<forward name="failure" path=".ibss.login" />
17 16
			<forward name="ibOperationTimeOut" path=".ibss.logout" />
18 17
		</action>
19 18
		<action name="ibssLoginForm" path="/ss101/portalLogin" scope="session"
20
			type="com.ib.ibss.controller.actions.ss101_access.IBSSPortalLoginAction"
21
			validate="false">
19
			type="com.ib.ibss.controller.actions.ss101_access.IBSSPortalLoginAction" validate="false">
22 20
			<forward name="success" path=".ibss.main.page" />
23 21
			<forward name="failure" path=".ibss.login" />
24 22
			<forward name="ftl" path=".ibss.chgpass" />
25 23
			<forward name="notifAlert" path=".ibss.notifalert" />
26 24
		</action>
27
		<action name="ibssLoginForm" path="/ss101/notifAlert"
28
			scope="session"
29
			type="com.ib.ibss.controller.actions.ss101_access.IBSSNotificationAlertAction"
30
			validate="false">
25
		<action name="ibssLoginForm" path="/ss101/notifAlert" scope="session"
26
			type="com.ib.ibss.controller.actions.ss101_access.IBSSNotificationAlertAction" validate="false">
31 27
			<forward name="change" path=".ibss.chgpass" />
32 28
			<forward name="skip" path="/ss101/loginProceed.do" />
33 29
		</action>
34
		<action name="ibssLoginForm" path="/ss101/forceChangePassword"
35
			scope="session"
36
			type="com.ib.ibss.controller.actions.ss101_access.IBSSForceChangePasswordAction"
37
			validate="false">
30
		<action name="ibssLoginForm" path="/ss101/forceChangePassword" scope="session"
31
			type="com.ib.ibss.controller.actions.ss101_access.IBSSForceChangePasswordAction" validate="false">
38 32
			<forward name="success" path=".ibss.loginsuccess" />
39 33
			<forward name="failure" path=".ibss.chgpass" />
40 34
		</action>
41
		<action forward=".ibss.main.page" name="ibssLoginForm" path="/ss101/loginProceed"
42
			scope="session" validate="false" />
35

  
36
		<action name="ibssLoginForm" path="/ss101/changeRootPassword" scope="request"
37
			type="com.ib.ibss.controller.actions.ss101_access.IBSSChangeRootPasswordAction" validate="false">
38

  
39
			<forward name="start" path=".ibss.changeRootPassword" />
40
			<forward name="success" path=".ibss.changeRootPassword.success" />
41
			<forward name="failure" path=".ibss.changeRootPassword" />
42
		</action>
43

  
44
		<action forward=".ibss.main.page" name="ibssLoginForm" path="/ss101/loginProceed" scope="session" validate="false" />
43 45
		<action name="ibssLogoutForm" path="/ss101/logout" scope="session"
44
			type="com.ib.ibss.controller.actions.ss101_access.IBSSPortalLogoutAction"
45
			validate="false">
46
			type="com.ib.ibss.controller.actions.ss101_access.IBSSPortalLogoutAction" validate="false">
46 47
			<forward name="success" path=".ibss.logout" />
47 48
			<forward name="sessionExpired" path=".ibss.session.error" />
48 49
		</action>
49
		<action forward=".ibss.main.page" name="ibssLoginForm" path="/ss101/MainProfile"
50
			scope="session" validate="false" />
51
		
50
		<action forward=".ibss.main.page" name="ibssLoginForm" path="/ss101/MainProfile" scope="session" validate="false" />
51

  
52 52
	</action-mappings>
53 53
	<controller />
54 54
</struts-config>
WebContent/WEB-INF/config/ss101_access/tiles-defs.xml
23 23
		<put name="body" value="/jsp/ss101_access/ibssLogout.jsp" />
24 24
	</definition>
25 25

  
26
	<definition name=".ibss.changeRootPassword" extends=".ibss.user.login.template">
27
		<put name="body" value="/jsp/ss101_access/ibssChangeRootPassword.jsp" />
28
	</definition>
29
	
30
	<definition name=".ibss.changeRootPassword.success" extends=".ibss.user.login.template">
31
		<put name="body" value="/jsp/ss101_access/ibssChangeRootPassword_success.jsp" />
32
	</definition>
33

  
26 34
</tiles-definitions>
WebContent/jsp/ss101_access/ibssChangeRootPassword.jsp
1
<%@ taglib uri="/WEB-INF/tld/struts-html-el" prefix="htmlEL" %>
2
<%@ taglib uri="/WEB-INF/tld/struts-bean" prefix="bean" %>
3
<%@ taglib uri="/WEB-INF/tld/struts-logic" prefix="logic" %>
4
<%@ taglib uri="/WEB-INF/tld/struts-logic-el" prefix="logicEL" %>
5
<%@ taglib uri="/WEB-INF/tld/c" prefix="c" %>
6

  
7
<script type="text/javascript" src="../js/passwordmeter.js"></script>
8

  
9
<h3><bean:message key="general.rootPassword.update"/></h3>
10
<br/>
11

  
12
<table id="errorTable">
13
<tr>
14
	<td>
15
		<span id="serverSideError" class="error"><jsp:include flush="true" page="/jsp/errorHandler.jsp"></jsp:include></span>
16
	</td>
17
</tr>
18
</table>
19

  
20
<htmlEL:form action="/ss101/changeRootPassword.do">
21
<table class="tabularConfirm" width="517" height="97" border="1">
22
  <tr>
23
    <td width="71">&nbsp;</td>
24

  
25
    <td width="138">&nbsp;</td>
26
    <td width="60">&nbsp;</td>
27
    <td width="50%">&nbsp;</td>
28
    <td width="48">&nbsp;</td>
29
  </tr>
30
  <tr>
31
    <td>&nbsp;</td>
32
    <td width="138"><bean:message key="login.oldpassword"/>:</td>
33

  
34
    <td width="60"><htmlEL:password autocomplete="off" property="oldPassword" name="ibssLoginForm" maxlength="12"/></td>
35
    <td>&nbsp;</td>
36
    <td width="48">&nbsp;</td>
37
  </tr>
38
  
39
  <tr>
40
    <td>&nbsp;</td>
41
    <td><bean:message key="login.newpassword"/>:</td>
42
    <td><htmlEL:password autocomplete="off" property="newPassword" name="ibssLoginForm" 
43
    onkeyup="testPassword(document.forms.ibssLoginForm.newPassword.value)" /></td>
44

  
45
    <td>&nbsp;<span style="font-size: 11px;">Password Strength : </span><span id="passCheck" class="textColor0"></span><br>
46
    <span id="passwordStrength" class="strength0"></span></td>
47
    <td>&nbsp;</td>
48
  </tr>
49
  <tr>
50
    <td>&nbsp;</td>
51
    <td><bean:message key="login.confirmpassword"/>:</td>
52
    <td><htmlEL:password autocomplete="off" property="confirmPassword" name="ibssLoginForm" /></td>
53
    <td>&nbsp;</td>
54
    <td>&nbsp;</td>
55
  </tr>
56
  
57
  <tr>
58
    <td>&nbsp;</td>
59
    <td>&nbsp;</td>
60
    <td>&nbsp;</td>
61
    <td>&nbsp;</td>
62
    <td>&nbsp;</td>
63
  </tr>
64

  
65
  <tr>
66
    <td>&nbsp;</td>
67
    <td>&nbsp;</td>
68
    <td>&nbsp;</td>
69
    <td>&nbsp;</td>
70
    <td>
71
        <htmlEL:submit property="action" styleClass="button" onclick="overlay();">
72
			<bean:message key="general.button.change"/>						
73
		</htmlEL:submit>
74
	</td>
75
  </tr>
76

  
77
</table>
78
</htmlEL:form>
79

  
80
<style>
81

  
82
#passwordStrength
83
{
84
	height:3px;
85
	display:block;
86
	float:left;
87
}
88

  
89
</style>
WebContent/jsp/ss101_access/ibssChangeRootPassword_success.jsp
1
<%@ taglib uri="/WEB-INF/tld/struts-html-el" prefix="htmlEL" %>
2
<%@ taglib uri="/WEB-INF/tld/struts-bean" prefix="bean" %>
3
<%@ taglib uri="/WEB-INF/tld/struts-logic" prefix="logic" %>
4
<%@ taglib uri="/WEB-INF/tld/struts-logic-el" prefix="logicEL" %>
5
<%@ taglib uri="/WEB-INF/tld/c" prefix="c" %>
6

  
7
<h3><bean:message key="general.rootPassword.update.result"/></h3>
8
<br/>
9
<table class="tabularForm" width="517" border="1">
10
  <tr>
11
    <td width="101">&nbsp;</td>
12
    <td class="success" width="277"><strong><bean:message key="general.status.successful"/></strong></td>
13
    <td width="150">&nbsp;</td>
14
    <td width="64">&nbsp;</td>
15
  </tr>
16
  <tr>
17
    <td height="28">&nbsp;</td>
18
    <td colspan="2"><bean:message key="general.changedpassword"/></td>
19
    <td>&nbsp;</td>
20
    <td>&nbsp;</td>
21
  </tr>  
22
</table>
resource/com/ib/ibss/resources/message/IBSSApplicationResources.properties
550 550
general.changedpassword=Password has been successfully changed
551 551
general.logout=Logout
552 552
general.error.message.cst.logout=You have logged out from the system
553

  
554
general.rootPassword.update=Root Password Update
555
general.rootPassword.update.result=Root Password Update - Result
556

  
553 557
login.notifalert=Notification Alert
554 558
login.notifalert.content=Your password will be expired in short time periods. Please change your password.
555 559

  
resource/log4j.staging-ci.xml
41 41
	</logger>
42 42
	
43 43
	<root>
44
		<priority value="error" />
44
		<priority value="info" />
45 45
		<appender-ref ref="ConsoleAppender"/>
46 46
	</root>
47 47
</log4j:configuration>
src/com/ib/ibss/common/utils/SettingsUtils.java
37 37
{
38 38
	static Class<SettingsUtils> c_oClass = SettingsUtils.class;
39 39
	
40
	private static final String PRELOAD_SETTINGS = "AppConfig";
40
	public static final String PRELOAD_SETTINGS = "AppConfig";
41 41
	
42 42
	private static ResourceBundle c_oSettings = null;
43 43
	
src/com/ib/ibss/controller/actions/ss101_access/IBSSChangeRootPasswordAction.java
1
/**
2
 * Copyright (M) 2009 Penril Datability (M) Sdn Bhd All rights reserved.
3
 *
4
 * This software is copyrighted. Under the copyright laws, this software
5
 * may not be copied, in whole or in part, without prior written consent
6
 * of Penril Datability (M) Sdn Bhd or its assignees. This software is
7
 * provided under the terms of a license between Penril Datability (M)
8
 * Sdn Bhd and the recipient, and its use is subject to the terms of that
9
 * license.
10
 */
11

  
12
package com.ib.ibss.controller.actions.ss101_access;
13

  
14
import java.util.Map.Entry;
15

  
16
import javax.servlet.http.HttpServletRequest;
17
import javax.servlet.http.HttpServletResponse;
18

  
19
import org.apache.struts.action.ActionErrors;
20
import org.apache.struts.action.ActionForm;
21
import org.apache.struts.action.ActionForward;
22
import org.apache.struts.action.ActionMapping;
23

  
24
import com.ib.ibss.common.constant.JSPValidator;
25
import com.ib.ibss.common.utils.IBSSNavigationUtil;
26
import com.ib.ibss.enterprise.services.ss101_access.IBSSChangeRootPasswordServices;
27
import com.ib.ibss.error.exception.IBSSGenericException;
28
import com.ib.ibss.struts.utils.IBSSControllerAction;
29
import com.ib.ibss.struts.utils.IBSSDynaBean;
30
import com.ib.ibss.struts.utils.IBSSDynaBeanManager;
31
import com.ib.ibss.struts.utils.IBSSSessionObjects;
32

  
33
/**
34
 * This is the Action controller class to go to load home screen after successful login
35
 */
36
public class IBSSChangeRootPasswordAction extends IBSSControllerAction {
37
	/**
38
	 * @param mapping
39
	 *            The ActionMapping used to select this instance
40
	 * @param form
41
	 *            The optional ActionForm bean for this request which is from form-bean.xml(if any)
42
	 * @param request
43
	 *            The HTTP request we are processing
44
	 * @param response
45
	 *            The HTTP response we are creating
46
	 * @return The requested ActionForward object
47
	 * @throws Exception
48
	 *             if the application business logic throws an exception
49
	 * 
50
	 * @see com.ib.ibss.struts.utils.IBSSControllerAction#execute(org.apache.struts.action.ActionMapping,
51
	 *      org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
52
	 *      javax.servlet.http.HttpServletResponse)
53
	 */
54
	public ActionForward execute(
55
			ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
56
			throws Exception {
57

  
58
		noErrorHandling(request, mapping);
59

  
60
		final boolean hasRequestParams = request.getParameterMap().size() > 0;
61
		ActionErrors errors = null;
62
		if (hasRequestParams)
63
			errors = form.validate(createNewActionMapping(
64
					mapping, JSPValidator.FORCE_RESET_PASS_VALIDATION), request);
65

  
66
		if (errors != null && !errors.isEmpty()) {
67
			errorHandling(request, mapping, errors);
68

  
69
		} else if (hasRequestParams) {
70
			IBSSDynaBean dynaBean = IBSSDynaBeanManager.createIBSSDynaBean(form, mapping);
71
			IBSSSessionObjects sessionObjects = new IBSSSessionObjects(request);
72

  
73
			try {
74
				IBSSChangeRootPasswordServices services = new IBSSChangeRootPasswordServices(sessionObjects);
75
				services.setIBSSDynaBean(dynaBean);
76
				services.saveNewRootPassword();
77

  
78
			} catch (IBSSGenericException e) {
79
				errorHandling(request, mapping, e);
80
			}
81
		} else {
82
			setForwardPage("start");
83
		}
84
		return super.execute(mapping, form, request, response);
85
	}
86
}
src/com/ib/ibss/enterprise/services/ss101_access/IBSSChangeRootPasswordServices.java
1
/**
2
 * Copyright (M) 2009 Penril Datability (M) Sdn Bhd All rights reserved.
3
 *
4
 * This software is copyrighted. Under the copyright laws, this software
5
 * may not be copied, in whole or in part, without prior written consent
6
 * of Penril Datability (M) Sdn Bhd or its assignees. This software is
7
 * provided under the terms of a license between Penril Datability (M)
8
 * Sdn Bhd and the recipient, and its use is subject to the terms of that
9
 * license.
10
 */
11

  
12
package com.ib.ibss.enterprise.services.ss101_access;
13

  
14
import my.com.upass.ConfigBean;
15
import net.penril.ibss.audit.log.AuditLogConstants;
16
import net.penril.ibss.audit.log.USER_ACTIVITY_TYTPE;
17

  
18
import com.ib.ibss.common.constant.ExceptionErrors;
19
import com.ib.ibss.common.utils.IBSSLogger;
20
import com.ib.ibss.enterprise.services.IBSSEnterpriseServicesWorkspace;
21
import com.ib.ibss.enterprise.services.StatusConstants;
22
import com.ib.ibss.error.exception.IBSSBusinessException;
23
import com.ib.ibss.error.exception.IBSSGenericException;
24
import com.ib.ibss.error.handler.IBSSErrorHandler;
25
import com.ib.ibss.struts.utils.IBSSSessionObjects;
26

  
27
/**
28
 * Get necessary details information to perform force change password if needed
29
 */
30
public class IBSSChangeRootPasswordServices extends IBSSEnterpriseServicesWorkspace {
31

  
32
	/**
33
	 * Class constructor specifying session object.
34
	 * 
35
	 * @param sessionObject
36
	 *            Session object contains all information stored in HTTP session.
37
	 */
38
	public IBSSChangeRootPasswordServices(IBSSSessionObjects sessionObject) {
39
		super(sessionObject);
40
	}
41

  
42
	public void saveNewRootPassword() throws IBSSGenericException {
43

  
44
		IBSSLogger.debug(getClass(), "Entering saveNewRootPassword");
45

  
46
		String oldPassword = null;
47
		String newPassword = null;
48
		String confirmPassword = null;
49

  
50
		int errorCode = 0;
51

  
52
		long status = AuditLogConstants.UNSUCCESSFUL;
53

  
54
		try {
55
			oldPassword = getBeanMessage(IBSSAccessConstants.OLD_PASSWORD);
56
			newPassword = getBeanMessage(IBSSAccessConstants.NEW_PASSWORD);
57
			confirmPassword = getBeanMessage(IBSSAccessConstants.CONFIRM_PASSWORD);
58

  
59
			if (newPassword.equals(confirmPassword)) {
60
				errorCode = getUPassService().changeRootPassword(newPassword, oldPassword);
61

  
62
				if (errorCode != StatusConstants.ERR_SUCCESS) {
63
					if (errorCode == StatusConstants.ERR_INVALID_CREDENTIAL) {
64
						throw IBSSErrorHandler.createBusinessException(IBSSBusinessException.LOGIN,
65
								ExceptionErrors.LOGIN_INVALID_EXISTING_PWD);
66

  
67
					} else if (errorCode == StatusConstants.ERR_PASSWORD_CHANGE_INTERVAL) {
68
						final int changePasswordInterval = new ConfigBean().getChangePasswordInterval();
69
						throw IBSSErrorHandler.createBusinessException(IBSSBusinessException.UPASS,
70
								ExceptionErrors.ERR_PASSWORD_CHANGE_INTERVAL,
71
								new String[] { String.valueOf(changePasswordInterval) });
72

  
73
					} else {
74
						throw IBSSErrorHandler.createBusinessException(
75
								IBSSBusinessException.LOGIN, String.valueOf(errorCode));
76
					}
77
				}
78

  
79
			} else {
80
				throw IBSSErrorHandler.createBusinessException(
81
						IBSSBusinessException.LOGIN, ExceptionErrors.LOGIN_INVALID_EXISTING_PWD);
82
			}
83
			/* Logging section */
84
			status = AuditLogConstants.SUCCESSFUL;
85

  
86
		} catch (Exception e) {
87
			IBSSErrorHandler.handleServiceError(e, getClass());
88

  
89
		} finally {
90
			try {
91
				getAuditLogDAO().logActivity(
92
						USER_ACTIVITY_TYTPE.CHANGE_PASSWORD.getID(),
93
						"A change request recieved for the root password",
94
						status, "Accessed 'Change Root Password' form from IP: "
95
								+ getIBSSessionObjects().getRemoteIPAddress(),
96
						"root");
97

  
98
			} catch (Exception e) {
99
				IBSSErrorHandler.handleServiceError(e, getClass());
100
			}
101
		}
102
		IBSSLogger.debug(getClass(), "Exiting saveNewRootPassword");
103
	}
104
}
src/com/ib/ibss/upass/service/UPassService.java
108 108
	int modifyUPassAdmin(
109 109
			String sessionUserAlias, String sessionUserPassword,
110 110
			String userAlias, String userDescription, String password);
111

  
112
	int changeRootPassword(String newPassword, String oldPassword);
111 113
}
src/com/ib/ibss/upass/service/UPassServiceImpl.java
10 10
 */
11 11
package com.ib.ibss.upass.service;
12 12

  
13
import java.io.File;
14
import java.io.FileWriter;
15
import java.io.IOException;
16
import java.io.InputStream;
13 17
import java.io.UnsupportedEncodingException;
18
import java.net.URISyntaxException;
19
import java.net.URL;
14 20
import java.security.MessageDigest;
15 21
import java.security.NoSuchAlgorithmException;
16 22
import java.util.Date;
17 23
import java.util.List;
18 24
import java.util.Map;
25
import java.util.Properties;
19 26

  
27
import my.com.upass.Constants;
20 28
import my.com.upass.UPassControllerV2;
21 29
import my.com.upass.UPassException;
22 30
import my.com.upass.maybank.entities.UserProfile;
......
28 36
import org.apache.commons.codec.binary.Hex;
29 37
import org.hibernate.Session;
30 38

  
39
import com.ib.common.utils.IBLoggerInf;
40
import com.ib.common.utils.ResourcesUtils;
31 41
import com.ib.ibss.common.utils.IBSSLogger;
32 42
import com.ib.ibss.common.utils.SettingsUtils;
33 43
import com.ib.ibss.enterprise.services.StatusConstants;
......
464 474
				userAlias, userDescription,
465 475
				inMigrationPeriod ? password : sha256(password));
466 476
	}
477

  
478
	@Override
479
	public int changeRootPassword(String newPassword, String oldPassword) {
480
		final int returnCode = upassController.SP_ChangeStaticPassword(
481
				adminUserAlias,
482
				inMigrationPeriod ? newPassword : sha256(newPassword),
483
				inMigrationPeriod ? oldPassword : sha256(oldPassword));
484

  
485
		if (returnCode == Constants.ERR_SUCCESS) {
486
			final String propsLocator = "/" + SettingsUtils.PRELOAD_SETTINGS + ".properties";
487
			final URL settingsUrl = getClass().getResource(propsLocator);
488
			Properties props = new Properties();
489
			InputStream propsStream = ResourcesUtils.class.getClassLoader()
490
					.getResourceAsStream(propsLocator);
491
			try {
492
				props.load(propsStream);
493
				final String newPasswordBase64 = Base64.encodeBase64String(newPassword.getBytes());
494
				props.setProperty(StatusConstants.APPLICATION_ADMIN_PASS, newPasswordBase64);
495
				final File propsFile = new File(settingsUrl.toURI());
496
				props.store(new FileWriter(propsFile),
497
						"Updated programmatically by UPassServiceImpl,"
498
								+ " as a result of root password modification.");
499

  
500
			} catch (IOException e) {
501
				IBLoggerInf.getLogger().error(e.getMessage(), e);
502
				
503
			} catch (URISyntaxException e) {
504
				IBLoggerInf.getLogger().error(e.getMessage(), e);
505
			
506
			} finally {
507
				try {
508
					propsStream.close();
509
				
510
				} catch (IOException e) {
511
					IBLoggerInf.getLogger().error(e.getMessage(), e);
512
				}
513
			}
514
		}
515
		return returnCode;
516
	}
467 517
}
src/com/ib/ibss/upass/service/UPassServiceMockUpImpl.java
313 313
		return 0;
314 314
	}
315 315

  
316
	@Override
317
	public int changeRootPassword(String newPassword, String oldPassword) {
318
		// TODO Auto-generated method stub
319
		return 0;
320
	}
321

  
316 322
}

Also available in: Unified diff