Source:
<code>public boolean isTOTPEnabledForLocalUser(String username) throws TOTPException { try { int tenantId = IdentityUtil.getTenantIdOFUser(username); UserRealm userRealm = TOTPManagerComponent.getRealmService().getTenantUserRealm(tenantId); if (userRealm != null) { UserStoreManager userStoreManager = userRealm.getUserStoreManager(); String secretKey = userStoreManager.getUserClaimValue(MultitenantUtils.getTenantAwareUsername (username), Constants.SECRET_KEY, null); String currentEncoding = TOTPUtil.getEncodingMethod(); String storedEncoding = userStoreManager.getUserClaimValue(MultitenantUtils.getTenantAwareUsername (username), Constants.Encoding, null); if (!currentEncoding.equals(storedEncoding)) { userStoreManager.setUserClaimValue(MultitenantUtils.getTenantAwareUsername(username), Constants.SECRET_KEY, "", null); userStoreManager.setUserClaimValue(MultitenantUtils.getTenantAwareUsername(username), Constants.QR_CODE_URL, "", null); userStoreManager.setUserClaimValue(MultitenantUtils.getTenantAwareUsername(username), Constants.Encoding, "Invalid", null); if (log.isDebugEnabled()) { log.debug("TOTP user claims was cleared of the user : " + username); } return false; } if ("".equals(secretKey) || secretKey == null) { return false; } else { return true; <START> } <END> } else { throw new TOTPException("Cannot find the user realm for the given tenant domain : " + CarbonContext .getThreadLocalCarbonContext().getTenantDomain()); } } catch (IdentityException e) { throw new TOTPException("TOTPAccessController failed while trying to get the tenant ID of the user : " + username, e); } catch (UserStoreException e) { throw new TOTPException("TOTPAccessController failed while trying to access userRealm of the user : " + username, e); } catch (IdentityApplicationManagementException e) { throw new TOTPException("TOTPAccessController failed while trying to access encoding method of the user : " + "" + username, e); } }</code><technical_language>simplified "return StringUtils.isNotBlank(secretKey);"</technical_language>

Target:
public boolean isTOTPEnabledForLocalUser(String username) throws TOTPException { try { int tenantId = IdentityUtil.getTenantIdOFUser(username); UserRealm userRealm = TOTPManagerComponent.getRealmService().getTenantUserRealm(tenantId); if (userRealm != null) { UserStoreManager userStoreManager = userRealm.getUserStoreManager(); String secretKey = userStoreManager.getUserClaimValue(MultitenantUtils.getTenantAwareUsername (username), Constants.SECRET_KEY_CLAIM_URL, null); String currentEncoding = TOTPUtil.getEncodingMethod(); String storedEncoding = userStoreManager.getUserClaimValue(MultitenantUtils.getTenantAwareUsername (username), Constants.ENCODING_CLAIM_URL, null); if (!currentEncoding.equals(storedEncoding)) { userStoreManager.setUserClaimValue(MultitenantUtils.getTenantAwareUsername(username), Constants.SECRET_KEY_CLAIM_URL, "", null); userStoreManager.setUserClaimValue(MultitenantUtils.getTenantAwareUsername(username), Constants.QR_CODE_CLAIM_URL, "", null); userStoreManager.setUserClaimValue(MultitenantUtils.getTenantAwareUsername(username), Constants.ENCODING_CLAIM_URL, "Invalid", null); if (log.isDebugEnabled()) { log.debug("TOTP user claims was cleared of the user : " + username); } return false; } return StringUtils.isNotBlank(secretKey); } else { throw new TOTPException("Cannot find the user realm for the given tenant domain : " + CarbonContext .getThreadLocalCarbonContext().getTenantDomain()); } } catch (IdentityException e) { throw new TOTPException("TOTPAccessController failed while trying to get the tenant ID of the user : " + username, e); } catch (UserStoreException e) { throw new TOTPException("TOTPAccessController failed while trying to access userRealm of the user : " + username, e); } catch (IdentityApplicationManagementException e) { throw new TOTPException("TOTPAccessController failed while trying to access encoding method of the user : " + "" + username, e); } }