Skip to content

Commit 7a975bc

Browse files
authored
no functional changes, only static code cleanup (#309)
1 parent 3dce7a5 commit 7a975bc

File tree

9 files changed

+22
-28
lines changed

9 files changed

+22
-28
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) 2021, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package com.oracle.weblogic.imagetool.aru;
5+
6+
import com.oracle.weblogic.imagetool.util.Utils;
7+
8+
public class InvalidCredential extends AruException {
9+
public InvalidCredential() {
10+
super(Utils.getMessage("IMG-0022"));
11+
}
12+
}

imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/MultiplePatchVersionsException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.util.List;
88
import java.util.stream.Collectors;
99

10-
import com.oracle.weblogic.imagetool.aru.AruPatch;
1110
import com.oracle.weblogic.imagetool.util.Utils;
1211

1312
public class MultiplePatchVersionsException extends IOException {

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/cache/AddPatchEntry.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import java.util.List;
88

99
import com.oracle.weblogic.imagetool.api.model.CommandResponse;
10-
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
11-
import com.oracle.weblogic.imagetool.logging.LoggingFactory;
1210
import com.oracle.weblogic.imagetool.util.Utils;
1311
import picocli.CommandLine.Command;
1412
import picocli.CommandLine.Option;
@@ -20,8 +18,6 @@
2018
)
2119
public class AddPatchEntry extends CacheAddOperation {
2220

23-
private static final LoggingFacade logger = LoggingFactory.getLogger(AddPatchEntry.class);
24-
2521
@Override
2622
public CommandResponse call() throws Exception {
2723

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.oracle.weblogic.imagetool.aru.AruProduct;
2525
import com.oracle.weblogic.imagetool.aru.AruUtil;
2626
import com.oracle.weblogic.imagetool.aru.InstalledPatch;
27+
import com.oracle.weblogic.imagetool.aru.InvalidCredential;
2728
import com.oracle.weblogic.imagetool.aru.InvalidPatchNumberException;
2829
import com.oracle.weblogic.imagetool.aru.MultiplePatchVersionsException;
2930
import com.oracle.weblogic.imagetool.builder.BuildCommand;
@@ -162,20 +163,18 @@ void setTempDirectory(String value) {
162163
tempDirectory = value;
163164
}
164165

165-
void init(String buildId) throws Exception {
166+
void init(String buildId) throws InvalidCredential, IOException {
166167
logger.entering(buildId);
167168
logger.info(HelpVersionProvider.versionString());
168169
dockerfileOptions = new DockerfileOptions(buildId);
169170
logger.info("IMG-0016", buildId);
170171

171172
handleProxyUrls();
172173
password = Utils.getPasswordFromInputs(passwordStr, passwordFile, passwordEnv);
173-
// check user support credentials if useCache not set to always and we are applying any patches
174174

175-
if (userId != null || password != null) {
176-
if (!AruUtil.checkCredentials(userId, password)) {
177-
throw new Exception("user Oracle support credentials do not match");
178-
}
175+
// if userid or password is provided, validate the pair of provided values
176+
if ((userId != null || password != null) && !AruUtil.checkCredentials(userId, password)) {
177+
throw new InvalidCredential();
179178
}
180179

181180
handleChown();

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CreateImage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public CommandResponse call() throws Exception {
9393
Utils.setInventoryLocation(inventoryPointerFile, dockerfileOptions);
9494
Utils.copyLocalFile(Paths.get(inventoryPointerFile), Paths.get(tmpDir, "/oraInst.loc"), false);
9595
} else {
96-
Utils.copyResourceAsFile("/response-files/oraInst.loc", tmpDir, false);
96+
Utils.copyResourceAsFile("/response-files/oraInst.loc", tmpDir);
9797
}
9898

9999
// Create Dockerfile

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/RebaseImage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public CommandResponse call() throws Exception {
150150
Utils.setInventoryLocation(inventoryPointerFile, dockerfileOptions);
151151
Utils.copyLocalFile(Paths.get(inventoryPointerFile), Paths.get(tmpDir,"/oraInst.loc"), false);
152152
} else {
153-
Utils.copyResourceAsFile("/response-files/oraInst.loc", tmpDir, false);
153+
Utils.copyResourceAsFile("/response-files/oraInst.loc", tmpDir);
154154
}
155155
}
156156

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/HttpUtil.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.apache.http.entity.mime.MultipartEntityBuilder;
3636
import org.apache.http.impl.client.BasicCookieStore;
3737
import org.apache.http.impl.client.BasicCredentialsProvider;
38-
import org.apache.http.impl.client.CloseableHttpClient;
3938
import org.apache.http.impl.client.HttpClientBuilder;
4039
import org.w3c.dom.Document;
4140
import org.xml.sax.InputSource;
@@ -237,11 +236,6 @@ public static Document postCheckConflictRequest(String url, String payload, Stri
237236

238237
CookieStore cookieStore = new BasicCookieStore();
239238

240-
CloseableHttpClient client =
241-
HttpClientBuilder.create().setDefaultRequestConfig(config.build())
242-
.setUserAgent("Wget/1.10")
243-
.useSystemProperties().build();
244-
245239
Executor httpExecutor = HttpUtil.getHttpExecutor(username, password);
246240
httpExecutor.use(cookieStore);
247241

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/Utils.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@ private Utils() {
6464
*
6565
* @param resourcePath resource path in the jar
6666
* @param destPath local file to copy to.
67-
* @param markExec sets the executable flag if true
6867
* @throws IOException in case of error
6968
*/
70-
public static void copyResourceAsFile(String resourcePath, String destPath, boolean markExec) throws IOException {
69+
public static void copyResourceAsFile(String resourcePath, String destPath) throws IOException {
7170
Objects.requireNonNull(resourcePath);
7271
Objects.requireNonNull(destPath);
7372
if (Files.isDirectory(Paths.get(destPath))) {
@@ -79,11 +78,6 @@ public static void copyResourceAsFile(String resourcePath, String destPath, bool
7978
}
8079
Files.copy(Utils.class.getResourceAsStream(resourcePath), Paths.get(destPath),
8180
StandardCopyOption.REPLACE_EXISTING);
82-
if (markExec) {
83-
if (!System.getProperty("os.name").toLowerCase().startsWith("windows")) {
84-
Files.setPosixFilePermissions(Paths.get(destPath), PosixFilePermissions.fromString("r-xr-xr-x"));
85-
}
86-
}
8781
}
8882

8983
/**
@@ -424,7 +418,7 @@ public static Properties getBaseImageProperties(String builder, String dockerIma
424418
String contextDir) throws IOException, InterruptedException {
425419
logger.entering(builder, dockerImage, script, contextDir);
426420
final String scriptToRun = "test-env.sh";
427-
Utils.copyResourceAsFile(script, contextDir + File.separator + scriptToRun, true);
421+
Utils.copyResourceAsFile(script, contextDir + File.separator + scriptToRun);
428422
List<String> imageEnvCmd = Utils.getDockerRunCmd(builder,
429423
contextDir + File.separator + scriptToRun, dockerImage);
430424
logger.info("IMG-0097", dockerImage);

imagetool/src/main/resources/ImageTool.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ IMG-0018=Downloading patch [[cyan: {0}]]...
2020
IMG-0019={0} - locating patch number for the latest PSU...
2121
IMG-0020={0} - the latest PSU patch number is [[cyan: {1}]]
2222
IMG-0021=ORACLE_HOME value must be the same in both new and old image in order to rebase the domain
23-
IMG-0022=NOT USED
23+
IMG-0022=Invalid Oracle support credentials, verify the values provided for user and password match your OTN credential
2424
IMG-0023=No PSU recommended for {0}, version {1}
2525
IMG-0024=Cached patch file {0} has an empty path
2626
IMG-0025=No Domain Home in source image. Add DOMAIN_HOME environment variable to source image and try again.

0 commit comments

Comments
 (0)