3030import java .util .logging .Level ;
3131import java .util .logging .Logger ;
3232import java .util .logging .SimpleFormatter ;
33+ import java .util .regex .Matcher ;
34+ import java .util .regex .Pattern ;
3335import java .util .stream .Collectors ;
3436import java .util .stream .Stream ;
3537
38+ import static com .oracle .weblogicx .imagebuilder .api .model .CachePolicy .ALWAYS ;
3639import static com .oracle .weblogicx .imagebuilder .util .Constants .BUILD_ARG ;
3740import static com .oracle .weblogicx .imagebuilder .util .Constants .HTTP ;
3841import static com .oracle .weblogicx .imagebuilder .util .Constants .HTTPS ;
@@ -57,9 +60,12 @@ public abstract class ImageOperation implements Callable<CommandResponse> {
5760 @ Override
5861 public CommandResponse call () throws Exception {
5962 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+ }
6369 if (!ARUUtil .checkCredentials (userId , password )) {
6470 return new CommandResponse (-1 , "user Oracle support credentials do not match" );
6571 }
@@ -96,11 +102,12 @@ List<String> handlePatchFiles(Path tmpDir, Path tmpPatchesDir) throws Exception
96102 patchLocations .add (psuResolver .resolve (cacheStore ));
97103 }
98104 if (patches != null && !patches .isEmpty ()) {
105+ Pattern patchIdPattern = Pattern .compile (PATCH_ID_REGEX );
99106 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 ));
104111 } else {
105112 logger .severe ("Ignoring invalid patch id format: " + patchId );
106113 }
0 commit comments