Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.

Commit c1b4e78

Browse files
Merge pull request #1 from cicsdev/sample/security
Sample/security
2 parents 5c095a7 + 4eb442b commit c1b4e78

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ To deploy the sample you will need to import the projects into CICS Explorer.
3535

3636
To install the sample as a CICS bundle:
3737

38-
1. Export the CICS bundle from Eclipse by selecting the project com.ibm.cicsdev.ejb.bundle > Export Bundle Project to z/OS UNIX File System.
38+
1. Export the CICS bundle from Eclipse by selecting the project **com.ibm.cicsdev.ejb.bundle** > **Export Bundle Project to z/OS UNIX File System**.
3939
2. Define and install a JVMSERVER resource named `DFHWLP` in the CICS region.
4040
3. Add the features `ejbLite-3.2`, `jsf-2.2` and `jaxrs-2.0` to the `featureManager` element in the Liberty JVM server's server.xml configuration file.
4141
4. Define and install a BUNDLE resource.
4242

4343
To install the sample through Liberty configuration
44-
1. Export the EAR project from Eclipse by selecting the project com.ibm.cicsdev.ejb.app > File > Export > EAR file > Next > choose a destination > Finish.
44+
1. Export the EAR project from Eclipse by selecting the project **com.ibm.cicsdev.ejb.app** > **File** > **Export** > **EAR file** > **Next** > choose a destination > **Finish**.
4545
2. Copy the EAR file in binary to the `apps` directory in the Liberty configuration directory on zFS.
4646
3. Replace the Liberty configuration file `server.xml` or update elements featureManager, safRegistry and application using [server.xml](etc/config/server.xml) as a basis.
4747
4. Install a JVMSERVER resource in the CICS region.
4848

49-
**Note:** JVMSERVER autoconfigure will configure the JVM server with the necessary elements in server.xml. Ensure autoconfigure is enabled in the JVM profile of the JVMSERVER used to run this sample.
49+
**Note:** JVM server autoconfigure will configure the JVM server with the necessary elements in server.xml. Ensure autoconfigure is enabled in the JVM profile of the JVMSERVER used to run this sample.
5050

5151
If the sample is correctly deployed, you should see the following messages in the Liberty logs:
5252

@@ -56,21 +56,21 @@ A CWWKT0016I: Web application available (default_host): http://mvs.example.ibm.c
5656
A CWWKT0016I: Web application available (default_host): http://mvs.example.ibm.com:9080/stock/
5757
```
5858

59-
If you use CICS bundle deployment, you will also need to define a RACF profile for users to access the stock REST API.
59+
If you use CICS bundle deployment, you will also need to define a RACF EJBROLE profile for users to access the stock REST API which is protected by the Administrator role.
6060

6161
```
6262
RDEFINE EJBROLE BBGZDFLT.com.ibm.cicsdev.ejb.Administrator UACC(NONE)
6363
PERMIT BBGZDFLT.com.ibm.cicsdev.ejb.Administrator CLASS(EJBROLE) ACCESS(READ) ID(WEBUSER)
6464
```
6565

66-
If you don't have RACF access, you could alter the `Administrator` role in the code to be the `cicsAllAuthenticated` role instead, which is always configured for CICS bundles, in the [CatalogueBean](projects/com.ibm.cicsdev.ejb/ejbModule/com/ibm/cicsdev/ejb/CatalogueBean.java) class.
66+
If you don't have RACF access, you could alter the `Administrator` role in the [CatalogueBean](projects/com.ibm.cicsdev.ejb/ejbModule/com/ibm/cicsdev/ejb/CatalogueBean.java) to be the `cicsAllAuthenticated` role instead, which is always configured for CICS bundles,
6767

6868
## Running the Sample
69-
To create new items in the store send a HTTP request to the stock API:
69+
To create new items in the store send an authenticated HTTP request to the stock API. The authenticated user must have access to the role named in the CatalogueBean.
7070

7171
```http
7272
POST /stock/api/items HTTP/1.1
73-
Host: mvs.example.ibm.com:9080
73+
Host: <hostname>:<port>
7474
Content-Type: application/json
7575
Authentication: BASIC <base64 encoded username,password>
7676
@@ -85,21 +85,23 @@ Content-Type: application/json
8585
{"id":1,"name":"CICS TS for z/OS","stock":2}
8686
```
8787

88-
**Note:** We use BASIC authentication here, but any form of HTTP or HTTPS authentication would work.
89-
90-
You can use this request using the command line tool cURL:
88+
You can use this request using the command line tool cURL, replacing <hostname>, <port> and <WEBUSER> with your own values.
9189

9290
```shell
93-
curl mvs.example.ibm.com:9080/stock/api/items/ -X POST -d '{ "name": "CICS TS for z/OS", "stock": 2 }' -H 'Content-Type: application/json' --user MVSUSER1
91+
curl <hostname>:<port>/stock/api/items/ -X POST -d '{ "name": "CICS TS for z/OS", "stock": 2 }' -H 'Content-Type: application/json' --user <WEBUSER>
9492
```
9593

96-
Once one or more items have been created, you can then use a browser to navigate to http://mvs.example.ibm.com:9080/shop/ and use the shop.
94+
**Note:** We use HTTP BASIC authentication in this example but other forms of authentiation could be used.
95+
96+
97+
Once one or more items have been created, you can then use a browser to navigate to http://hostname:port/shop/ and use the shop via the CartBean. There is no role protecting
98+
the CartBean so these requests do not need to be authenticated.
9799

98-
More stock can be added to an item through the following request (in this case we update item with the ID `1`):
100+
More stock can be added to an item through the following HTTP request (in this case we update item with the ID `1`):
99101

100102
```http
101103
PUT /stock/api/items/1
102-
Host: mvs.example.ibm.com:9080
104+
Host: <hostname>:<port>
103105
Content-Type: application/json
104106
Authentication: BASIC <base64 encoded username,password>
105107
@@ -117,7 +119,7 @@ You can view the current state of an item by sending a GET request (in this case
117119

118120
```http
119121
GET /stock/api/items/1
120-
Host: mvs.example.ibm.com:9080
122+
Host: <hostname>:<port>
121123
Accept: application/json
122124
Authentication: BASIC <base64 encoded username,password>
123125
```
@@ -130,7 +132,7 @@ Content-Type: application/json
130132
```
131133

132134
### Further Configuration
133-
Because TSQs are not recoverable by default, to get the benefit of EJB transactions in the project, you would need to define a TS Model similar to this:
135+
Because CICS TSQs are not recoverable by default, to get the benefit of EJB transactions in the project, you would need to define a TS model definition similar to this:
134136

135137
```
136138
DEFINE TSMODEL(JAVAEJB) GROUP(SAMPEJB) PREFIX(CATALOGUE) RECOVERABLE(YES)
@@ -139,12 +141,11 @@ DEFINE TSMODEL(JAVAEJB) GROUP(SAMPEJB) PREFIX(CATALOGUE) RECOVERABLE(YES)
139141
## Importing the Projects into Eclipse
140142
All the projects with code are Eclipse projects. To import these projects:
141143

142-
1. In Eclipse select *File* > *Import* > *General/Existing Projects into Workspace*
143-
2. *Browse* to the `projects` directory.
144+
1. In Eclipse select **File** > **Import** > **General/Existing Projects into Workspace**
145+
2. **Browse** to the `projects` directory.
144146
3. Ensure all 5 projects are checked
145-
4. *Finish* to import the source projects.
147+
4. **Finish** to import the source projects.
146148

147-
Optionally, you can import the CICS bundle project by following the same steps, but with the `etc` directory.
148149

149150
## Notes
150151
[Twitter Bootstrap](http://getbootstrap.com/) is linked to for styling of the JSF web pages. This is pulled from a content delivery network (CDN) online. If external links are blocked, these web pages will continue to work without Bootstrap, but the Bootstrap CSS can also be downloaded and added by changing the `link` element:

0 commit comments

Comments
 (0)