Skip to content

ZCS-19497: Add IRopcCredCache with Guava cache and SSHA512 hashing for non-EAS protocol credential caching - #1850

Open
sonali033 wants to merge 1 commit into
feature/ZCS-19097-mfa-easfrom
feature/ZCS-19497
Open

ZCS-19497: Add IRopcCredCache with Guava cache and SSHA512 hashing for non-EAS protocol credential caching#1850
sonali033 wants to merge 1 commit into
feature/ZCS-19097-mfa-easfrom
feature/ZCS-19497

Conversation

@sonali033

Copy link
Copy Markdown
Contributor

ZCS-19497: Add Guava credential cache for IRopc non-EAS protocols

  • Introduced IRopcCredCache with SSHA512 hashing (aligned with EAS PassCache)
  • TTL: 1hr, max size: 10000, configurable via named constants
  • Integrated cache lookup and store in IRopcCustomAuth
  • Cache skipped for zsync protocol (EAS uses its own PassCache)

@sonali033
sonali033 marked this pull request as ready for review July 13, 2026 12:24
@sonali033
sonali033 force-pushed the feature/ZCS-19497 branch from 44cd9a0 to 3cca7cf Compare July 24, 2026 09:04

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

checkstyle

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'ip'.


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'deviceId'.


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck> reported by reviewdog 🐶
'if' construct must use '{}'s.


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'email'.

public static void invalidate(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'userAgent'.

public static void invalidate(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'protocol'.

public static void invalidate(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'provider'.

public static void invalidate(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'ip'.

public static void invalidate(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'deviceId'.


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck> reported by reviewdog 🐶
'if' construct must use '{}'s.


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'email'.

public static void storeRejection(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'userAgent'.

public static void storeRejection(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'protocol'.

public static void storeRejection(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'provider'.

public static void storeRejection(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'ip'.

public static void storeRejection(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'deviceId'.


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck> reported by reviewdog 🐶
'if' construct must use '{}'s.


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'email'.

public static void checkRejectionLimit(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'userAgent'.

public static void checkRejectionLimit(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'protocol'.

public static void checkRejectionLimit(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'provider'.

public static void checkRejectionLimit(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'ip'.

public static void checkRejectionLimit(String email, String userAgent, String protocol, String provider, String ip,


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'deviceId'.

String deviceId) throws AuthFailedServiceException {


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck> reported by reviewdog 🐶
'if' construct must use '{}'s.


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck> reported by reviewdog 🐶
Line exceeds 120 characters in comments

ZimbraLog.account.warn("IRopcCredCache: auth blocked for %s; push rejection limit reached (%d)", email, count);


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 120 characters (found 127).

ZimbraLog.account.warn("IRopcCredCache: auth blocked for %s; push rejection limit reached (%d)", email, count);


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck> reported by reviewdog 🐶
'if' construct must use '{}'s.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

checkstyle

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck> reported by reviewdog 🐶
'if' construct must use '{}'s.


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck> reported by reviewdog 🐶
Line exceeds 120 characters in comments

ZimbraLog.account.warn("IRopcCredCache: auth blocked for %s; push rejection limit reached (%d)", email, count);


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 120 characters (found 127).

ZimbraLog.account.warn("IRopcCredCache: auth blocked for %s; push rejection limit reached (%d)", email, count);


🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck> reported by reviewdog 🐶
'if' construct must use '{}'s.

import com.zimbra.cs.account.auth.PasswordUtil.SSHA512;
import java.util.concurrent.TimeUnit;

import static com.zimbra.cs.account.auth.ropc.IRopcConstants.TTL_MS;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck> reported by reviewdog 🐶
Extra separation in import group before 'com.zimbra.cs.account.auth.ropc.IRopcConstants.TTL_MS'

String effectivePassword = getEffectivePassword(password);
String key = buildKey(email, userAgent, protocol, provider, ip, deviceId);

// Store the successful credential

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments to start with lower case here and below

user, protocolStr, userAgent, deviceId, ipAddress, provider);

// Implementation of the cache check using composite keys
if (useCustomCache) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is not required , as this flow works only if custom auth is idp ropc.

CRED_CACHE.put(key, entry);

// Store IP bridge when deviceId is present
// Enables OPCC to real deviceId upgrade in isValid()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OPCC?

default:
throw ServiceException.FAILURE("Authentication service temporarily unavailable.", null);
}
long expires_in = 3600000L;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck> reported by reviewdog 🐶
Name 'expires_in' must match pattern '^[a-z][a-zA-Z0-9]*$'.

*/
private static final class CacheEntry {

final String hash;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck> reported by reviewdog 🐶
Variable 'hash' must be private and have accessor methods.

* absolute wall-clock timestamp (ms) after which this entry is considered expired.
* computed as: System.currentTimeMillis() + (expiresInSeconds * 1000)
*/
final long expiryTimestamp;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck> reported by reviewdog 🐶
Variable 'expiryTimestamp' must be private and have accessor methods.

/**
* validates entry against password. Immediately invalidates expired entries.
*/
private static boolean isMatch(CacheEntry entry, String key, String password) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
@return tag should be present and have description.

/**
* validates entry against password. Immediately invalidates expired entries.
*/
private static boolean isMatch(CacheEntry entry, String key, String password) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'entry'.

/**
* validates entry against password. Immediately invalidates expired entries.
*/
private static boolean isMatch(CacheEntry entry, String key, String password) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'key'.

/**
* validates entry against password. Immediately invalidates expired entries.
*/
private static boolean isMatch(CacheEntry entry, String key, String password) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck> reported by reviewdog 🐶
Expected @PARAM tag for 'password'.

@sonali033
sonali033 force-pushed the feature/ZCS-19497 branch from 08c057f to 5fdd816 Compare July 31, 2026 06:55
@ashwinsahu19
ashwinsahu19 force-pushed the feature/ZCS-19097-mfa-eas branch 2 times, most recently from 8fb6ac3 to e9dedfa Compare August 7, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants