30
30
import java .util .logging .Level ;
31
31
import java .util .logging .Logger ;
32
32
import java .util .logging .SimpleFormatter ;
33
+ import java .util .regex .Matcher ;
34
+ import java .util .regex .Pattern ;
33
35
import java .util .stream .Collectors ;
34
36
import java .util .stream .Stream ;
35
37
38
+ import static com .oracle .weblogicx .imagebuilder .api .model .CachePolicy .ALWAYS ;
36
39
import static com .oracle .weblogicx .imagebuilder .util .Constants .BUILD_ARG ;
37
40
import static com .oracle .weblogicx .imagebuilder .util .Constants .HTTP ;
38
41
import static com .oracle .weblogicx .imagebuilder .util .Constants .HTTPS ;
@@ -57,9 +60,12 @@ public abstract class ImageOperation implements Callable<CommandResponse> {
57
60
@ Override
58
61
public CommandResponse call () throws Exception {
59
62
handleProxyUrls ();
60
- // check user support credentials if we are applying any patches
61
- if (latestPSU || !patches .isEmpty ()) {
62
- password = handlePasswordOptions ();
63
+ password = handlePasswordOptions ();
64
+ // check user support credentials if useCache not set to always and we are applying any patches
65
+ if (latestPSU || (!patches .isEmpty () && useCache != ALWAYS )) {
66
+ if (Utils .isEmptyString (password )) {
67
+ return new CommandResponse (-1 , "Failed to determine password. use one of the options to input password" );
68
+ }
63
69
if (!ARUUtil .checkCredentials (userId , password )) {
64
70
return new CommandResponse (-1 , "user Oracle support credentials do not match" );
65
71
}
@@ -96,11 +102,12 @@ List<String> handlePatchFiles(Path tmpDir, Path tmpPatchesDir) throws Exception
96
102
patchLocations .add (psuResolver .resolve (cacheStore ));
97
103
}
98
104
if (patches != null && !patches .isEmpty ()) {
105
+ Pattern patchIdPattern = Pattern .compile (PATCH_ID_REGEX );
99
106
for (String patchId : patches ) {
100
- if ( patchId . matches ( PATCH_ID_REGEX )) {
101
- patchId = patchId . substring ( 1 );
102
- patchLocations .add (new PatchFile (useCache , installerType .toString (), installerVersion , patchId , userId ,
103
- password ).resolve (cacheStore ));
107
+ Matcher matcher = patchIdPattern . matcher ( patchId );
108
+ if ( matcher . matches () && matcher . groupCount () > 0 ) {
109
+ patchLocations .add (new PatchFile (useCache , installerType .toString (), installerVersion ,
110
+ matcher . group ( 1 ), userId , password ).resolve (cacheStore ));
104
111
} else {
105
112
logger .severe ("Ignoring invalid patch id format: " + patchId );
106
113
}
0 commit comments