• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmrs / openmrs-core / 32774236414

24 Aug 2026 08:30PM UTC coverage: 66.861% (+0.03%) from 66.833%
32774236414

push

github

web-flow
TRUNK-6662: Get unchanged password hashing working using Spring's interfaces (#6219)

Co-authored-by: Ian <ian.c.bacher@gmail.com>

50 of 53 new or added lines in 7 files covered. (94.34%)

7 existing lines in 3 files now uncovered.

25145 of 37608 relevant lines covered (66.86%)

0.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/api/src/main/java/org/openmrs/spring/LegacyOpenmrsPasswordEncoder.java
1
/**
2
 * This Source Code Form is subject to the terms of the Mozilla Public License,
3
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
 * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5
 * the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6
 *
7
 * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8
 * graphic logo is a trademark of OpenMRS Inc.
9
 */
10
package org.openmrs.spring;
11

12
import org.openmrs.util.Security;
13
import org.springframework.security.crypto.password.PasswordEncoder;
14

15
/**
16
 * Wraps OpenMRS's historical password hashing behind Spring Security's {@link PasswordEncoder}:
17
 * SHA-512 over {@code password + salt}, with the older SHA-1 variants still accepted so existing
18
 * rows keep authenticating.
19
 *
20
 * @since 2.8.10
21
 */
22
public class LegacyOpenmrsPasswordEncoder implements PasswordEncoder {
1✔
23

24
        @Override
25
        public String encode(CharSequence rawPassword) {
26
                return Security.encodeString(rawPassword.toString());
1✔
27
        }
28

29
        @Override
30
        public boolean matches(CharSequence rawPassword, String encodedPassword) {
31
                if (encodedPassword == null || rawPassword == null) {
1✔
NEW
32
                        return false;
×
33
                }
34
                
35
                return Security.hashMatches(encodedPassword, rawPassword.toString());
1✔
36
        }
37
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc