Skip to content

Commit 6311d25

Browse files
committed
Merge branch 'saml2-init-data' into 'main'
adding archive file support for SAML2 initialization data files See merge request weblogic-cloud/weblogic-deploy-tooling!1475
2 parents 819f2f1 + b242c36 commit 6311d25

16 files changed

+740
-22
lines changed

core/src/main/java/oracle/weblogic/deploy/tool/archive_helper/add/AddCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
AddNodeManagerKeystoreCommand.class,
2929
AddOPSSWalletCommand.class,
3030
AddRCUWalletCommand.class,
31+
AddSaml2InitializationDataCommand.class,
3132
AddScriptCommand.class,
3233
AddServerKeystoreCommand.class,
3334
AddSharedLibraryCommand.class,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) 2023, Oracle and/or its affiliates.
3+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
*/
5+
package oracle.weblogic.deploy.tool.archive_helper.add;
6+
7+
import java.io.File;
8+
9+
import oracle.weblogic.deploy.logging.PlatformLogger;
10+
import oracle.weblogic.deploy.logging.WLSDeployLogFactory;
11+
import oracle.weblogic.deploy.tool.archive_helper.ArchiveHelperException;
12+
import oracle.weblogic.deploy.tool.archive_helper.CommandResponse;
13+
import oracle.weblogic.deploy.util.ExitCode;
14+
import oracle.weblogic.deploy.util.WLSDeployArchiveIOException;
15+
import picocli.CommandLine.Command;
16+
import picocli.CommandLine.Option;
17+
18+
import static oracle.weblogic.deploy.tool.ArchiveHelper.LOGGER_NAME;
19+
20+
@Command(
21+
name = "saml2InitializationData",
22+
header = "Add a SAML2 data initialization file to the archive file.",
23+
description = "%nCommand-line options:"
24+
)
25+
public class AddSaml2InitializationDataCommand extends AddTypeCommandBase {
26+
private static final String CLASS = AddScriptCommand.class.getName();
27+
private static final PlatformLogger LOGGER = WLSDeployLogFactory.getLogger(LOGGER_NAME);
28+
private static final String TYPE = "SAML2 initialization data file";
29+
30+
@Option(
31+
names = {"-source"},
32+
paramLabel = "<path>",
33+
description = "File system path to the SAML2 initialization data file to add",
34+
required = true
35+
)
36+
private String sourcePath;
37+
38+
@Override
39+
public CommandResponse call() throws Exception {
40+
final String METHOD = "call";
41+
LOGGER.entering(CLASS, METHOD);
42+
43+
CommandResponse response;
44+
File sourceFile;
45+
try {
46+
sourceFile = initializeOptions(this.sourcePath);
47+
48+
String resultName;
49+
if (this.overwrite) {
50+
resultName = this.archive.replaceSaml2DataFile(sourceFile.getName(), sourceFile.getPath());
51+
} else {
52+
resultName = this.archive.addSaml2DataFile(sourceFile.getPath());
53+
}
54+
response = new CommandResponse(ExitCode.OK, resultName);
55+
} catch (ArchiveHelperException ex) {
56+
LOGGER.severe("WLSDPLY-30010", ex, TYPE, this.sourcePath,
57+
this.archiveFilePath, ex.getLocalizedMessage());
58+
response = new CommandResponse(ex.getExitCode(), "WLSDPLY-30010", TYPE,
59+
this.sourcePath, this.archiveFilePath, ex.getLocalizedMessage());
60+
} catch (WLSDeployArchiveIOException | IllegalArgumentException ex) {
61+
LOGGER.severe("WLSDPLY-30011", ex, TYPE, this.sourcePath,
62+
this.overwrite, this.archiveFilePath, ex.getLocalizedMessage());
63+
response = new CommandResponse(ExitCode.ERROR, "WLSDPLY-30011", TYPE,
64+
this.sourcePath, this.overwrite, this.archiveFilePath, ex.getLocalizedMessage());
65+
}
66+
67+
LOGGER.exiting(CLASS, METHOD, response);
68+
return response;
69+
}
70+
}

core/src/main/java/oracle/weblogic/deploy/tool/archive_helper/extract/ExtractCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
ExtractNodeManagerKeystoreCommand.class,
3030
ExtractOPSSWalletCommand.class,
3131
ExtractRCUWalletCommand.class,
32+
ExtractSaml2InitializationDataCommand.class,
3233
ExtractScriptCommand.class,
3334
ExtractServerKeystoreCommand.class,
3435
ExtractSharedLibraryCommand.class,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (c) 2023, Oracle and/or its affiliates.
3+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
*/
5+
package oracle.weblogic.deploy.tool.archive_helper.extract;
6+
7+
import oracle.weblogic.deploy.logging.PlatformLogger;
8+
import oracle.weblogic.deploy.logging.WLSDeployLogFactory;
9+
import oracle.weblogic.deploy.tool.archive_helper.ArchiveHelperException;
10+
import oracle.weblogic.deploy.tool.archive_helper.CommandResponse;
11+
import oracle.weblogic.deploy.util.ExitCode;
12+
import oracle.weblogic.deploy.util.WLSDeployArchiveIOException;
13+
14+
import picocli.CommandLine.Command;
15+
import picocli.CommandLine.Option;
16+
17+
import static oracle.weblogic.deploy.tool.ArchiveHelper.LOGGER_NAME;
18+
19+
@Command(
20+
name = "saml2InitializationData",
21+
header = "Extract SAML2 initialization data file from the archive file.",
22+
description = "%nCommand-line options:"
23+
)
24+
public class ExtractSaml2InitializationDataCommand extends ExtractTypeCommandBase {
25+
private static final String CLASS = ExtractSaml2InitializationDataCommand.class.getName();
26+
private static final PlatformLogger LOGGER = WLSDeployLogFactory.getLogger(LOGGER_NAME);
27+
private static final String TYPE = "SAML2 initialization data file";
28+
private static final String ERROR_KEY = "WLSDPLY-30047";
29+
30+
@Option(
31+
names = {"-name"},
32+
description = "Name of the SAML2 initialization data file to be extracted from the archive file",
33+
required = true
34+
)
35+
private String name;
36+
37+
38+
@Override
39+
public CommandResponse call() throws Exception {
40+
final String METHOD = "call";
41+
LOGGER.entering(CLASS, METHOD);
42+
43+
CommandResponse response;
44+
try {
45+
initializeOptions();
46+
47+
this.archive.extractSaml2DataFile(this.name, this.targetDirectory);
48+
response = new CommandResponse(ExitCode.OK, "WLSDPLY-30046", TYPE, this.name,
49+
this.archiveFilePath, this.targetDirectory.getPath());
50+
} catch (ArchiveHelperException ex) {
51+
LOGGER.severe(ERROR_KEY, ex, TYPE, this.name, this.archiveFilePath,
52+
this.targetDirectory.getPath(), ex.getLocalizedMessage());
53+
response = new CommandResponse(ex.getExitCode(), ERROR_KEY, TYPE, this.name,
54+
this.archiveFilePath, this.targetDirectory.getPath(), ex.getLocalizedMessage());
55+
} catch (WLSDeployArchiveIOException | IllegalArgumentException ex) {
56+
LOGGER.severe(ERROR_KEY, ex, TYPE, this.name, this.archiveFilePath,
57+
this.targetDirectory.getPath(), ex.getLocalizedMessage());
58+
response = new CommandResponse(ExitCode.ERROR, ERROR_KEY, TYPE, this.name,
59+
this.archiveFilePath, this.targetDirectory.getPath(), ex.getLocalizedMessage());
60+
}
61+
62+
LOGGER.exiting(CLASS, METHOD, response);
63+
return response;
64+
}
65+
}

core/src/main/java/oracle/weblogic/deploy/tool/archive_helper/list/ListCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
ListNodeManagerKeystoreCommand.class,
2828
ListOPSSWalletCommand.class,
2929
ListRCUWalletCommand.class,
30+
ListSaml2InitializationDataCommand.class,
3031
ListScriptCommand.class,
3132
ListServerKeystoreCommand.class,
3233
ListSharedLibraryCommand.class,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2023, Oracle and/or its affiliates.
3+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
*/
5+
package oracle.weblogic.deploy.tool.archive_helper.list;
6+
7+
import oracle.weblogic.deploy.logging.PlatformLogger;
8+
import oracle.weblogic.deploy.logging.WLSDeployLogFactory;
9+
import oracle.weblogic.deploy.tool.archive_helper.CommandResponse;
10+
11+
import picocli.CommandLine.Command;
12+
import picocli.CommandLine.Option;
13+
14+
import static oracle.weblogic.deploy.tool.ArchiveHelper.LOGGER_NAME;
15+
import static oracle.weblogic.deploy.util.WLSDeployArchive.ArchiveEntryType.SAML2_DATA;
16+
17+
@Command(
18+
name = "saml2InitializationData",
19+
header = "List SAML2 initialization data entries in the archive file.",
20+
description = "%nCommand-line options:"
21+
)
22+
public class ListSaml2InitializationDataCommand extends ListTypeCommandBase {
23+
private static final String CLASS = ListSaml2InitializationDataCommand.class.getName();
24+
private static final PlatformLogger LOGGER = WLSDeployLogFactory.getLogger(LOGGER_NAME);
25+
26+
@Option(
27+
names = { "-name" },
28+
paramLabel = "<name>",
29+
description = "Name of the SAML2 initialization data file to list"
30+
)
31+
private String name;
32+
33+
@Override
34+
public CommandResponse call() throws Exception {
35+
final String METHOD = "call";
36+
LOGGER.entering(CLASS, METHOD);
37+
38+
CommandResponse response = listType(SAML2_DATA, "SAML2 initialization data file", name);
39+
40+
LOGGER.exiting(CLASS, METHOD, response);
41+
return response;
42+
}
43+
}

core/src/main/java/oracle/weblogic/deploy/tool/archive_helper/remove/RemoveCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
RemoveNodeManagerKeystoreCommand.class,
2929
RemoveOPSSWalletCommand.class,
3030
RemoveRCUWalletCommand.class,
31+
RemoveSaml2InitializationDataCommand.class,
3132
RemoveScriptCommand.class,
3233
RemoveServerKeystoreCommand.class,
3334
RemoveSharedLibraryCommand.class,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) 2023, Oracle and/or its affiliates.
3+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
*/
5+
package oracle.weblogic.deploy.tool.archive_helper.remove;
6+
7+
import oracle.weblogic.deploy.logging.PlatformLogger;
8+
import oracle.weblogic.deploy.logging.WLSDeployLogFactory;
9+
import oracle.weblogic.deploy.tool.archive_helper.ArchiveHelperException;
10+
import oracle.weblogic.deploy.tool.archive_helper.CommandResponse;
11+
import oracle.weblogic.deploy.util.ExitCode;
12+
import oracle.weblogic.deploy.util.WLSDeployArchiveIOException;
13+
14+
import picocli.CommandLine.Command;
15+
import picocli.CommandLine.Option;
16+
17+
import static oracle.weblogic.deploy.tool.ArchiveHelper.LOGGER_NAME;
18+
19+
@Command(
20+
name = "saml2InitializationData",
21+
header = "Remove SAML2 initialization data file from the archive file.",
22+
description = "%nCommand-line options:"
23+
)
24+
public class RemoveSaml2InitializationDataCommand extends RemoveTypeCommandBase {
25+
private static final String CLASS = RemoveSaml2InitializationDataCommand.class.getName();
26+
private static final PlatformLogger LOGGER = WLSDeployLogFactory.getLogger(LOGGER_NAME);
27+
private static final String TYPE = "SAML2 initialization data file";
28+
29+
@Option(
30+
names = {"-name"},
31+
description = "Name of the SAML2 initialization data file to be removed from the archive file",
32+
required = true
33+
)
34+
private String name;
35+
36+
@Override
37+
public CommandResponse call() throws Exception {
38+
final String METHOD = "call";
39+
LOGGER.entering(CLASS, METHOD);
40+
41+
CommandResponse response;
42+
try {
43+
initializeOptions();
44+
45+
int entriesRemoved;
46+
if (this.force) {
47+
entriesRemoved = this.archive.removeSaml2DataFile(this.name, true);
48+
} else {
49+
entriesRemoved = this.archive.removeSaml2DataFile(this.name);
50+
}
51+
response = new CommandResponse(ExitCode.OK, "WLSDPLY-30026", TYPE, this.name,
52+
entriesRemoved, this.archiveFilePath);
53+
} catch (ArchiveHelperException ex) {
54+
LOGGER.severe("WLSDPLY-30027", ex, TYPE, this.name, this.archiveFilePath, ex.getLocalizedMessage());
55+
response = new CommandResponse(ex.getExitCode(), "WLSDPLY-30027", TYPE, this.name,
56+
this.archiveFilePath, ex.getLocalizedMessage());
57+
} catch (WLSDeployArchiveIOException | IllegalArgumentException ex) {
58+
LOGGER.severe("WLSDPLY-30028", ex, TYPE, this.name, this.force,
59+
this.archiveFilePath, ex.getLocalizedMessage());
60+
response = new CommandResponse(ExitCode.ERROR, "WLSDPLY-30028", TYPE, this.name, this.force,
61+
this.archiveFilePath, ex.getLocalizedMessage());
62+
}
63+
64+
LOGGER.exiting(CLASS, METHOD, response);
65+
return response;
66+
}
67+
}

0 commit comments

Comments
 (0)