From c053d83eb437764e6b81e06e3c47e546f2082c46 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Thu, 6 Jun 2019 12:57:34 -0500 Subject: [PATCH 1/4] add opss set secret capability --- .../deploy/util/WLSDeployArchive.java | 173 ++++++++++-------- core/src/main/python/create.py | 4 + .../python/wlsdeploy/aliases/alias_entries.py | 3 +- .../wlsdeploy/aliases/model_constants.py | 1 + .../wlsdeploy/tool/create/domain_creator.py | 59 ++++++ .../python/wlsdeploy/tool/util/wlst_helper.py | 10 + .../main/python/wlsdeploy/util/wlst_helper.py | 8 + 7 files changed, 184 insertions(+), 74 deletions(-) diff --git a/core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java b/core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java index 6fe92e6161..9912839e32 100644 --- a/core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java +++ b/core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java @@ -28,7 +28,6 @@ public class WLSDeployArchive { public static final String WLSDPLY_ARCHIVE_BINARY_DIR = "wlsdeploy"; - /** * Top-level archive subdirectory where the config * will be extracted. @@ -40,6 +39,10 @@ public class WLSDeployArchive { */ public static final String ARCHIVE_ATP_WALLET_PATH = "atpwallet"; + /** + * Top-level archive subdirectory where the opss wallet is stored + */ + public static final String ARCHIVE_OPSS_WALLET_PATH = "opsswallet"; /** * Top-level archive subdirectory where the model is stored and the subdirectory to which it will be extracted. */ @@ -51,7 +54,6 @@ public class WLSDeployArchive { */ public static final String ARCHIVE_APPS_TARGET_DIR = WLSDPLY_ARCHIVE_BINARY_DIR + "/applications"; - /** * Top-level archive subdirectory where the shared libraries are stored and the subdirectory to * which they will be extracted. @@ -142,8 +144,8 @@ public static boolean isPathIntoArchive(String path) { LOGGER.entering(CLASS, METHOD, path); boolean result = false; if (!StringUtils.isEmpty(path)) { - result = - path.startsWith(WLSDPLY_ARCHIVE_BINARY_DIR + ZIP_SEP) || path.startsWith(ARCHIVE_ATP_WALLET_PATH + ZIP_SEP); + result = path.startsWith(WLSDPLY_ARCHIVE_BINARY_DIR + ZIP_SEP) || path + .startsWith(ARCHIVE_ATP_WALLET_PATH + ZIP_SEP) || path.startsWith(ARCHIVE_OPSS_WALLET_PATH + ZIP_SEP); } LOGGER.exiting(CLASS, METHOD, result); return result; @@ -152,6 +154,7 @@ public static boolean isPathIntoArchive(String path) { /** * Determine if the specified path is in the classpath libraries folder. * This includes the case where the specified path is the classpath libraries folder. + * * @param path the path to be checked * @return true if the specified path matches or is under the classpath libraries folder */ @@ -173,7 +176,7 @@ public String getArchiveFileName() { * * @param model the model file to add * @throws WLSDeployArchiveIOException if an IOException occurred while reading or writing changes - * @throws IllegalArgumentException if the model is null, does not exist, or is not a file + * @throws IllegalArgumentException if the model is null, does not exist, or is not a file */ public void addModel(File model) throws WLSDeployArchiveIOException { final String METHOD = "addModel"; @@ -188,10 +191,10 @@ public void addModel(File model) throws WLSDeployArchiveIOException { /** * Adds the model file into the archive using the specified model file name. * - * @param model the file containing the model + * @param model the file containing the model * @param modelFileName the file name to use * @throws WLSDeployArchiveIOException if an IOException occurred while reading or writing changes - * @throws IllegalArgumentException if the model is null, does not exist, or is not a file + * @throws IllegalArgumentException if the model is null, does not exist, or is not a file */ public void addModel(File model, String modelFileName) throws WLSDeployArchiveIOException { final String METHOD = "addModel"; @@ -209,7 +212,7 @@ public void addModel(File model, String modelFileName) throws WLSDeployArchiveIO * @param modelDirectory the directory where to place the extracted model * @return the model file or null, if no model exists * @throws WLSDeployArchiveIOException if an error occurs - * @throws IllegalArgumentException if the modelDirectory is null, does not exist, or is not a directory + * @throws IllegalArgumentException if the modelDirectory is null, does not exist, or is not a directory */ public File extractModel(File modelDirectory) throws WLSDeployArchiveIOException { final String METHOD = "extractModel"; @@ -225,8 +228,9 @@ public File extractModel(File modelDirectory) throws WLSDeployArchiveIOException try { modelFile = FileUtils.getModelFile(resultDirectory); } catch (IllegalArgumentException | IllegalStateException ex) { - WLSDeployArchiveIOException wsdioe = new WLSDeployArchiveIOException("WLSDPLY-01400", ex, - resultDirectory.getAbsolutePath(), ex.getLocalizedMessage()); + WLSDeployArchiveIOException wsdioe = + new WLSDeployArchiveIOException("WLSDPLY-01400", ex, resultDirectory.getAbsolutePath(), + ex.getLocalizedMessage()); LOGGER.throwing(CLASS, METHOD, wsdioe); throw wsdioe; } @@ -257,8 +261,8 @@ public boolean containsModel() throws WLSDeployArchiveIOException { String modelEntryName = FileUtils.getModelFileName(modelDirContents, getZipFile().getFileName()); result = !StringUtils.isEmpty(modelEntryName); } catch (IllegalArgumentException iae) { - WLSDeployArchiveIOException wsdioe = new WLSDeployArchiveIOException("WLSDPLY-01401", iae, - iae.getLocalizedMessage()); + WLSDeployArchiveIOException wsdioe = + new WLSDeployArchiveIOException("WLSDPLY-01401", iae, iae.getLocalizedMessage()); LOGGER.throwing(CLASS, METHOD, wsdioe); throw wsdioe; } @@ -288,7 +292,7 @@ public List getArchiveEntries() throws WLSDeployArchiveIOException { * @param path the path into the archive file to test * @return true if the specified location was found int the archive, false otherwise * @throws WLSDeployArchiveIOException if an error occurs reading the archive file - * @throws IllegalArgumentException if the path is null or empty + * @throws IllegalArgumentException if the path is null or empty */ public boolean containsFile(String path) throws WLSDeployArchiveIOException { final String METHOD = "containsFile"; @@ -312,7 +316,7 @@ public boolean containsFile(String path) throws WLSDeployArchiveIOException { * @param path the path into the archive file to test * @return true if the specified location was found in the archive file and is a directory * @throws WLSDeployArchiveIOException if an error occurs reading the archive file - * @throws IllegalArgumentException if the path is null or empty + * @throws IllegalArgumentException if the path is null or empty */ public boolean containsPath(String path) throws WLSDeployArchiveIOException { final String METHOD = "isAPath"; @@ -337,7 +341,7 @@ public boolean containsPath(String path) throws WLSDeployArchiveIOException { * @param path the path into the archive file to test * @return true if the specified location was found in the archive file * @throws WLSDeployArchiveIOException if an error occurs reading the archive file - * @throws IllegalArgumentException if the path is null or empty + * @throws IllegalArgumentException if the path is null or empty */ public boolean containsFileOrPath(String path) throws WLSDeployArchiveIOException { final String METHOD = "containsFileOrPath"; @@ -360,12 +364,12 @@ public boolean containsFileOrPath(String path) throws WLSDeployArchiveIOExceptio * if the path is wlsdeploy/applications/myapp.ear and the extractToLocation is the domain home, the file * will be written to $DOMAIN_HOME/wlsdeploy/applications/myapp.ear. * - * @param path the path into the archive file to extract + * @param path the path into the archive file to extract * @param extractToLocation the base directory to which to write the extracted file or directory. * @return the canonical extracted file name * @throws WLSDeployArchiveIOException if an error occurs reading the archive or writing the file - * @throws IllegalArgumentException if the path is null or empty or the extractToLocation - * was not a valid, existing directory + * @throws IllegalArgumentException if the path is null or empty or the extractToLocation + * was not a valid, existing directory */ public String extractFile(String path, File extractToLocation) throws WLSDeployArchiveIOException { return extractFile(path, extractToLocation, false); @@ -374,14 +378,14 @@ public String extractFile(String path, File extractToLocation) throws WLSDeployA /** * Extract the specified file to the specified location. * - * @param path the path into the archive file to extract - * @param extractToLocation the base directory to which to write the extracted file or directory + * @param path the path into the archive file to extract + * @param extractToLocation the base directory to which to write the extracted file or directory * @param stripLeadingPathDirectories whether or not to strip the leading directories * when writing to the target location * @return the canonical extracted file name * @throws WLSDeployArchiveIOException if an error occurs reading the archive or writing the file - * @throws IllegalArgumentException if the path is null or empty or the extractToLocation - * was not a valid directory + * @throws IllegalArgumentException if the path is null or empty or the extractToLocation + * was not a valid directory */ public String extractFile(String path, File extractToLocation, boolean stripLeadingPathDirectories) throws WLSDeployArchiveIOException { @@ -466,8 +470,8 @@ public String getFileHash(String path) throws WLSDeployArchiveIOException { fileBytes = FileUtils.readInputStreamToByteArray(zipEntries.get(path)); } catch (IOException ioe) { WLSDeployArchiveIOException aioe = - new WLSDeployArchiveIOException("WLSDPLY-01407", ioe, getArchiveFileName(), - path, ioe.getLocalizedMessage()); + new WLSDeployArchiveIOException("WLSDPLY-01407", ioe, getArchiveFileName(), path, + ioe.getLocalizedMessage()); LOGGER.throwing(CLASS, METHOD, aioe); throw aioe; } finally { @@ -480,8 +484,8 @@ public String getFileHash(String path) throws WLSDeployArchiveIOException { result = FileUtils.computeHash(fileBytes); } catch (NoSuchAlgorithmException e) { WLSDeployArchiveIOException aioe = - new WLSDeployArchiveIOException("WLSDPLY-01407", e, getArchiveFileName(), - path, e.getLocalizedMessage()); + new WLSDeployArchiveIOException("WLSDPLY-01407", e, getArchiveFileName(), path, + e.getLocalizedMessage()); LOGGER.throwing(CLASS, METHOD, aioe); throw aioe; } @@ -497,7 +501,7 @@ public String getFileHash(String path) throws WLSDeployArchiveIOException { * @param appPath - File representing the actual path of the archive or directory in the file system * @return the relative path where the application will be unpacked by the unpackApplications() method * @throws WLSDeployArchiveIOException if an IOException occurred while reading or writing changes - * @throws IllegalArgumentException if the file or directory passed in does not exist + * @throws IllegalArgumentException if the file or directory passed in does not exist */ public String addApplication(File appPath) throws WLSDeployArchiveIOException { final String METHOD = "addApplication"; @@ -539,7 +543,26 @@ public String getATPWallet() throws WLSDeployArchiveIOException { LOGGER.entering(CLASS, METHOD); List result = getZipFile().listZipEntries(ARCHIVE_ATP_WALLET_PATH + ZIP_SEP); LOGGER.exiting(CLASS, METHOD, result); - if (result.size()>0) { + if (result.size() > 0) { + return result.get(0); + } else { + return null; + } + } + + /** + * Get the path of the OPSS wallet in the archive. + * + * @return path of the OPSS wallet + * @throws WLSDeployArchiveIOException if an error occurs reading the archive + */ + public String getOPSSWallet() throws WLSDeployArchiveIOException { + final String METHOD = "getOPSSWallet"; + + LOGGER.entering(CLASS, METHOD); + List result = getZipFile().listZipEntries(ARCHIVE_OPSS_WALLET_PATH + ZIP_SEP); + LOGGER.exiting(CLASS, METHOD, result); + if (result.size() > 0) { return result.get(0); } else { return null; @@ -550,10 +573,10 @@ public String getATPWallet() throws WLSDeployArchiveIOException { * Extract the specified application from the archive to the domain home directory. * * @param applicationPath the application path into the archive file - * @param domainHome the domain home directory + * @param domainHome the domain home directory * @throws WLSDeployArchiveIOException if an IOException occurred while reading the archive or writing the file - * @throws IllegalArgumentException if the file or directory passed in does not exist - * or the application path is empty + * @throws IllegalArgumentException if the file or directory passed in does not exist + * or the application path is empty */ public void extractApplication(String applicationPath, File domainHome) throws WLSDeployArchiveIOException { final String METHOD = "extractApplication"; @@ -578,7 +601,7 @@ public void extractApplication(String applicationPath, File domainHome) throws W * @param shlibPath - File representing the actual path of the archive or directory in the file system * @return the relative path where the shared library will be unpacked by the unpackSharedLibraries() method * @throws WLSDeployArchiveIOException if an IOException occurred while reading or writing changes - * @throws IllegalArgumentException if the file or directory passed in does not exist + * @throws IllegalArgumentException if the file or directory passed in does not exist */ public String addSharedLibrary(File shlibPath) throws WLSDeployArchiveIOException { final String METHOD = "addSharedLibrary"; @@ -612,10 +635,10 @@ public List listSharedLibraries() throws WLSDeployArchiveIOException { * Extract the specified shared library from the archive to the domain home directory. * * @param sharedLibraryPath the shared library path into the archive file - * @param domainHome the domain home directory + * @param domainHome the domain home directory * @throws WLSDeployArchiveIOException if an IOException occurred while reading the archive or writing the file - * @throws IllegalArgumentException if the file or directory passed in does not exist - * or the application path is empty + * @throws IllegalArgumentException if the file or directory passed in does not exist + * or the application path is empty */ public void extractSharedLibrary(String sharedLibraryPath, File domainHome) throws WLSDeployArchiveIOException { final String METHOD = "extractSharedLibrary"; @@ -640,7 +663,7 @@ public void extractSharedLibrary(String sharedLibraryPath, File domainHome) thro * @param domainLibPath - File representing the actual path of the archive or directory in the file system * @return the relative path where the library will be unpacked by the unpackApplications() method * @throws WLSDeployArchiveIOException if an IOException occurred while reading or writing changes - * @throws IllegalArgumentException if the file or directory passed in does not exist + * @throws IllegalArgumentException if the file or directory passed in does not exist */ public String addDomainLibLibrary(File domainLibPath) throws WLSDeployArchiveIOException { final String METHOD = "addDomainLibLibrary"; @@ -673,10 +696,10 @@ public List listDomainLibLibraries() throws WLSDeployArchiveIOException /** * Extract the specified domain library to the specified location (e.g., $DOMAIN_HOME/lib). * - * @param archivePath the path of the library within the archive + * @param archivePath the path of the library within the archive * @param extractToLocation the location to write the file * @throws WLSDeployArchiveIOException if an IOException occurred while extracting or writing the file - * @throws IllegalArgumentException if the file or directory passed in does not exist + * @throws IllegalArgumentException if the file or directory passed in does not exist */ public void extractDomainLibLibrary(String archivePath, File extractToLocation) throws WLSDeployArchiveIOException { final String METHOD = "extractDomainLibLibrary"; @@ -697,7 +720,7 @@ public void extractDomainLibLibrary(String archivePath, File extractToLocation) * @param libPath - File representing the actual path of the archive or directory in the file system * @return the relative path where the library will be unpacked by the unpackApplications() method * @throws WLSDeployArchiveIOException if an IOException occurred while reading or writing changes - * @throws IllegalArgumentException if the file or directory passed in does not exist + * @throws IllegalArgumentException if the file or directory passed in does not exist */ public String addClasspathLibrary(File libPath) throws WLSDeployArchiveIOException { final String METHOD = "addClasspathLibrary"; @@ -732,7 +755,7 @@ public List listClasspathLibraries() throws WLSDeployArchiveIOException * * @param domainHome the domain home directory * @throws WLSDeployArchiveIOException in an error occurs reading the archive or writing the files. - * @throws IllegalArgumentException if the domain home directory is not a valid, existing directory + * @throws IllegalArgumentException if the domain home directory is not a valid, existing directory */ public void extractClasspathLibraries(File domainHome) throws WLSDeployArchiveIOException { final String METHOD = "extractClasspathLibraries"; @@ -747,11 +770,11 @@ public void extractClasspathLibraries(File domainHome) throws WLSDeployArchiveIO /** * Adds an application's deployment plan file to the archive. * - * @param planFile the deployment plan file + * @param planFile the deployment plan file * @param preferredName the preferred name of the file to add * @return the actual name of the file in the archive * @throws WLSDeployArchiveIOException if an error occurs adding the file - * @throws IllegalArgumentException if the file does not exist or the preferredName was empty or null + * @throws IllegalArgumentException if the file does not exist or the preferredName was empty or null */ public String addApplicationDeploymentPlan(File planFile, String preferredName) throws WLSDeployArchiveIOException { final String METHOD = "addApplicationDeploymentPlan"; @@ -769,11 +792,11 @@ public String addApplicationDeploymentPlan(File planFile, String preferredName) /** * Adds a shared library's deployment plan file to the archive. * - * @param planFile the deployment plan file + * @param planFile the deployment plan file * @param preferredName the preferred name of the file to add * @return the actual name of the file in the archive * @throws WLSDeployArchiveIOException if an error occurs adding the file - * @throws IllegalArgumentException if the file does not exist or the preferredName was empty or null + * @throws IllegalArgumentException if the file does not exist or the preferredName was empty or null */ public String addSharedLibraryDeploymentPlan(File planFile, String preferredName) throws WLSDeployArchiveIOException { @@ -795,7 +818,7 @@ public String addSharedLibraryDeploymentPlan(File planFile, String preferredName * @param scriptFile the script file to add * @return the actual name of the file in the archive * @throws WLSDeployArchiveIOException if an error occurs adding the file - * @throws IllegalArgumentException if the file does not exist + * @throws IllegalArgumentException if the file does not exist */ public String addScript(File scriptFile) throws WLSDeployArchiveIOException { final String METHOD = "addScript"; @@ -811,11 +834,11 @@ public String addScript(File scriptFile) throws WLSDeployArchiveIOException { /** * Add a Server Identity Key Store file to the server's directory in the archive. * - * @param serverName the Server name used to segregate the directories + * @param serverName the Server name used to segregate the directories * @param keystoreFile the file to add * @return the new location of the file to use in the model * @throws WLSDeployArchiveIOException if an error occurs while archiving the file - * @throws IllegalArgumentException if the file does not exist or the clusterName is empty or null + * @throws IllegalArgumentException if the file does not exist or the clusterName is empty or null */ public String addServerKeyStoreFile(String serverName, File keystoreFile) throws WLSDeployArchiveIOException { final String METHOD = "addServerKeyStoreFile"; @@ -835,7 +858,7 @@ public String addServerKeyStoreFile(String serverName, File keystoreFile) throws * @param mimeMappingFile the file to add * @return the new location of the file to use in the model * @throws WLSDeployArchiveIOException if an error occurs while archiving the file - * @throws IllegalArgumentException if the file does not exist or the clusterName is empty or null + * @throws IllegalArgumentException if the file does not exist or the clusterName is empty or null */ public String addMimeMappingFile(File mimeMappingFile) throws WLSDeployArchiveIOException { final String METHOD = "addMimeMappingFile"; @@ -843,7 +866,7 @@ public String addMimeMappingFile(File mimeMappingFile) throws WLSDeployArchiveIO LOGGER.entering(CLASS, METHOD, mimeMappingFile); validateExistingFile(mimeMappingFile, "mimeMappingFile", getArchiveFileName(), METHOD); - String newName = addItemToZip(ARCHIVE_CONFIG_TARGET_DIR + ZIP_SEP , mimeMappingFile); + String newName = addItemToZip(ARCHIVE_CONFIG_TARGET_DIR + ZIP_SEP, mimeMappingFile); LOGGER.exiting(CLASS, METHOD, newName); return newName; } @@ -852,10 +875,10 @@ public String addMimeMappingFile(File mimeMappingFile) throws WLSDeployArchiveIO * Add a Coherence configuration file to the archive. * * @param clusterName the Coherence cluster name used to segregate the directories - * @param configFile the file to add + * @param configFile the file to add * @return thje new location of the file to use in the model * @throws WLSDeployArchiveIOException if an error occurs while archiving the file - * @throws IllegalArgumentException if the file does not exist or the clusterName is empty or null + * @throws IllegalArgumentException if the file does not exist or the clusterName is empty or null */ public String addCoherenceConfigFile(String clusterName, File configFile) throws WLSDeployArchiveIOException { final String METHOD = "addCoherenceConfigFile"; @@ -872,11 +895,11 @@ public String addCoherenceConfigFile(String clusterName, File configFile) throws /** * Add a Coherence configuration file to the archive from an http site. * - * @param clusterName the Coherence cluster name used to segregate the directories + * @param clusterName the Coherence cluster name used to segregate the directories * @param urlForConfigFile a file object representing the path at the remote url * @return the new location of the file to use in the model * @throws WLSDeployArchiveIOException if an error occurs while archiving the file - * @throws IllegalArgumentException if the clusterName is empty or null or the urlForConfigFile is null + * @throws IllegalArgumentException if the clusterName is empty or null or the urlForConfigFile is null */ public String addCoherenceConfigFileFromUrl(String clusterName, URL urlForConfigFile) throws WLSDeployArchiveIOException { @@ -886,8 +909,8 @@ public String addCoherenceConfigFileFromUrl(String clusterName, URL urlForConfig validateNonEmptyString(clusterName, "clusterName", METHOD); validateNonNullObject(urlForConfigFile, "urlForConfigFile", METHOD); - String newName = addUrlToZip(ARCHIVE_COHERENCE_TARGET_DIR + ZIP_SEP + clusterName, - urlForConfigFile, COHERENCE_CONFIG_FILE_EXTENSION, true); + String newName = addUrlToZip(ARCHIVE_COHERENCE_TARGET_DIR + ZIP_SEP + clusterName, urlForConfigFile, + COHERENCE_CONFIG_FILE_EXTENSION, true); LOGGER.exiting(CLASS, METHOD, newName); return newName; } @@ -895,13 +918,14 @@ public String addCoherenceConfigFileFromUrl(String clusterName, URL urlForConfig /** * Add an empty directory to the archive file for the coherence cluster using the persistence directory type value. * The directory type is stored under the unique coherence cluster name. - * @param clusterName name of the coherence cluster to which the persistence directory belongs + * + * @param clusterName name of the coherence cluster to which the persistence directory belongs * @param directoryType type of the coherence cluster persistence directory * @return unique directory name * @throws WLSDeployArchiveIOException unexpected exception adding the directory name to the archive file */ - public String addCoherencePersistenceDirectory(String clusterName, String directoryType) throws - WLSDeployArchiveIOException { + public String addCoherencePersistenceDirectory(String clusterName, String directoryType) + throws WLSDeployArchiveIOException { final String METHOD = "addCoherencePersistenceDirectory"; LOGGER.entering(CLASS, METHOD, clusterName, directoryType); @@ -914,12 +938,12 @@ public String addCoherencePersistenceDirectory(String clusterName, String direct /** * Add an empty directory to the archive file using the File Store name. + * * @param fileStoreName name of the File Store * @return unique directory name created using the file store name * @throws WLSDeployArchiveIOException unexpected exception adding the directory name to the archive file */ - public String addFileStoreDirectory(String fileStoreName) throws - WLSDeployArchiveIOException { + public String addFileStoreDirectory(String fileStoreName) throws WLSDeployArchiveIOException { final String METHOD = "addFileStoreDirectory"; LOGGER.entering(CLASS, METHOD, fileStoreName); @@ -935,7 +959,7 @@ public String addFileStoreDirectory(String fileStoreName) throws * @param keystoreFile the file to add * @return the new location of the file to use in the model * @throws WLSDeployArchiveIOException if an error occurs while archiving the file - * @throws IllegalArgumentException if the file does not exist + * @throws IllegalArgumentException if the file does not exist */ public String addNodeManagerKeyStoreFile(File keystoreFile) throws WLSDeployArchiveIOException { final String METHOD = "addNodeManagerKeyStoreFile"; @@ -1142,8 +1166,9 @@ protected void extractDirectoryFromZip(String fromDirectoryName, String toDirect targetDirectory = targetFile.getParentFile(); } if (!targetDirectory.exists() && !targetDirectory.mkdirs()) { - WLSDeployArchiveIOException wdaioe = new WLSDeployArchiveIOException("WLSDPLY-01414", - getArchiveFileName(), targetDirectory.getAbsolutePath()); + WLSDeployArchiveIOException wdaioe = + new WLSDeployArchiveIOException("WLSDPLY-01414", getArchiveFileName(), + targetDirectory.getAbsolutePath()); LOGGER.throwing(CLASS, METHOD, wdaioe); throw wdaioe; } @@ -1160,8 +1185,9 @@ protected void extractDirectoryFromZip(String fromDirectoryName, String toDirect } } } catch (IOException ioe) { - WLSDeployArchiveIOException wdaioe = new WLSDeployArchiveIOException("WLSDPLY-01415", ioe, - getArchiveFileName(), targetFile.getAbsolutePath(), ioe.getLocalizedMessage()); + WLSDeployArchiveIOException wdaioe = + new WLSDeployArchiveIOException("WLSDPLY-01415", ioe, getArchiveFileName(), + targetFile.getAbsolutePath(), ioe.getLocalizedMessage()); LOGGER.throwing(CLASS, METHOD, wdaioe); throw wdaioe; } finally { @@ -1171,8 +1197,7 @@ protected void extractDirectoryFromZip(String fromDirectoryName, String toDirect LOGGER.exiting(CLASS, METHOD); } - protected void extractFileFromZip(String itemToExtract, File extractToLocation) - throws WLSDeployArchiveIOException { + protected void extractFileFromZip(String itemToExtract, File extractToLocation) throws WLSDeployArchiveIOException { extractFileFromZip(itemToExtract, null, null, extractToLocation); } @@ -1193,8 +1218,8 @@ protected void extractFileFromZip(String itemToExtract, String fromDir, String t File targetFile = new File(extractToLocation, targetFileName); File targetDirectory = targetFile.getParentFile(); if (!targetDirectory.exists() && !targetDirectory.mkdirs()) { - WLSDeployArchiveIOException wdaioe = new WLSDeployArchiveIOException("WLSDPLY-01414", - getArchiveFileName(), targetDirectory.getAbsolutePath()); + WLSDeployArchiveIOException wdaioe = new WLSDeployArchiveIOException("WLSDPLY-01414", getArchiveFileName(), + targetDirectory.getAbsolutePath()); LOGGER.throwing(CLASS, METHOD, wdaioe); throw wdaioe; } @@ -1202,8 +1227,9 @@ protected void extractFileFromZip(String itemToExtract, String fromDir, String t try (FileOutputStream outputStream = new FileOutputStream(targetFile, false)) { copyFile(inputStream, outputStream); } catch (IOException ioe) { - WLSDeployArchiveIOException wdaioe = new WLSDeployArchiveIOException("WLSDPLY-01415", ioe, - getArchiveFileName(), targetFile.getAbsolutePath(), ioe.getLocalizedMessage()); + WLSDeployArchiveIOException wdaioe = + new WLSDeployArchiveIOException("WLSDPLY-01415", ioe, getArchiveFileName(), + targetFile.getAbsolutePath(), ioe.getLocalizedMessage()); LOGGER.throwing(CLASS, METHOD, wdaioe); throw wdaioe; } finally { @@ -1373,8 +1399,9 @@ private static FileInputStream getFileInputStream(File f, String itemName, Strin try { inputStream = new FileInputStream(f); } catch (IOException ioe) { - WLSDeployArchiveIOException wdaioe = new WLSDeployArchiveIOException("WLSDPLY-01425", ioe, archiveName, - f.getAbsolutePath(), itemName, ioe.getLocalizedMessage()); + WLSDeployArchiveIOException wdaioe = + new WLSDeployArchiveIOException("WLSDPLY-01425", ioe, archiveName, f.getAbsolutePath(), itemName, + ioe.getLocalizedMessage()); LOGGER.throwing(CLASS, callingMethod, wdaioe); throw wdaioe; } diff --git a/core/src/main/python/create.py b/core/src/main/python/create.py index ceee3c5436..9b6643bd6e 100644 --- a/core/src/main/python/create.py +++ b/core/src/main/python/create.py @@ -5,6 +5,7 @@ The main module for the WLSDeploy tool to create empty domains. """ import javaos as os +import jarray import sys from java.io import IOException from java.lang import IllegalArgumentException @@ -330,6 +331,8 @@ def validateRCUArgsAndModel(model_context, model, alias_helper): return has_atpdbinfo + + def main(args): """ The entry point for the create domain tool. @@ -408,6 +411,7 @@ def main(args): rcu_db_info = RcuDbInfo(alias_helper, rcu_properties_map) atp_helper.fix_jps_config(rcu_db_info, model_context) + except WLSDeployArchiveIOException, ex: __logger.severe('WLSDPLY-12409', _program_name, ex.getLocalizedMessage(), error=ex, class_name=_class_name, method_name=_method_name) diff --git a/core/src/main/python/wlsdeploy/aliases/alias_entries.py b/core/src/main/python/wlsdeploy/aliases/alias_entries.py index f1fefc9f13..988e7d6956 100644 --- a/core/src/main/python/wlsdeploy/aliases/alias_entries.py +++ b/core/src/main/python/wlsdeploy/aliases/alias_entries.py @@ -185,7 +185,8 @@ class AliasEntries(object): # the ServerGroup is not listed in this map, it will be targeted to all managed # servers in the domain. 'ServerGroupTargetingLimits': 'dict', - 'RCUDbInfo' : 'dict' + 'RCUDbInfo': 'dict', + 'OPSSSecrets': 'string' } __domain_name_token = 'DOMAIN' diff --git a/core/src/main/python/wlsdeploy/aliases/model_constants.py b/core/src/main/python/wlsdeploy/aliases/model_constants.py index 6443b88d5d..f0245ce9f6 100644 --- a/core/src/main/python/wlsdeploy/aliases/model_constants.py +++ b/core/src/main/python/wlsdeploy/aliases/model_constants.py @@ -19,6 +19,7 @@ APP_DIR = 'AppDir' APPLICATION = 'Application' RCU_DB_INFO = 'RCUDbInfo' +OPSS_SECRETS = 'OPSSSecrets' RCU_PREFIX = 'rcu_prefix' RCU_SCHEMA_PASSWORD = 'rcu_schema_password' RCU_ADMIN_PASSWORD = 'rcu_admin_password' diff --git a/core/src/main/python/wlsdeploy/tool/create/domain_creator.py b/core/src/main/python/wlsdeploy/tool/create/domain_creator.py index ceb326850d..4dbe9f680d 100644 --- a/core/src/main/python/wlsdeploy/tool/create/domain_creator.py +++ b/core/src/main/python/wlsdeploy/tool/create/domain_creator.py @@ -3,6 +3,7 @@ The Universal Permissive License (UPL), Version 1.0 """ import javaos as os +import jarray from oracle.weblogic.deploy.create import RCURunner from wlsdeploy.aliases.location_context import LocationContext from wlsdeploy.aliases.model_constants import ADMIN_PASSWORD @@ -39,6 +40,7 @@ from wlsdeploy.aliases.model_constants import MACHINE from wlsdeploy.aliases.model_constants import MIGRATABLE_TARGET from wlsdeploy.aliases.model_constants import NAME +from wlsdeploy.aliases.model_constants import OPSS_SECRETS from wlsdeploy.aliases.model_constants import PARTITION from wlsdeploy.aliases.model_constants import PASSWORD from wlsdeploy.aliases.model_constants import PASSWORD_ENCRYPTED @@ -80,6 +82,9 @@ from wlsdeploy.tool.util.topology_helper import TopologyHelper from wlsdeploy.util import dictionary_utils from wlsdeploy.util import model as model_helper +from java.io import File, FileInputStream, FileOutputStream +from java.util.zip import ZipInputStream +from oracle.weblogic.deploy.util import WLSDeployArchive class DomainCreator(Creator): @@ -161,6 +166,8 @@ def create(self): self.__fail_mt_1221_domain_creation() self.__create_domain() self.__deploy() + + self.logger.exiting(class_name=self.__class_name, method_name=_method_name) return @@ -345,6 +352,9 @@ def __deploy(self): self.__set_domain_attributes() self._configure_security_configuration() self.__deploy_resources_and_apps() + + + self.wlst_helper.update_domain() self.wlst_helper.close_domain() return @@ -1093,3 +1103,52 @@ def _configure_security_configuration(self): self.security_provider_creator.create_security_configuration(security_config_location) self.logger.exiting(class_name=self.__class_name, method_name=_method_name) return + + def __configure_opss_secrets(self, model_context, model): + _method_name = '__configure_opss_secrets' + self.logger.entering(class_name=self.__class_name, method_name=_method_name) + + extract_path = None + domain_info = self._domain_info + if domain_info is not None: + if OPSS_SECRETS in domain_info: + opss_secret_password = domain_info[OPSS_SECRETS] + + if model_context.get_archive_file_name() and opss_secret_password: + archive_file = WLSDeployArchive(model_context.get_archive_file_name()) + if archive_file: + opss_wallet_zipentry = archive_file.getOPSSWallet() + if opss_wallet_zipentry: + domain_path = self._domain_home + extract_path = domain_path + os.sep + 'opsswallet' + extract_dir = File(extract_path) + extract_dir.mkdirs() + wallet_zip = archive_file.extractFile(opss_wallet_zipentry, File(domain_path)) + + if not os.path.exists(extract_path): + os.mkdir(extract_path) + + buffer = jarray.zeros(1024, "b") + fis = FileInputStream(wallet_zip) + zis = ZipInputStream(fis) + ze = zis.getNextEntry() + while ze: + fileName = ze.getName() + newFile = File(extract_path + File.separator + fileName) + File(newFile.getParent()).mkdirs() + fos = FileOutputStream(newFile) + len = zis.read(buffer) + while len > 0: + fos.write(buffer, 0, len) + len = zis.read(buffer) + + fos.close() + zis.closeEntry() + ze = zis.getNextEntry() + zis.closeEntry() + zis.close() + fis.close() + os.remove(wallet_zip) + #self.wlst_helper.setSharedSecretStoreWithPassword(extract_path, opss_secret_password) + self.logger.exiting(class_name=self.__class_name, method_name=_method_name) + return extract_path diff --git a/core/src/main/python/wlsdeploy/tool/util/wlst_helper.py b/core/src/main/python/wlsdeploy/tool/util/wlst_helper.py index e31b6b2c56..14ef44e70f 100644 --- a/core/src/main/python/wlsdeploy/tool/util/wlst_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/wlst_helper.py @@ -1047,3 +1047,13 @@ def reopen(self, model_context): pwe.getLocalizedMessage(), error=pwe) self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name) raise ex + + def setSharedSecretStoreWithPassword(self, wallet_path, password): + try: + wlst_helper.set_shared_secret_store_with_password(wallet_path, password) + except PyWLSTException, pwe: + ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19144', + pwe.getLocalizedMessage(), error=pwe) + self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name) + raise ex + _method_name = 'setSharedSecretStoreWithPassword' diff --git a/core/src/main/python/wlsdeploy/util/wlst_helper.py b/core/src/main/python/wlsdeploy/util/wlst_helper.py index ed930565d9..644079ef24 100644 --- a/core/src/main/python/wlsdeploy/util/wlst_helper.py +++ b/core/src/main/python/wlsdeploy/util/wlst_helper.py @@ -1395,3 +1395,11 @@ def reopen_offline(domain_home): _logger.fine('WLSDPLY-00081', class_name=_class_name, method_name=_method_name) read_domain(domain_home) _logger.exiting(class_name=_class_name, method_name=_method_name) + + +def set_shared_secret_store_with_password(wallet_path, password): + _method_name = 'setSharedSecretStoreWithPassword' + _logger.fine('WLSDPLY-00081', class_name=_class_name, method_name=_method_name) + setSharedSecretStoreWithPassword(wallet_path,password) + _logger.exiting(class_name=_class_name, method_name=_method_name) + From 816b3b7f256c4c8092b149c108498cce24462a57 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Thu, 6 Jun 2019 13:31:26 -0500 Subject: [PATCH 2/4] complete logic for opss secret --- .../python/wlsdeploy/tool/create/domain_creator.py | 11 +++++------ core/src/main/python/wlsdeploy/util/wlst_helper.py | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/core/src/main/python/wlsdeploy/tool/create/domain_creator.py b/core/src/main/python/wlsdeploy/tool/create/domain_creator.py index 4dbe9f680d..2125ef473f 100644 --- a/core/src/main/python/wlsdeploy/tool/create/domain_creator.py +++ b/core/src/main/python/wlsdeploy/tool/create/domain_creator.py @@ -353,7 +353,7 @@ def __deploy(self): self._configure_security_configuration() self.__deploy_resources_and_apps() - + self.__configure_opss_secrets() self.wlst_helper.update_domain() self.wlst_helper.close_domain() @@ -1104,7 +1104,7 @@ def _configure_security_configuration(self): self.logger.exiting(class_name=self.__class_name, method_name=_method_name) return - def __configure_opss_secrets(self, model_context, model): + def __configure_opss_secrets(self): _method_name = '__configure_opss_secrets' self.logger.entering(class_name=self.__class_name, method_name=_method_name) @@ -1113,9 +1113,8 @@ def __configure_opss_secrets(self, model_context, model): if domain_info is not None: if OPSS_SECRETS in domain_info: opss_secret_password = domain_info[OPSS_SECRETS] - - if model_context.get_archive_file_name() and opss_secret_password: - archive_file = WLSDeployArchive(model_context.get_archive_file_name()) + if self.model_context.get_archive_file_name() and opss_secret_password: + archive_file = WLSDeployArchive(self.model_context.get_archive_file_name()) if archive_file: opss_wallet_zipentry = archive_file.getOPSSWallet() if opss_wallet_zipentry: @@ -1149,6 +1148,6 @@ def __configure_opss_secrets(self, model_context, model): zis.close() fis.close() os.remove(wallet_zip) - #self.wlst_helper.setSharedSecretStoreWithPassword(extract_path, opss_secret_password) + self.wlst_helper.setSharedSecretStoreWithPassword(extract_path, opss_secret_password) self.logger.exiting(class_name=self.__class_name, method_name=_method_name) return extract_path diff --git a/core/src/main/python/wlsdeploy/util/wlst_helper.py b/core/src/main/python/wlsdeploy/util/wlst_helper.py index 644079ef24..f3cc73cd1d 100644 --- a/core/src/main/python/wlsdeploy/util/wlst_helper.py +++ b/core/src/main/python/wlsdeploy/util/wlst_helper.py @@ -1400,6 +1400,6 @@ def reopen_offline(domain_home): def set_shared_secret_store_with_password(wallet_path, password): _method_name = 'setSharedSecretStoreWithPassword' _logger.fine('WLSDPLY-00081', class_name=_class_name, method_name=_method_name) - setSharedSecretStoreWithPassword(wallet_path,password) + wlst.setSharedSecretStoreWithPassword(wallet_path,password) _logger.exiting(class_name=_class_name, method_name=_method_name) From 802b81424665cf970fe5c4b602f807d58a5f8ea5 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Thu, 6 Jun 2019 14:51:28 -0500 Subject: [PATCH 3/4] fix _method name --- core/src/main/python/wlsdeploy/util/wlst_helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/python/wlsdeploy/util/wlst_helper.py b/core/src/main/python/wlsdeploy/util/wlst_helper.py index b00903c520..102203a06a 100644 --- a/core/src/main/python/wlsdeploy/util/wlst_helper.py +++ b/core/src/main/python/wlsdeploy/util/wlst_helper.py @@ -1403,7 +1403,7 @@ def set_shared_secret_store_with_password(wallet_path, password): :param wallet_path: opss extracted wallet :param password: opss store extraction time password """ - _method_name = 'setSharedSecretStoreWithPassword' + _method_name = 'set_shared_secret_store_with_password' _logger.fine('WLSDPLY-00081', class_name=_class_name, method_name=_method_name) wlst.setSharedSecretStoreWithPassword(wallet_path,password) _logger.exiting(class_name=_class_name, method_name=_method_name) From 10e46936adb0a18e99c8a3e9fd4ee97e05b1c7f6 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Fri, 7 Jun 2019 09:47:32 -0500 Subject: [PATCH 4/4] refactoring --- .../weblogic/deploy/util/FileUtils.java | 55 ++++++++++++++++++ .../wlsdeploy/tool/create/atp_helper.py | 44 ++------------- .../wlsdeploy/tool/create/domain_creator.py | 56 ++++--------------- .../deploy/messages/wlsdeploy_rb.properties | 2 +- 4 files changed, 72 insertions(+), 85 deletions(-) diff --git a/core/src/main/java/oracle/weblogic/deploy/util/FileUtils.java b/core/src/main/java/oracle/weblogic/deploy/util/FileUtils.java index fcf689d805..6b397d111e 100644 --- a/core/src/main/java/oracle/weblogic/deploy/util/FileUtils.java +++ b/core/src/main/java/oracle/weblogic/deploy/util/FileUtils.java @@ -12,12 +12,15 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; +import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Locale; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; import javax.xml.bind.DatatypeConverter; @@ -632,6 +635,56 @@ public static File writeInputStreamToFile(InputStream input, String fileName) th return file; } + + public static void extractZipFileContent(WLSDeployArchive archiveFile, String zipEntry, String extractPath) { + final String METHOD = "extractZipFileContent"; + + try { + + if (zipEntry != null) { + + File extractDir = new File(extractPath); + extractDir.mkdirs(); + String walletZip = archiveFile.extractFile(zipEntry, + Files.createTempDirectory("tempwallet").toFile()); + + if (!Files.exists(Paths.get(extractPath))) { + Files.createDirectory(Paths.get(extractPath)); + } + + byte[] buffer = new byte[1024]; + FileInputStream fis = new FileInputStream(walletZip); + ZipInputStream zis = new ZipInputStream(fis); + ZipEntry ze = zis.getNextEntry(); + while (ze != null) { + String fileName = ze.getName(); + File newFile = new File(extractPath + File.separator + fileName); + new File(newFile.getParent()).mkdirs(); + FileOutputStream fos = new FileOutputStream(newFile); + int len = zis.read(buffer); + while (len > 0) { + fos.write(buffer, 0, len); + len = zis.read(buffer); + } + fos.close(); + zis.closeEntry(); + ze = zis.getNextEntry(); + + } + zis.closeEntry(); + zis.close(); + fis.close(); + Files.delete(Paths.get(walletZip)); + } + } catch (IOException | WLSDeployArchiveIOException ioe) { + String message = ExceptionHelper.getMessage("WLSDPLY-01118", METHOD, CLASS, ioe.getLocalizedMessage()); + IllegalArgumentException iae = new IllegalArgumentException(message); + LOGGER.throwing(CLASS, METHOD, iae); + throw iae; + + } + + } /////////////////////////////////////////////////////////////////////////// // Private helper methods // /////////////////////////////////////////////////////////////////////////// @@ -718,4 +771,6 @@ public boolean accept(File dir, String name) { return result; } } + + } diff --git a/core/src/main/python/wlsdeploy/tool/create/atp_helper.py b/core/src/main/python/wlsdeploy/tool/create/atp_helper.py index 55ad666609..526a5e7fb5 100644 --- a/core/src/main/python/wlsdeploy/tool/create/atp_helper.py +++ b/core/src/main/python/wlsdeploy/tool/create/atp_helper.py @@ -5,17 +5,12 @@ """ -import os, re - -from xml.dom.minidom import parse - +import os +import re from java.io import File -from java.io import FileInputStream -from java.io import FileOutputStream -from java.util.zip import ZipInputStream -import jarray - +from oracle.weblogic.deploy.util import FileUtils from wlsdeploy.aliases import model_constants +from xml.dom.minidom import parse def set_ssl_properties(xmlDoc, atp_creds_path, keystore_password, truststore_password): @@ -61,34 +56,6 @@ def set_property(DOMTree, prop, name, value): newline = DOMTree.createTextNode('\n') prop.appendChild(newline) - -def unzip_atp_wallet(wallet_file, location): - - if not os.path.exists(location): - os.mkdir(location) - - buffer = jarray.zeros(1024, "b") - fis = FileInputStream(wallet_file) - zis = ZipInputStream(fis) - ze = zis.getNextEntry() - while ze: - fileName = ze.getName() - newFile = File(location + File.separator + fileName) - File(newFile.getParent()).mkdirs() - fos = FileOutputStream(newFile) - len = zis.read(buffer) - while len > 0: - fos.write(buffer, 0, len) - len = zis.read(buffer) - - fos.close() - zis.closeEntry() - ze = zis.getNextEntry() - zis.closeEntry() - zis.close() - fis.close() - - def fix_jps_config(rcu_db_info, model_context): tns_admin = rcu_db_info.get_atp_tns_admin() keystore_password = rcu_db_info.get_keystore_password() @@ -163,7 +130,6 @@ def extract_walletzip(model, model_context, archive_file, atp_zipentry): extract_dir = File(extract_path) extract_dir.mkdirs() wallet_zip = archive_file.extractFile(atp_zipentry, File(domain_path)) - unzip_atp_wallet(wallet_zip, extract_path) - os.remove(wallet_zip) + FileUtils.extractZipFileContent(archive_file, wallet_zip, extract_path) return extract_path # update the model to add the tns_admin diff --git a/core/src/main/python/wlsdeploy/tool/create/domain_creator.py b/core/src/main/python/wlsdeploy/tool/create/domain_creator.py index 8678afe7d1..6695ceebc5 100644 --- a/core/src/main/python/wlsdeploy/tool/create/domain_creator.py +++ b/core/src/main/python/wlsdeploy/tool/create/domain_creator.py @@ -3,24 +3,21 @@ The Universal Permissive License (UPL), Version 1.0 """ import javaos as os -import jarray -from java.util import Properties -from java.io import File, FileInputStream, FileOutputStream -from oracle.weblogic.deploy.create import RCURunner -from java.util.zip import ZipInputStream -from oracle.weblogic.deploy.util import WLSDeployArchive import weblogic.security.internal.SerializedSystemIni as SerializedSystemIni import weblogic.security.internal.encryption.ClearOrEncryptedService as ClearOrEncryptedService - +from java.io import FileOutputStream +from java.util import Properties +from oracle.weblogic.deploy.create import RCURunner +from oracle.weblogic.deploy.util import WLSDeployArchive, FileUtils from wlsdeploy.aliases.location_context import LocationContext from wlsdeploy.aliases.model_constants import ADMIN_PASSWORD from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME from wlsdeploy.aliases.model_constants import ADMIN_USERNAME from wlsdeploy.aliases.model_constants import APP_DIR from wlsdeploy.aliases.model_constants import ATP_ADMIN_USER -from wlsdeploy.aliases.model_constants import ATP_TNS_ENTRY from wlsdeploy.aliases.model_constants import ATP_DEFAULT_TABLESPACE from wlsdeploy.aliases.model_constants import ATP_TEMPORARY_TABLESPACE +from wlsdeploy.aliases.model_constants import ATP_TNS_ENTRY from wlsdeploy.aliases.model_constants import CLUSTER from wlsdeploy.aliases.model_constants import CREATE_ONLY_DOMAIN_ATTRIBUTES from wlsdeploy.aliases.model_constants import DEFAULT_ADMIN_SERVER_NAME @@ -51,11 +48,11 @@ from wlsdeploy.aliases.model_constants import PARTITION from wlsdeploy.aliases.model_constants import PASSWORD from wlsdeploy.aliases.model_constants import PASSWORD_ENCRYPTED +from wlsdeploy.aliases.model_constants import RCU_ADMIN_PASSWORD from wlsdeploy.aliases.model_constants import RCU_DB_CONN from wlsdeploy.aliases.model_constants import RCU_DB_INFO from wlsdeploy.aliases.model_constants import RCU_PREFIX from wlsdeploy.aliases.model_constants import RCU_SCHEMA_PASSWORD -from wlsdeploy.aliases.model_constants import RCU_ADMIN_PASSWORD from wlsdeploy.aliases.model_constants import RESOURCE_GROUP from wlsdeploy.aliases.model_constants import RESOURCE_GROUP_TEMPLATE from wlsdeploy.aliases.model_constants import SECURITY @@ -77,8 +74,8 @@ from wlsdeploy.exception import exception_helper from wlsdeploy.exception.expection_types import ExceptionType from wlsdeploy.tool.create import atp_helper -from wlsdeploy.tool.create.rcudbinfo_helper import RcuDbInfo from wlsdeploy.tool.create.creator import Creator +from wlsdeploy.tool.create.rcudbinfo_helper import RcuDbInfo from wlsdeploy.tool.create.security_provider_creator import SecurityProviderCreator from wlsdeploy.tool.deploy import deployer_utils from wlsdeploy.tool.deploy import model_deployer @@ -1138,7 +1135,6 @@ def __create_boot_dot_properties(self): def __configure_opss_secrets(self): _method_name = '__configure_opss_secrets' self.logger.entering(class_name=self.__class_name, method_name=_method_name) - extract_path = None domain_info = self._domain_info if domain_info is not None: @@ -1146,39 +1142,9 @@ def __configure_opss_secrets(self): opss_secret_password = domain_info[OPSS_SECRETS] if self.model_context.get_archive_file_name() and opss_secret_password: archive_file = WLSDeployArchive(self.model_context.get_archive_file_name()) - if archive_file: - opss_wallet_zipentry = archive_file.getOPSSWallet() - if opss_wallet_zipentry: - domain_path = self._domain_home - extract_path = domain_path + os.sep + 'opsswallet' - extract_dir = File(extract_path) - extract_dir.mkdirs() - wallet_zip = archive_file.extractFile(opss_wallet_zipentry, File(domain_path)) - - if not os.path.exists(extract_path): - os.mkdir(extract_path) - - buffer = jarray.zeros(1024, "b") - fis = FileInputStream(wallet_zip) - zis = ZipInputStream(fis) - ze = zis.getNextEntry() - while ze: - fileName = ze.getName() - newFile = File(extract_path + File.separator + fileName) - File(newFile.getParent()).mkdirs() - fos = FileOutputStream(newFile) - len = zis.read(buffer) - while len > 0: - fos.write(buffer, 0, len) - len = zis.read(buffer) - - fos.close() - zis.closeEntry() - ze = zis.getNextEntry() - zis.closeEntry() - zis.close() - fis.close() - os.remove(wallet_zip) - self.wlst_helper.setSharedSecretStoreWithPassword(extract_path, opss_secret_password) + extract_path = self._domain_home + os.sep + 'opsswallet' + zip_entry = archive_file.getOPSSWallet(); + FileUtils.extractZipFileContent(archive_file, zip_entry, extract_path) + self.wlst_helper.setSharedSecretStoreWithPassword(extract_path, opss_secret_password) self.logger.exiting(class_name=self.__class_name, method_name=_method_name) return extract_path diff --git a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties index 9a4b899ade..2432502e90 100644 --- a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties +++ b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties @@ -128,7 +128,7 @@ WLSDPLY-01114=Deleting the file {1} in directory {0} WLSDPLY-01115=Unable to delete file {0} from directory {1} WLSDPLY-01116=Unable to successfully delete the directory {0} WLSDPLY-01117=Model directory {0} has more than one {1} file, found {2} after previously finding {3} - +WLSDPLY-01118=Error extracting zipentry zip file {0} # oracle.weblogic.deploy.util.ProcessHandler.java WLSDPLY-01200=Process for command {0} isRunning() unable to get an exit value: {1} WLSDPLY-01201=ProcessHandler had no registered wait handler when asked to exec() command: {0}