Skip to content

correcting wallet handling across multiple archives to process the wallets in the right order #1411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
import java.net.URL;
import java.nio.file.Files;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
Expand Down Expand Up @@ -3698,6 +3701,48 @@ public int removeFileStoreDirectory(String fileStoreName, boolean silent)
// database wallet methods //
///////////////////////////////////////////////////////////////////////////////////////////////

/**
* Get the list of database wallet names from the archive.
*
* @return the list of wallet names
* @throws WLSDeployArchiveIOException if an IOException occurred while reading the archive
*/
public List<String> getDatabaseWalletNames() throws WLSDeployArchiveIOException {
final String METHOD = "getDatabaseWalletNames";
LOGGER.entering(CLASS, METHOD);

// This is ugly because of the deprecated atpwallet location.
Set<String> results = new HashSet<>();
List<String> zipEntries = getZipFile().listZipEntries();
int prefixLength = ARCHIVE_DB_WALLETS_DIR.length() + 1;
for (String zipEntry : zipEntries) {
if (zipEntry.startsWith(OLD_ARCHIVE_ATP_WALLET_PATH)) {
LOGGER.finer("Adding deprecated atpwallet as {0}",DEFAULT_RCU_WALLET_NAME);
results.add(DEFAULT_RCU_WALLET_NAME);
} else if (zipEntry.startsWith(ARCHIVE_DB_WALLETS_DIR)) {
// skip over the wlsdeploy/dbWallets/ entry
if (zipEntry.length() <= prefixLength) {
continue;
}

int walletNameDirectorySeparatorIndex = zipEntry.indexOf(ZIP_SEP, prefixLength);
if (walletNameDirectorySeparatorIndex == -1) {
WLSDeployArchiveIOException ex = new WLSDeployArchiveIOException("WLSDPLY-01460",
getArchiveFileName(), zipEntry);
LOGGER.throwing(CLASS, METHOD, ex);
throw ex;
}
String walletName = zipEntry.substring(prefixLength, walletNameDirectorySeparatorIndex);

LOGGER.finer("Adding wallet {0}", walletName);
results.add(walletName);
}
}

LOGGER.exiting(CLASS, METHOD, results);
return new ArrayList<>(results);
}

/**
* Add a database wallet to the archive.
*
Expand Down
37 changes: 23 additions & 14 deletions core/src/main/python/wlsdeploy/tool/util/archive_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,17 @@ def extract_database_wallet(self, wallet_name=WLSDeployArchive.DEFAULT_RCU_WALLE
:raises: BundleAwareException of the appropriate type: if an error occurs
"""
_method_name = 'extract_database_wallet'
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)
self.__logger.entering(wallet_name, class_name=self.__class_name, method_name=_method_name)

resulting_wallet_path = None
for archive_file in self.__archive_files[::-1]:
for archive_file in self.__archive_files:
wallet_path = archive_file.extractDatabaseWallet(self.__domain_home, wallet_name)
# Allow iteration to continue through all archive files but
# make sure to store off the path for a wallet that was extracted.
#
self.__logger.finer('extract wallet {0} from archive file {1} returned wallet path {2}',
wallet_name, archive_file.getArchiveFileName(), wallet_path,
class_name=self.__class_name, method_name=_method_name)
if wallet_path is not None:
# If multiple archives contain the same named wallet, they
# will all have the same path.
Expand All @@ -402,19 +405,25 @@ def extract_database_wallet(self, wallet_name=WLSDeployArchive.DEFAULT_RCU_WALLE
return resulting_wallet_path

def extract_all_database_wallets(self):
_method_name = 'extract_all_database_wallets'
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)

# extract_database_wallet() loops through the archive files so just collect
# the list of wallet names from the archive files and then loop through that list.

wallet_names = sets.Set()
for archive_file in self.__archive_files:
archive_entries = archive_file.getArchiveEntries()
wallet_names = sets.Set()
for entry in archive_entries:
if entry.startswith(WLSDeployArchive.ARCHIVE_DB_WALLETS_DIR):
if os.path.isdir(entry):
wallet_names.add(os.path.basename(entry))
else:
name = os.path.basename(os.path.dirname(entry))
wallet_names.add(name)
for wallet_name in wallet_names:
self.extract_database_wallet(wallet_name)
self.__logger.finer('processing archive_file {0}', archive_file.getArchiveFileName(),
class_name=self.__class_name, method_name=_method_name)
archive_wallet_names = archive_file.getDatabaseWalletNames()
wallet_names.update(archive_wallet_names)

for wallet_name in wallet_names:
self.__logger.finer('extracting database wallet {0}', wallet_name,
class_name=self.__class_name, method_name=_method_name)
self.extract_database_wallet(wallet_name)

self.__logger.exiting(class_name=self.__class_name, method_name=_method_name)

def extract_opss_wallet(self):
"""
Expand All @@ -426,7 +435,7 @@ def extract_opss_wallet(self):
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)

resulting_wallet_path = None
for archive_file in self.__archive_files[::-1]:
for archive_file in self.__archive_files:
wallet_path = archive_file.extractOPSSWallet(self.__domain_home)
# Allow iteration to continue through all archive files but
# make sure to store off the path for a wallet that was extracted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ WLSDPLY-01456=Failed to remove File Store {0} from archive file {1} because the
WLSDPLY-01457=Failed to remove database wallet {0} from archive file {1} because the archive file did not contain {2}.
WLSDPLY-01458=Failed to remove OPSS wallet from archive file {0} because the archive file did not contain {1}.
WLSDPLY-01459=Failed to add RCU Wallet to archive because the archive file {0} already contains an RCU wallet with {1} entries.

WLSDPLY-01460=Failed to get the database wallet names from archive file {0} because the archive contains an invalid database wallet entry at {1}

# oracle.weblogic.deploy.util.WLSDeployZipFile.java
WLSDPLY-01500=The zip file {0} has the saved entry {1}
Expand Down
1 change: 1 addition & 0 deletions documentation/3.0/content/release-notes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ None
#### Bug Fixes
- #1405: Corrected some issues with the Windows shell scripts where they were not properly handling paths with spaces.
- #1409: Corrected a bug where a wallet deprecation message was still being logged as a warning.
- #1411: Corrected a bug where wallet extraction handling with multiple archive files was happening in the wrong order.

#### Known Issues
1. When running `discoverDomain` with the `-remote` flag, there are several MBeans that are not being properly handled that
Expand Down