From 9af205777fdc28e2d8df698850d632604988d262 Mon Sep 17 00:00:00 2001 From: Dave Hladky Date: Thu, 22 Jan 2015 13:22:18 -0600 Subject: [PATCH] Omaha #3918 Central registry web interface broken by DPA fix. Former-commit-id: 5fd928ec4cabac3c11bcbf4ab4b8c4b202bea670 [formerly c1127b066f87e0fdf5eb91484f06cb80bf12b3ca] [formerly 5fd928ec4cabac3c11bcbf4ab4b8c4b202bea670 [formerly c1127b066f87e0fdf5eb91484f06cb80bf12b3ca] [formerly a15e67385ad80260f5ee3070facef9b1138700b6 [formerly 5aa305adb5fd16c72ce557309cab28fd287379d9]]] Former-commit-id: a15e67385ad80260f5ee3070facef9b1138700b6 Former-commit-id: f3f75d02dc7d2852ed27d04850825da8058a83fc [formerly 92fbbea65a731d5a3c905135e7ea7262dd136f47] Former-commit-id: 60efde53e6b065fd2a10cd51cf1617a597603e63 --- .../ebxml/web/security/CredentialCache.java | 85 ++++++++++--------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/web/security/CredentialCache.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/web/security/CredentialCache.java index 5746bf4778..46a17a4e62 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/web/security/CredentialCache.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/web/security/CredentialCache.java @@ -126,8 +126,10 @@ public class CredentialCache { @Override public String[] doInTransaction( TransactionStatus status) { + String localUserName = userName; PersonType user = null; - + String password = null; + String role = null; /* * If we are the central registry, directly * query the registry @@ -135,31 +137,34 @@ public class CredentialCache { if (centralRegistry) { user = personDao.getById(userName + RegistryUsers.USER_SUFFIX); - } + } else { + // This is a case required if you are + // connected to a central registry. + if (isFederationEnabled) { - // This is a case required if you are - // connected to a central registry. - if (isFederationEnabled) { - - /* - * If we are not the central registry, - * query the central registry to get the - * user's information - */ - try { - user = restServices - .getRegistryObject( - CENTRAL_REGISTRY_ADDRESS, - userName - + RegistryUsers.USER_SUFFIX); - } catch (Exception e) { - throw new WebServiceException( - "Error contacting central registry!", - e); + /* + * If we are not the central + * registry, query the central + * registry to get the user's + * information + */ + try { + user = restServices + .getRegistryObject( + CENTRAL_REGISTRY_ADDRESS, + userName + + RegistryUsers.USER_SUFFIX); + } catch (Exception e) { + throw new WebServiceException( + "Error contacting central registry!", + e); + } } - + } + + if (isFederationEnabled) { /* - * User not found means unauthorized + * User not found in federation mode means unauthorized */ if (user == null) { throw new WebServiceException( @@ -173,9 +178,8 @@ public class CredentialCache { * role in the return array. Decrypt * the password. */ - String userName = user + localUserName = user .getSlotValue(RegistryUsers.USER_SLOT_NAME); - String password = null; try { password = encryption.decrypt( securityConfig @@ -187,28 +191,29 @@ public class CredentialCache { "Error decrypting password!", e); } - String role = user + role = user .getSlotValue(RegistryUsers.ROLE_SLOT_NAME); - return new String[] { userName, - password, role }; } - } + } else { + /* + * This is a case where you are not + * connected to a central registry + * (Standalone server and edge + * condition), use defaults. + */ - /* - * This is a case where you are not - * connected to a central registry - * (Standalone server and edge condition), - * use defaults. - */ - else { statusHandler .handle(Priority.INFO, "Federation not enabled! Proceeding with default user, pass, and role!"); - return new String[] { DEFAULT_USER, - DEFAULT_PASSWORD, DEFAULT_ROLE }; - } - } + localUserName = DEFAULT_USER; + password = DEFAULT_PASSWORD; + role = DEFAULT_ROLE; + } + + return new String[] { localUserName, + password, role }; + } }); } });