├── front-end-ui ├── src │ ├── app.css │ ├── assets │ │ ├── .gitkeep │ │ └── images │ │ │ ├── user.png │ │ │ ├── delete.png │ │ │ ├── edit-glyph.png │ │ │ ├── icon_remove.svg │ │ │ ├── icon_add.svg │ │ │ ├── icon_edit--grpname.svg │ │ │ ├── icon_twitter.svg │ │ │ ├── arrow-left.svg │ │ │ ├── icon_error.svg │ │ │ ├── icon_menu.svg │ │ │ ├── icon-overflow-menu.svg │ │ │ └── modal--img_right.svg │ ├── tsconfig.app.json │ ├── tsconfig.spec.json │ ├── app │ │ ├── app.component.html │ │ ├── user │ │ │ ├── users.ts │ │ │ ├── userObject.ts │ │ │ ├── user.ts │ │ │ └── services │ │ │ │ └── user.service.ts │ │ ├── group │ │ │ ├── groups.ts │ │ │ ├── group-contribution.ts │ │ │ ├── group.ts │ │ │ ├── group-add-member.component.html │ │ │ ├── group-create.component.html │ │ │ ├── groups.component.html │ │ │ └── services │ │ │ │ └── group.service.ts │ │ ├── loginObject.ts │ │ ├── app.component.ts │ │ ├── occasion │ │ │ ├── Contribution.ts │ │ │ └── Occasion.ts │ │ ├── header │ │ │ ├── header.component.html │ │ │ └── header.component.ts │ │ ├── logout │ │ │ └── logout.component.ts │ │ ├── auth │ │ │ └── services │ │ │ │ └── auth.service.ts │ │ ├── app.component.spec.ts │ │ ├── login │ │ │ ├── services │ │ │ │ └── login.service.ts │ │ │ ├── twitter.login.component.ts │ │ │ └── login.component.html │ │ ├── app-routing.module.ts │ │ └── app.module.ts │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── typings.d.ts │ ├── index.html │ ├── main.ts │ └── polyfills.ts ├── .dockerignore ├── collateral │ ├── group.bmp │ ├── groups.bmp │ ├── login.bmp │ ├── userLogin.bmp │ ├── createGroup.bmp │ ├── editProfile.bmp │ ├── headerMenu.bmp │ ├── createProfile.bmp │ ├── groupAddMember.bmp │ ├── groupNoEntries.bmp │ ├── groupsNoEntries.bmp │ ├── groupEditOccasion.bmp │ ├── groupOccasionCreate.bmp │ ├── twitterSignInPage.bmp │ ├── groupOccasionOverflowMenu.bmp │ ├── groupsSignedInUsingTweeter.bmp │ ├── groupOccasionNotificationLogged.bmp │ ├── groupOccasionNotificationTweeted.bmp │ ├── groupOccasionNotificationAcmeGiftsTwitterAccountTweet.bmp │ ├── groupOccasionNotificationAcmeGiftsTwitterDirectMsgSent.bmp │ └── groupOccasionNotificationAcmeGiftsTwitterDirectMsgReceived.bmp ├── Dockerfile ├── .editorconfig ├── npm_build │ ├── tsconfig.json │ ├── protractor.conf.js │ ├── karma.conf.js │ ├── .eslintrc.json │ └── package.json ├── .factorypath ├── liberty │ ├── config │ │ └── server.xml │ └── app │ │ └── web.xml ├── .gitignore └── build.gradle ├── microservice-auth ├── .gitignore ├── .settings │ ├── org.eclipse.wst.validation.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.wst.common.project.facet.core.prefs.xml │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.wst.common.component ├── Dockerfile ├── src │ ├── main │ │ ├── java │ │ │ └── net │ │ │ │ └── wasdev │ │ │ │ └── sample │ │ │ │ └── microprofile │ │ │ │ └── auth │ │ │ │ ├── AuthApplication.java │ │ │ │ └── AuthResource.java │ │ ├── webapp │ │ │ └── WEB-INF │ │ │ │ └── web.xml │ │ └── liberty │ │ │ └── config │ │ │ └── server.xml │ └── test │ │ ├── resources │ │ └── cxf.xml │ │ └── java │ │ └── test │ │ └── AuthResourceTest.java ├── .project ├── .classpath └── build.gradle ├── microservice-user ├── .gitignore ├── Dockerfile ├── .classpath ├── src │ ├── main │ │ ├── java │ │ │ └── net │ │ │ │ └── wasdev │ │ │ │ └── sample │ │ │ │ └── microprofile │ │ │ │ └── user │ │ │ │ ├── UserApplication.java │ │ │ │ ├── MongoAccess.java │ │ │ │ └── PasswordUtility.java │ │ ├── webapp │ │ │ └── WEB-INF │ │ │ │ └── web.xml │ │ └── liberty │ │ │ └── config │ │ │ └── server.xml │ └── test │ │ └── resources │ │ └── cxf.xml └── .project ├── microservice-group ├── .gitignore ├── Dockerfile ├── src │ ├── main │ │ ├── java │ │ │ └── net │ │ │ │ └── wasdev │ │ │ │ └── samples │ │ │ │ └── microprofile │ │ │ │ └── group │ │ │ │ ├── GroupApplication.java │ │ │ │ └── MongoAccess.java │ │ ├── webapp │ │ │ ├── WEB-INF │ │ │ │ └── web.xml │ │ │ └── META-INF │ │ │ │ └── swagger.json │ │ └── liberty │ │ │ └── config │ │ │ └── server.xml │ └── test │ │ └── resources │ │ └── cxf.xml ├── .project └── .classpath ├── microservice-occasion ├── .gitignore ├── collateral │ ├── mpConfig.bmp │ ├── retryAndFallback.bmp │ ├── pomBootstrapProperties.bmp │ ├── gradleBootstrapProperties.bmp │ ├── notificationFallbackHandler.bmp │ └── occasionBootstrapProperties.bmp ├── Dockerfile ├── src │ ├── test │ │ └── resources │ │ │ ├── logging.properties │ │ │ └── cxf.xml │ └── main │ │ ├── java │ │ └── net │ │ │ └── wasdev │ │ │ └── samples │ │ │ └── microProfile │ │ │ └── occasions │ │ │ ├── OccasionApplication.java │ │ │ ├── JwtBuilder.java │ │ │ ├── JwtBuilderImpl.java │ │ │ ├── OccasionResponse.java │ │ │ ├── MongoAccess.java │ │ │ ├── NotificationRetryBean.java │ │ │ └── NotificationFallbackHandler.java │ │ ├── webapp │ │ └── WEB-INF │ │ │ └── web.xml │ │ └── resources │ │ └── liberty │ │ └── config │ │ └── server.xml ├── .classpath └── .project ├── shared-keystore ├── .gitignore ├── .settings │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.wst.common.component │ └── org.eclipse.jdt.core.prefs ├── certs │ ├── DigiCertSHA2SecureServerCA.crt │ └── DigiCertSHA2HighAssuranceServerCA.crt ├── .project ├── .classpath └── build.gradle ├── collateral └── architecture.bmp ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── microservice-notification ├── Dockerfile ├── src │ └── main │ │ ├── java │ │ └── net │ │ │ └── wasdev │ │ │ └── sample │ │ │ └── microprofile │ │ │ └── notification │ │ │ └── NotificationApplication.java │ │ ├── webapp │ │ └── WEB-INF │ │ │ └── web.xml │ │ └── liberty │ │ └── config │ │ └── server.xml ├── .classpath ├── .project └── build.gradle ├── microservice-notification_v1_1 ├── Dockerfile ├── src │ └── main │ │ ├── java │ │ └── net │ │ │ └── wasdev │ │ │ └── sample │ │ │ └── microprofile │ │ │ └── notification │ │ │ └── extended │ │ │ ├── NotificationApplication.java │ │ │ ├── NotificationFallbackHandler.java │ │ │ └── NotificationRetryBean.java │ │ ├── webapp │ │ └── WEB-INF │ │ │ └── web.xml │ │ └── liberty │ │ └── config │ │ └── server.xml ├── .classpath ├── .project └── build.gradle ├── .travis.yml ├── run-app ├── src │ └── main │ │ └── resources │ │ ├── groups.json │ │ ├── users.json │ │ ├── cxf.xml │ │ └── occasions.json ├── stopMongo.sh ├── .project ├── stopMongo.bat ├── .classpath ├── startMongo.bat ├── startMongo.sh └── build.gradle ├── docker-push ├── .project ├── .gitignore ├── settings.gradle ├── gradlew.bat └── docker-build /front-end-ui/src/app.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /front-end-ui/src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /front-end-ui/.dockerignore: -------------------------------------------------------------------------------- 1 | npm_build* 2 | -------------------------------------------------------------------------------- /microservice-auth/.gitignore: -------------------------------------------------------------------------------- 1 | /mongodb/ 2 | /mongolog* 3 | -------------------------------------------------------------------------------- /microservice-user/.gitignore: -------------------------------------------------------------------------------- 1 | /mongodb/ 2 | /mongolog* 3 | -------------------------------------------------------------------------------- /microservice-group/.gitignore: -------------------------------------------------------------------------------- 1 | /.apt_generated/ 2 | /mongodb 3 | /mongolog* 4 | -------------------------------------------------------------------------------- /microservice-occasion/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /mongodb/ 3 | /mongolog* 4 | /*~ 5 | -------------------------------------------------------------------------------- /shared-keystore/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated things 2 | /src/main/resources/keystore.jceks 3 | -------------------------------------------------------------------------------- /collateral/architecture.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/collateral/architecture.bmp -------------------------------------------------------------------------------- /microservice-auth/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /microservice-auth/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openliberty/open-liberty:kernel 2 | COPY target/liberty/wlp/usr/servers/authServer /config 3 | -------------------------------------------------------------------------------- /front-end-ui/collateral/group.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/group.bmp -------------------------------------------------------------------------------- /front-end-ui/collateral/groups.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groups.bmp -------------------------------------------------------------------------------- /front-end-ui/collateral/login.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/login.bmp -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /front-end-ui/collateral/userLogin.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/userLogin.bmp -------------------------------------------------------------------------------- /front-end-ui/collateral/createGroup.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/createGroup.bmp -------------------------------------------------------------------------------- /front-end-ui/collateral/editProfile.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/editProfile.bmp -------------------------------------------------------------------------------- /front-end-ui/collateral/headerMenu.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/headerMenu.bmp -------------------------------------------------------------------------------- /front-end-ui/src/assets/images/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/src/assets/images/user.png -------------------------------------------------------------------------------- /front-end-ui/collateral/createProfile.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/createProfile.bmp -------------------------------------------------------------------------------- /front-end-ui/collateral/groupAddMember.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groupAddMember.bmp -------------------------------------------------------------------------------- /front-end-ui/collateral/groupNoEntries.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groupNoEntries.bmp -------------------------------------------------------------------------------- /front-end-ui/src/assets/images/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/src/assets/images/delete.png -------------------------------------------------------------------------------- /microservice-notification/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openliberty/open-liberty:kernel 2 | COPY target/liberty/wlp/usr/servers/notificationServer /config 3 | -------------------------------------------------------------------------------- /front-end-ui/collateral/groupsNoEntries.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groupsNoEntries.bmp -------------------------------------------------------------------------------- /microservice-notification_v1_1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openliberty/open-liberty:kernel 2 | COPY target/liberty/wlp/usr/servers/notificationServer /config 3 | -------------------------------------------------------------------------------- /front-end-ui/collateral/groupEditOccasion.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groupEditOccasion.bmp -------------------------------------------------------------------------------- /front-end-ui/collateral/groupOccasionCreate.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groupOccasionCreate.bmp -------------------------------------------------------------------------------- /front-end-ui/collateral/twitterSignInPage.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/twitterSignInPage.bmp -------------------------------------------------------------------------------- /front-end-ui/src/assets/images/edit-glyph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/src/assets/images/edit-glyph.png -------------------------------------------------------------------------------- /microservice-auth/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /microservice-occasion/collateral/mpConfig.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/microservice-occasion/collateral/mpConfig.bmp -------------------------------------------------------------------------------- /shared-keystore/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /shared-keystore/certs/DigiCertSHA2SecureServerCA.crt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/shared-keystore/certs/DigiCertSHA2SecureServerCA.crt -------------------------------------------------------------------------------- /front-end-ui/collateral/groupOccasionOverflowMenu.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groupOccasionOverflowMenu.bmp -------------------------------------------------------------------------------- /front-end-ui/collateral/groupsSignedInUsingTweeter.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groupsSignedInUsingTweeter.bmp -------------------------------------------------------------------------------- /microservice-occasion/collateral/retryAndFallback.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/microservice-occasion/collateral/retryAndFallback.bmp -------------------------------------------------------------------------------- /front-end-ui/collateral/groupOccasionNotificationLogged.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groupOccasionNotificationLogged.bmp -------------------------------------------------------------------------------- /microservice-occasion/collateral/pomBootstrapProperties.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/microservice-occasion/collateral/pomBootstrapProperties.bmp -------------------------------------------------------------------------------- /shared-keystore/certs/DigiCertSHA2HighAssuranceServerCA.crt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/shared-keystore/certs/DigiCertSHA2HighAssuranceServerCA.crt -------------------------------------------------------------------------------- /front-end-ui/collateral/groupOccasionNotificationTweeted.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groupOccasionNotificationTweeted.bmp -------------------------------------------------------------------------------- /microservice-occasion/collateral/gradleBootstrapProperties.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/microservice-occasion/collateral/gradleBootstrapProperties.bmp -------------------------------------------------------------------------------- /microservice-occasion/collateral/notificationFallbackHandler.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/microservice-occasion/collateral/notificationFallbackHandler.bmp -------------------------------------------------------------------------------- /microservice-occasion/collateral/occasionBootstrapProperties.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/microservice-occasion/collateral/occasionBootstrapProperties.bmp -------------------------------------------------------------------------------- /microservice-user/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openliberty/open-liberty:kernel 2 | COPY target/liberty/wlp/usr/servers/userServer /config 3 | COPY target/liberty/wlp/usr/shared /opt/ol/wlp/usr/shared 4 | -------------------------------------------------------------------------------- /shared-keystore/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /front-end-ui/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openliberty/open-liberty:kernel 2 | COPY target/liberty/wlp/usr/servers/UIServer /config 3 | RUN sed -i -e 's/httpEndpoint/httpEndpoint host="*"/g' /config/server.xml 4 | -------------------------------------------------------------------------------- /front-end-ui/collateral/groupOccasionNotificationAcmeGiftsTwitterAccountTweet.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groupOccasionNotificationAcmeGiftsTwitterAccountTweet.bmp -------------------------------------------------------------------------------- /front-end-ui/collateral/groupOccasionNotificationAcmeGiftsTwitterDirectMsgSent.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groupOccasionNotificationAcmeGiftsTwitterDirectMsgSent.bmp -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - openjdk8 4 | env: 5 | - TEST_COMMAND="./gradlew clean build" 6 | - TEST_COMMAND="mvn clean install" 7 | install: true 8 | script: 9 | - (eval "$TEST_COMMAND") 10 | -------------------------------------------------------------------------------- /microservice-auth/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/test/java=UTF-8 4 | encoding//src/test/resources=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /front-end-ui/collateral/groupOccasionNotificationAcmeGiftsTwitterDirectMsgReceived.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/sample-acmegifts/HEAD/front-end-ui/collateral/groupOccasionNotificationAcmeGiftsTwitterDirectMsgReceived.bmp -------------------------------------------------------------------------------- /microservice-occasion/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openliberty/open-liberty:kernel 2 | COPY target/wlp/usr/servers/OccasionsServer /config 3 | COPY target/wlp/usr/shared /opt/ol/wlp/usr/shared 4 | RUN sed -i -e 's/httpEndpoint/httpEndpoint host="*"/g' /config/server.xml -------------------------------------------------------------------------------- /shared-keystore/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip 6 | -------------------------------------------------------------------------------- /microservice-group/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openliberty/open-liberty:kernel 2 | COPY target/liberty/wlp/usr/servers/groupServer /config 3 | COPY target/liberty/wlp/usr/shared /opt/ol/wlp/usr/shared 4 | RUN sed -i -e 's/httpEndpoint/httpEndpoint host="*"/g' /config/server.xml 5 | -------------------------------------------------------------------------------- /front-end-ui/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "baseUrl": "./", 6 | "module": "es2015", 7 | "types": [] 8 | }, 9 | "exclude": [ 10 | "test.ts", 11 | "**/*.spec.ts" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /run-app/src/main/resources/groups.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "group1", 4 | "name": "Co-workers", 5 | "members": ["user1","user2","user3"] 6 | }, 7 | { 8 | "id": "group2", 9 | "name": "Friends", 10 | "members": ["user1","user4","user5"] 11 | } 12 | ] -------------------------------------------------------------------------------- /front-end-ui/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /front-end-ui/src/assets/images/icon_remove.svg: -------------------------------------------------------------------------------- 1 | newAsset 1 -------------------------------------------------------------------------------- /front-end-ui/src/assets/images/icon_add.svg: -------------------------------------------------------------------------------- 1 | addAsset 1 -------------------------------------------------------------------------------- /shared-keystore/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /front-end-ui/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "target": "es5", 8 | "types": [ 9 | "jasmine", 10 | "node" 11 | ] 12 | }, 13 | "files": [ 14 | "test.ts" 15 | ], 16 | "include": [ 17 | "**/*.spec.ts", 18 | "**/*.d.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /docker-push: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | NAMESPACE="acmegifts" 4 | docker push $NAMESPACE/front-end-ui:latest 5 | docker push $NAMESPACE/microservice-auth:latest 6 | docker push $NAMESPACE/microservice-group:latest 7 | docker push $NAMESPACE/microservice-notification:latest 8 | docker push $NAMESPACE/microservice-notification-v1-1:latest 9 | docker push $NAMESPACE/microservice-occasion:latest 10 | docker push $NAMESPACE/microservice-user:latest -------------------------------------------------------------------------------- /microservice-auth/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /front-end-ui/npm_build/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./src/main/webapp", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "experimentalDecorators": true, 9 | "target": "es5", 10 | "typeRoots": [ 11 | "node_modules/@types" 12 | ], 13 | "lib": [ 14 | "es2017", 15 | "dom" 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /microservice-auth/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | sample-acmegifts 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /microservice-occasion/src/test/resources/logging.properties: -------------------------------------------------------------------------------- 1 | .level=ALL 2 | java.util.logging.SimpleFormatter.format=%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$-6s %2$s %5$s%6$s%n 3 | handlers=java.util.logging.ConsoleHandler 4 | net.wasdev.samples.microProfile.occasions_test.level=ALL 5 | net.wasdev.samples.microProfile.occasions_test.handler=java.util.logging.ConsoleHandler 6 | java.util.logging.ConsoleHandler.level=ALL 7 | org.level=NONE 8 | com.level=NONE 9 | javax.level=NONE 10 | -------------------------------------------------------------------------------- /microservice-auth/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 8 | org.eclipse.jdt.core.compiler.source=1.8 9 | -------------------------------------------------------------------------------- /shared-keystore/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 8 | org.eclipse.jdt.core.compiler.source=1.8 9 | -------------------------------------------------------------------------------- /front-end-ui/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /front-end-ui/.factorypath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /front-end-ui/src/assets/images/icon_edit--grpname.svg: -------------------------------------------------------------------------------- 1 | newAsset 2 -------------------------------------------------------------------------------- /front-end-ui/liberty/config/server.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | microProfile-1.0 4 | ssl-1.0 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /microservice-auth/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /front-end-ui/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | export const environment = { 12 | production: true 13 | }; 14 | -------------------------------------------------------------------------------- /shared-keystore/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | shared-keystore 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /front-end-ui/src/app/user/users.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import {User} from './user'; 12 | 13 | export class Users { 14 | users: User[]; 15 | } 16 | -------------------------------------------------------------------------------- /front-end-ui/src/app/group/groups.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import {Group} from './group'; 12 | 13 | export class Groups { 14 | groups: Group[]; 15 | } 16 | -------------------------------------------------------------------------------- /front-end-ui/src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | /* SystemJS module definition */ 12 | declare var module: NodeModule; 13 | interface NodeModule { 14 | id: string; 15 | } 16 | -------------------------------------------------------------------------------- /front-end-ui/src/assets/images/icon_twitter.svg: -------------------------------------------------------------------------------- 1 | newAsset 1 -------------------------------------------------------------------------------- /front-end-ui/src/index.html: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | AcmeGifts 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /front-end-ui/src/app/loginObject.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | export class Login { 12 | 13 | constructor( 14 | public userName: string, 15 | public password: string 16 | ) { } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /microservice-user/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /microservice-occasion/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /front-end-ui/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import { Component } from '@angular/core'; 12 | 13 | @Component({ 14 | selector: 'app-root', 15 | templateUrl: './app.component.html' 16 | }) 17 | export class AppComponent { } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore node files 2 | front-end-ui/node/ 3 | front-end-ui/node_modules/ 4 | 5 | # Ignore target/build directories. 6 | target/ 7 | build/ 8 | 9 | # Ignore the settings directories. 10 | .settings/ 11 | 12 | # Ignore .metadata directories 13 | .metadata/ 14 | 15 | # Ignore RemoteSystemsTempFiles 16 | RemoteSystemsTempFiles/ 17 | 18 | # Ignore class files. 19 | *.class 20 | 21 | # Mobile Tools for Java (J2ME) 22 | .mtj.tmp/ 23 | 24 | # Package Files # 25 | *.jar 26 | *.war 27 | *.ear 28 | 29 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 30 | hs_err_pid* 31 | 32 | # ignore vim swap files 33 | *.swp 34 | 35 | # ignore certificates/keystores 36 | *.pkcs12 37 | *.pem 38 | 39 | # Ignore Gradle cache 40 | .gradle/ 41 | 42 | -------------------------------------------------------------------------------- /run-app/stopMongo.sh: -------------------------------------------------------------------------------- 1 | # This script is used to stop a Mongo database 2 | # 3 | # Example usage: 4 | # 5 | # stopMongo.sh [mongoPath] 6 | # 7 | # : The name of the directory where the Mongo DB is running 8 | # : Name of the build directory (Gradle = build, Maven = target) 9 | # [mongoPath] : Optional, absolute path to the Mongo install bin directory 10 | # 11 | 12 | dbName=$1 13 | buildDir=$2 14 | mongoPath=$3 15 | 16 | # Set mongo path if defined 17 | if [ ! -z mongoPath ]; then 18 | export PATH=$PATH:${mongoPath} 19 | fi 20 | 21 | # Kill any existing mongo server 22 | if [ -e ./${buildDir}/${dbName}/${dbName}.pid ]; then 23 | kill `cat ./${buildDir}/${dbName}/${dbName}.pid` 24 | rm ./${buildDir}/${dbName}/${dbName}.pid 25 | fi 26 | -------------------------------------------------------------------------------- /microservice-auth/src/main/java/net/wasdev/sample/microprofile/auth/AuthApplication.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.sample.microprofile.auth; 12 | 13 | import javax.ws.rs.core.Application; 14 | 15 | public class AuthApplication extends Application {} 16 | -------------------------------------------------------------------------------- /microservice-user/src/main/java/net/wasdev/sample/microprofile/user/UserApplication.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.sample.microprofile.user; 12 | 13 | import javax.ws.rs.core.Application; 14 | 15 | public class UserApplication extends Application {} 16 | -------------------------------------------------------------------------------- /front-end-ui/src/app/occasion/Contribution.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | export class Contribution { 12 | userId: string; 13 | amount: number; 14 | 15 | constructor (userId: string, amount: number) { 16 | this.userId = userId; 17 | this.amount = amount; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /microservice-notification/src/main/java/net/wasdev/sample/microprofile/notification/NotificationApplication.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.sample.microprofile.notification; 12 | 13 | import javax.ws.rs.core.Application; 14 | 15 | public class NotificationApplication extends Application {} 16 | -------------------------------------------------------------------------------- /front-end-ui/src/app/group/group-contribution.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | export class GroupContribution { 12 | groupId: string; 13 | contribution: number; 14 | 15 | constructor(groupId: string, contribution: number) { 16 | this.groupId = groupId; 17 | this.contribution = contribution; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /front-end-ui/src/app/user/userObject.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | export class User { 12 | constructor( 13 | public firstName: string, 14 | public lastName: string, 15 | public userName: string, 16 | public wishListLink: string, 17 | public twitterHandle: string, 18 | public password: string 19 | ) {} 20 | } 21 | -------------------------------------------------------------------------------- /run-app/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | run-app 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.m2e.core.maven2Nature 27 | org.eclipse.wst.common.project.facet.core.nature 28 | 29 | 30 | -------------------------------------------------------------------------------- /front-end-ui/src/assets/images/arrow-left.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | arrow--left 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /microservice-notification_v1_1/src/main/java/net/wasdev/sample/microprofile/notification/extended/NotificationApplication.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.sample.microprofile.notification.extended; 12 | 13 | import javax.ws.rs.core.Application; 14 | 15 | public class NotificationApplication extends Application {} 16 | -------------------------------------------------------------------------------- /front-end-ui/npm_build/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './e2e/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: 'e2e/tsconfig.e2e.json' 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /front-end-ui/src/app/group/group.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | export class Group { 12 | public id: string; 13 | public name: string; 14 | public members: string[]; 15 | 16 | constructor( id: string, name: string, members: string[]) { 17 | this.id = id; 18 | this.name = name; 19 | this.members = members; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /front-end-ui/src/app/user/user.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | export class User { 12 | constructor( 13 | public id: string, 14 | public firstName: string, 15 | public lastName: string, 16 | public userName: string, 17 | public wishListLink: string, 18 | public twitterHandle: string, 19 | public password: string, 20 | public isTwitterLogin: string 21 | ) {} 22 | } 23 | -------------------------------------------------------------------------------- /front-end-ui/src/main.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import { enableProdMode } from '@angular/core'; 12 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 13 | 14 | import { AppModule } from './app/app.module'; 15 | import { environment } from './environments/environment'; 16 | 17 | if (environment.production) { 18 | enableProdMode(); 19 | } 20 | 21 | platformBrowserDynamic().bootstrapModule(AppModule); 22 | -------------------------------------------------------------------------------- /front-end-ui/src/assets/images/icon_error.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | error--glyph 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /front-end-ui/src/app/occasion/Occasion.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import { Contribution } from './Contribution'; 12 | export class Occasion { 13 | constructor( 14 | public _id: string, 15 | public contributions: Contribution[], 16 | public date: string, 17 | public groupId: string, 18 | public name: string, 19 | public organizerId: string, 20 | public recipientId: string 21 | ) {} 22 | } 23 | -------------------------------------------------------------------------------- /front-end-ui/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # Maven copies & filters source here 9 | /npm_build/src 10 | 11 | # angular build outputs here, which is then packaged by maven into a war 12 | /src/main 13 | 14 | # dependencies 15 | /npm_build/node 16 | /npm_build/node_modules 17 | 18 | # IDEs and editors 19 | /.idea 20 | .project 21 | .classpath 22 | .c9/ 23 | *.launch 24 | .settings/ 25 | *.sublime-workspace 26 | 27 | # IDE - VSCode 28 | .vscode/* 29 | !.vscode/settings.json 30 | !.vscode/tasks.json 31 | !.vscode/launch.json 32 | !.vscode/extensions.json 33 | 34 | # misc 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | testem.log 41 | /typings 42 | yarn-error.log 43 | 44 | # e2e 45 | /e2e/*.js 46 | /e2e/*.map 47 | 48 | # System Files 49 | .DS_Store 50 | Thumbs.db 51 | /.apt_generated/ 52 | 53 | # Emacs 54 | *~ 55 | -------------------------------------------------------------------------------- /front-end-ui/src/assets/images/icon_menu.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | menu 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /front-end-ui/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | // The file contents for the current environment will overwrite these during build. 12 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 13 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 14 | // The list of which env maps to which file can be found in `.angular-cli.json`. 15 | 16 | export const environment = { 17 | production: false 18 | }; 19 | -------------------------------------------------------------------------------- /run-app/stopMongo.bat: -------------------------------------------------------------------------------- 1 | @REM This script is used to stop a Mongo database 2 | @REM 3 | @REM Example usage: 4 | @REM 5 | @REM stopMongo.sh [mongoPath] 6 | @REM 7 | @REM : The name of the directory where the Mongo DB is running 8 | @REM : Name of the build directory (Gradle = build, Maven = target) 9 | @REM [mongoPath] : Optional, absolute path to the Mongo install bin directory 10 | 11 | @echo off 12 | 13 | @REM Get the needed params. 14 | set dbName=%1 15 | set buildDir=%2 16 | set mongoPath=%3 17 | 18 | @REM Set the mongoDB path. 19 | IF defined mongoPath SET PATH=%PATH%;%mongoPath% 20 | 21 | @REM Create the needed directories. 22 | if defined dbName ( 23 | IF NOT exist .\%buildDir%\%dbName% ( 24 | md .\%buildDir%\%dbName% 25 | ) 26 | IF NOT exist .\%buildDir%\%dbName%\logs ( 27 | md .\%buildDir%\%dbName%\logs 28 | ) 29 | ) 30 | 31 | @REM Stop and remove any existing mongo db service. 32 | mongod --logpath %CD%\%buildDir%\%dbName%\logs\%dbName%_stop.log --remove --serviceName %dbName% 33 | -------------------------------------------------------------------------------- /microservice-notification_v1_1/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | Acme Gifts: Notification Microservice v1.1 13 | 14 | javax.ws.rs.core.Application 15 | 16 | 17 | javax.ws.rs.core.Application 18 | /* 19 | 20 | -------------------------------------------------------------------------------- /microservice-group/src/main/java/net/wasdev/samples/microprofile/group/GroupApplication.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.samples.microprofile.group; 12 | 13 | import java.util.HashSet; 14 | import java.util.Set; 15 | import javax.ws.rs.core.Application; 16 | 17 | public class GroupApplication extends Application { 18 | @Override 19 | public Set> getClasses() { 20 | Set> classes = new HashSet>(); 21 | classes.add(GroupResource.class); 22 | return classes; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /microservice-occasion/src/main/java/net/wasdev/samples/microProfile/occasions/OccasionApplication.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.samples.microProfile.occasions; 12 | 13 | import java.util.HashSet; 14 | import java.util.Set; 15 | import javax.ws.rs.core.Application; 16 | 17 | public class OccasionApplication extends Application { 18 | @Override 19 | public Set> getClasses() { 20 | Set> classes = new HashSet>(); 21 | classes.add(OccasionResource.class); 22 | return classes; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /microservice-notification/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 15 | Acme Gifts: Notification Microservice 16 | 17 | 18 | javax.ws.rs.core.Application 19 | 20 | 21 | 22 | javax.ws.rs.core.Application 23 | /* 24 | 25 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'acmeGifts' 2 | include ':shared-keystore' 3 | include ':microservice-auth' 4 | include ':microservice-user' 5 | include ':microservice-group' 6 | include ':microservice-notification' 7 | include ':microservice-occasion' 8 | include ':front-end-ui' 9 | include ':microservice-notification_v1_1' 10 | include ':run-app' 11 | 12 | project(':shared-keystore').projectDir = "$rootDir/shared-keystore" as File 13 | project(':microservice-auth').projectDir = "$rootDir/microservice-auth" as File 14 | project(':microservice-user').projectDir = "$rootDir/microservice-user" as File 15 | project(':microservice-group').projectDir = "$rootDir/microservice-group" as File 16 | project(':microservice-notification').projectDir = "$rootDir/microservice-notification" as File 17 | project(':microservice-occasion').projectDir = "$rootDir/microservice-occasion" as File 18 | project(':front-end-ui').projectDir = "$rootDir/front-end-ui" as File 19 | project(':microservice-notification_v1_1').projectDir = "$rootDir/microservice-notification_v1_1" as File 20 | project(':run-app').projectDir = "$rootDir/run-app" as File -------------------------------------------------------------------------------- /front-end-ui/src/app/header/header.component.html: -------------------------------------------------------------------------------- 1 | 10 |
11 |
ACME GIFTS
12 |
13 | 16 | 17 | 20 | 23 | 24 |
25 |
Hi, {{this.userName}}!
26 |
27 | -------------------------------------------------------------------------------- /front-end-ui/npm_build/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client:{ 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ], 20 | fixWebpackSourcePaths: true 21 | }, 22 | angularCli: { 23 | environment: 'dev' 24 | }, 25 | reporters: ['progress', 'kjhtml'], 26 | port: 9876, 27 | colors: true, 28 | logLevel: config.LOG_INFO, 29 | autoWatch: true, 30 | browsers: ['Chrome'], 31 | singleRun: false 32 | }); 33 | }; 34 | -------------------------------------------------------------------------------- /front-end-ui/liberty/app/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Acme Gifts: Frontend UI 7 | 8 | 9 | 404 10 | / 11 | 12 | 13 | 14 | 15 | frontendUI 16 | SSL for frontend UI component 17 | /* 18 | GET 19 | POST 20 | PUT 21 | DELETE 22 | 23 | 24 | CONFIDENTIAL 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /front-end-ui/src/assets/images/icon-overflow-menu.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Overflow-Menu_icon Copy 79 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /front-end-ui/src/app/logout/logout.component.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import { Component, OnInit } from '@angular/core'; 12 | import { Router } from '@angular/router'; 13 | 14 | @Component({ 15 | template: '' 16 | }) 17 | export class LogoutComponent implements OnInit { 18 | 19 | constructor(private router: Router) {} 20 | 21 | ngOnInit() { 22 | // Remove the JWT from web storage to logout the user. 23 | delete sessionStorage.jwt; 24 | delete sessionStorage.userName; 25 | delete sessionStorage.userId; 26 | 27 | // Route back to the initial page. 28 | this.router.navigate(['login']); 29 | } 30 | } -------------------------------------------------------------------------------- /microservice-notification/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /microservice-notification_v1_1/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /microservice-auth/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | microservice-auth 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.common.project.facet.core.builder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.jdt.core.javanature 33 | org.eclipse.m2e.core.maven2Nature 34 | org.eclipse.wst.common.project.facet.core.nature 35 | org.eclipse.wst.jsdt.core.jsNature 36 | 37 | 38 | -------------------------------------------------------------------------------- /microservice-user/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | microservice-user 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.common.project.facet.core.builder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.jdt.core.javanature 33 | org.eclipse.m2e.core.maven2Nature 34 | org.eclipse.wst.common.project.facet.core.nature 35 | org.eclipse.wst.jsdt.core.jsNature 36 | 37 | 38 | -------------------------------------------------------------------------------- /microservice-group/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | microservice-group 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.common.project.facet.core.builder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.jdt.core.javanature 33 | org.eclipse.m2e.core.maven2Nature 34 | org.eclipse.wst.common.project.facet.core.nature 35 | org.eclipse.wst.jsdt.core.jsNature 36 | 37 | 38 | -------------------------------------------------------------------------------- /microservice-occasion/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | microservice-occasion 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.common.project.facet.core.builder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.jdt.core.javanature 33 | org.eclipse.m2e.core.maven2Nature 34 | org.eclipse.wst.common.project.facet.core.nature 35 | org.eclipse.wst.jsdt.core.jsNature 36 | 37 | 38 | -------------------------------------------------------------------------------- /microservice-notification/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | microservice-notification 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.common.project.facet.core.builder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.jdt.core.javanature 33 | org.eclipse.m2e.core.maven2Nature 34 | org.eclipse.wst.common.project.facet.core.nature 35 | org.eclipse.wst.jsdt.core.jsNature 36 | 37 | 38 | -------------------------------------------------------------------------------- /microservice-notification_v1_1/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | microservice-notification_v1_1 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.common.project.facet.core.builder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | org.eclipse.wst.validation.validationbuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.jdt.core.javanature 33 | org.eclipse.m2e.core.maven2Nature 34 | org.eclipse.wst.common.project.facet.core.nature 35 | org.eclipse.wst.jsdt.core.jsNature 36 | 37 | 38 | -------------------------------------------------------------------------------- /front-end-ui/npm_build/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "ignorePatterns": [ 4 | "projects/**/*" 5 | ], 6 | "overrides": [ 7 | { 8 | "files": [ 9 | "*.ts" 10 | ], 11 | "parserOptions": { 12 | "project": [ 13 | "tsconfig.json", 14 | "e2e/tsconfig.json" 15 | ], 16 | "createDefaultProgram": true 17 | }, 18 | "extends": [ 19 | "plugin:@angular-eslint/recommended", 20 | "plugin:@angular-eslint/template/process-inline-templates" 21 | ], 22 | "rules": { 23 | "@angular-eslint/component-selector": [ 24 | "error", 25 | { 26 | "prefix": "app", 27 | "style": "kebab-case", 28 | "type": "element" 29 | } 30 | ], 31 | "@angular-eslint/directive-selector": [ 32 | "error", 33 | { 34 | "prefix": "app", 35 | "style": "camelCase", 36 | "type": "attribute" 37 | } 38 | ] 39 | } 40 | }, 41 | { 42 | "files": [ 43 | "*.html" 44 | ], 45 | "extends": [ 46 | "plugin:@angular-eslint/template/recommended" 47 | ], 48 | "rules": {} 49 | } 50 | ] 51 | } 52 | -------------------------------------------------------------------------------- /microservice-occasion/src/main/java/net/wasdev/samples/microProfile/occasions/JwtBuilder.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.samples.microProfile.occasions; 12 | 13 | /** 14 | * Liberty provides a JWT builder with static methods that can be used to build a JWT. We are 15 | * abstracting that out here, so that we can run unit tests without the Liberty runtime in place. 16 | */ 17 | public interface JwtBuilder { 18 | /** 19 | * Build a JWT in compact form (base 64 encoded and signed). 20 | * 21 | * @param groupName The group name that should be in the JWT claims. 22 | * @param userName The user name that should be in the JWT claims. 23 | * @return A MP-compliant JWT. 24 | */ 25 | public String buildCompactJWT(String groupName, String userName); 26 | } 27 | -------------------------------------------------------------------------------- /shared-keystore/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /front-end-ui/src/app/auth/services/auth.service.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; 12 | import { Injectable } from '@angular/core'; 13 | import { Observable } from 'rxjs/Rx'; 14 | 15 | /** 16 | * Perform operations with the authorization backend microservice. 17 | */ 18 | @Injectable() 19 | export class AuthService { 20 | 21 | // Maven fills in these variables from the pom.xml 22 | private url: string = "${auth.service.url}"; 23 | 24 | constructor(private http: HttpClient) { 25 | this.url = this.url + ((this.url.indexOf('/', this.url.length - 1) === -1) ? '/': '') ; 26 | } 27 | 28 | getLoginJwt(): Observable> { 29 | return this.http.get>(this.url, { observe: 'response'}).map(data => data); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /microservice-notification_v1_1/src/main/java/net/wasdev/sample/microprofile/notification/extended/NotificationFallbackHandler.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.sample.microprofile.notification.extended; 12 | 13 | import java.util.logging.Logger; 14 | import javax.enterprise.context.Dependent; 15 | import org.eclipse.microprofile.faulttolerance.ExecutionContext; 16 | import org.eclipse.microprofile.faulttolerance.FallbackHandler; 17 | 18 | @Dependent 19 | public class NotificationFallbackHandler implements FallbackHandler { 20 | 21 | @Override 22 | public String handle(ExecutionContext context) { 23 | Object[] tweetParameters = context.getParameters(); 24 | String message = (String) tweetParameters[0]; 25 | Logger fbLogger = (Logger) tweetParameters[2]; 26 | fbLogger.info(message); 27 | return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /run-app/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /microservice-auth/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /run-app/startMongo.bat: -------------------------------------------------------------------------------- 1 | @REM This script is used to start a Mongo database with a specified name and port. 2 | @REM 3 | @REM Example usage: 4 | @REM 5 | @REM startMongo.sh [mongoPath] 6 | @REM 7 | @REM : The name of the directory to create and use to hold the Mongo DB 8 | @REM : The port with which to start the Mongo DB server 9 | @REM : Name of the build directory (Gradle = build, Maven = target) 10 | @REM [mongoPath] : Optional absolute path to the Mongo install bin directory 11 | 12 | @echo off 13 | 14 | @REM Get the needed params. 15 | set dbName=%1 16 | set dbPort=%2 17 | 18 | set buildDir=%3 19 | set mongoPath=%4 20 | 21 | @REM Set the mongoDB path. 22 | IF defined mongoPath SET PATH=%PATH%;%mongoPath% 23 | 24 | @REM Create the needed directories. 25 | if defined dbName ( 26 | IF NOT exist .\%buildDir%\%dbName% ( 27 | md .\%buildDir%\%dbName% 28 | ) 29 | IF NOT exist .\%buildDir%\%dbName%\logs ( 30 | md .\%buildDir%\%dbName%\logs 31 | ) 32 | IF NOT exist .\%buildDir%\%dbName%\mongoDB ( 33 | md .\%buildDir%\%dbName%\mongoDB 34 | ) 35 | ) 36 | @REM Install a mongoDB service and start it. 37 | 38 | mongod --logpath %CD%\%buildDir%\%dbName%\logs\%dbName%_start.log --port %dbPort% --dbpath %CD%\%buildDir%\%dbName%\mongoDB --install --serviceName %dbName% --serviceDisplayName %dbName% 39 | 40 | net start %dbName% 41 | -------------------------------------------------------------------------------- /microservice-occasion/src/main/java/net/wasdev/samples/microProfile/occasions/JwtBuilderImpl.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.samples.microProfile.occasions; 12 | 13 | import com.ibm.websphere.security.jwt.Claims; 14 | import javax.enterprise.context.ApplicationScoped; 15 | 16 | /** Implementation of the JWT Builder for Liberty. */ 17 | @ApplicationScoped 18 | public class JwtBuilderImpl implements JwtBuilder { 19 | 20 | @Override 21 | public String buildCompactJWT(String groupName, String userName) { 22 | try { 23 | return com.ibm.websphere.security.jwt.JwtBuilder.create("jwtOccasionBuilder") 24 | .claim(Claims.SUBJECT, userName) 25 | .claim("upn", userName) 26 | .claim("groups", groupName) 27 | .buildJwt() 28 | .compact(); 29 | } catch (Throwable t) { 30 | throw new RuntimeException(t); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /run-app/src/main/resources/users.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "user1", 4 | "firstName": "John", 5 | "lastName": "Smith", 6 | "userName": "jsmith", 7 | "twitterHandle": "@jsmith", 8 | "wishListLink": "http://my.wishlist.com/jsmith", 9 | "password": "jsmith" 10 | }, 11 | { 12 | "id": "user2", 13 | "firstName": "Fred", 14 | "lastName": "Murphy", 15 | "userName": "fmurphy", 16 | "twitterHandle": "@fmurphy", 17 | "wishListLink": "http://my.wishlist.com/fmurphy", 18 | "password": "fmurphy" 19 | }, 20 | { 21 | "id": "user3", 22 | "firstName": "Stacy", 23 | "lastName": "White", 24 | "userName": "swhite", 25 | "twitterHandle": "@swhite", 26 | "wishListLink": "http://my.wishlist.com/swhite", 27 | "password": "swhite" 28 | }, 29 | { 30 | "id": "user4", 31 | "firstName": "Linda", 32 | "lastName": "Williams", 33 | "userName": "lwilliams", 34 | "twitterHandle": "@lwilliams", 35 | "wishListLink": "http://my.wishlist.com/lwilliams", 36 | "password": "lwilliams" 37 | }, 38 | { 39 | "id": "user5", 40 | "firstName": "Allen", 41 | "lastName": "Grant", 42 | "userName": "agrant", 43 | "twitterHandle": "@agrant", 44 | "wishListLink": "http://my.wishlist.com/agrant", 45 | "password": "agrant" 46 | } 47 | ] -------------------------------------------------------------------------------- /microservice-notification/src/main/liberty/config/server.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | microProfile-1.0 13 | mpConfig-1.1 14 | mpJwt-1.0 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 29 | 31 | 32 | -------------------------------------------------------------------------------- /microservice-group/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /microservice-notification_v1_1/src/main/liberty/config/server.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | microProfile-1.0 13 | mpConfig-1.1 14 | mpFaultTolerance-1.0 15 | mpJwt-1.0 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /run-app/startMongo.sh: -------------------------------------------------------------------------------- 1 | # This script is used to start a Mongo database with a specified name and port. 2 | # 3 | # Example usage: 4 | # 5 | # startMongo.sh [mongoPath] 6 | # 7 | # : The name of the directory to create and use to hold the Mongo DB 8 | # : The port with which to start the Mongo DB server 9 | # : Name of the build directory (Gradle = build, Maven = target) 10 | # [mongoPath] : Optional, absolute path to the Mongo install bin directory 11 | # 12 | 13 | dbName=$1 14 | dbPort=$2 15 | buildDir=$3 16 | mongoPath=$4 17 | 18 | if [ ! $# -ge 3 ]; then 19 | echo 'Please provide at least a dbName, dbPort, and buildDir' 20 | echo 'Example usage:' 21 | echo '' 22 | echo ' startMongo.sh [mongoPath] ' 23 | fi 24 | 25 | # Set mongo path if defined 26 | if [ ! -z mongoPath ]; then 27 | export PATH=$PATH:${mongoPath} 28 | fi 29 | 30 | # Create the mongo db directory 31 | if [ ! -d ./${buildDir}/${dbName} ]; then 32 | mkdir ./${buildDir}/${dbName} 33 | fi 34 | if [ ! -d ./${buildDir}/${dbName}/logs ]; then 35 | mkdir ./${buildDir}/${dbName}/logs 36 | fi 37 | if [ ! -d ./${buildDir}/${dbName}/mongoDB ]; then 38 | mkdir ./${buildDir}/${dbName}/mongoDB 39 | fi 40 | 41 | # Start the mongo db server 42 | mongod --fork --logpath ./${buildDir}/${dbName}/logs/${dbName}.log --port ${dbPort} --dbpath ./${buildDir}/${dbName}/mongoDB | 43 | grep "forked process:" | 44 | awk '{split($0,a,":"); print a[2]}' > ./${buildDir}/${dbName}/${dbName}.pid 45 | 46 | echo "Starting user database with pid: " 47 | cat ./${buildDir}/${dbName}/${dbName}.pid 48 | -------------------------------------------------------------------------------- /front-end-ui/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import { TestBed, async } from '@angular/core/testing'; 12 | 13 | import { AppComponent } from './app.component'; 14 | 15 | describe('AppComponent', () => { 16 | beforeEach(async(() => { 17 | TestBed.configureTestingModule({ 18 | declarations: [ 19 | AppComponent 20 | ], 21 | }).compileComponents(); 22 | })); 23 | 24 | it('should create the app', async(() => { 25 | const fixture = TestBed.createComponent(AppComponent); 26 | const app = fixture.debugElement.componentInstance; 27 | expect(app).toBeTruthy(); 28 | })); 29 | 30 | it(`should have as title 'app'`, async(() => { 31 | const fixture = TestBed.createComponent(AppComponent); 32 | const app = fixture.debugElement.componentInstance; 33 | expect(app.title).toEqual('app'); 34 | })); 35 | 36 | it('should render title in a h1 tag', async(() => { 37 | const fixture = TestBed.createComponent(AppComponent); 38 | fixture.detectChanges(); 39 | const compiled = fixture.debugElement.nativeElement; 40 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); 41 | })); 42 | }); 43 | -------------------------------------------------------------------------------- /microservice-group/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | Acme Gifts: Group Microservice 15 | 16 | 17 | javax.ws.rs.core.Application 18 | 19 | 20 | 21 | javax.ws.rs.core.Application 22 | /* 23 | 24 | 25 | 26 | groupMicroservice 27 | SSL for group service 28 | /* 29 | GET 30 | POST 31 | PUT 32 | DELETE 33 | 34 | 35 | CONFIDENTIAL 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /microservice-occasion/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | Acme Gifts: Occasion Microservice 15 | 16 | 17 | javax.ws.rs.core.Application 18 | 19 | 20 | 21 | javax.ws.rs.core.Application 22 | /* 23 | 24 | 25 | 26 | 27 | occasionMicroservice 28 | SSL for occasion service 29 | /* 30 | GET 31 | POST 32 | PUT 33 | DELETE 34 | 35 | 36 | CONFIDENTIAL 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /microservice-auth/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 15 | Acme Gifts: Auth Microservice 16 | 17 | 18 | javax.ws.rs.core.Application 19 | 20 | 21 | 22 | javax.ws.rs.core.Application 23 | /* 24 | 25 | 26 | 27 | 28 | 29 | authMicroservice 30 | SSL for user service 31 | /auth 32 | GET 33 | POST 34 | 35 | 36 | CONFIDENTIAL 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /microservice-occasion/src/main/java/net/wasdev/samples/microProfile/occasions/OccasionResponse.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.samples.microProfile.occasions; 12 | 13 | import javax.ws.rs.core.Response; 14 | 15 | public class OccasionResponse { 16 | public static final String NOTIFICATION_TYPE_LOG = "Notification request logged."; 17 | public static final String NOTIFICATION_TYPE_TWEET = "Notification request tweeted."; 18 | public static final String NOTIFICATION_TYPE_ERROR = 19 | "Your occasion was processed but a notification request was not sent. The notification service is not available."; 20 | 21 | private Response notificationResponse; 22 | private String notificationType; 23 | private Throwable notificationThrowable; 24 | 25 | public OccasionResponse(Response response, String type, Throwable throwable) { 26 | notificationResponse = response; 27 | notificationType = type; 28 | notificationThrowable = throwable; 29 | } 30 | 31 | public String getNotificationType() { 32 | return notificationType; 33 | } 34 | 35 | public Response getNotificationResponse() { 36 | return notificationResponse; 37 | } 38 | 39 | public Throwable getNotificationThrowable() { 40 | return notificationThrowable; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /microservice-user/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 15 | Acme Gifts: User Microservice 16 | 17 | 18 | javax.ws.rs.core.Application 19 | 20 | 21 | 22 | javax.ws.rs.core.Application 23 | /* 24 | 25 | 26 | 27 | 28 | 29 | userMicroservice 30 | SSL for user service 31 | /* 32 | GET 33 | POST 34 | PUT 35 | DELETE 36 | 37 | 38 | CONFIDENTIAL 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /microservice-group/src/main/java/net/wasdev/samples/microprofile/group/MongoAccess.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.samples.microprofile.group; 12 | 13 | import com.mongodb.DB; 14 | import com.mongodb.MongoClient; 15 | import java.net.UnknownHostException; 16 | import javax.enterprise.context.ApplicationScoped; 17 | import javax.inject.Inject; 18 | import org.eclipse.microprofile.config.inject.ConfigProperty; 19 | 20 | /** Holds the MongoDB instance that the JAX-RS resources will use. */ 21 | @ApplicationScoped 22 | public class MongoAccess { 23 | /** The mongoDB hostname */ 24 | @Inject 25 | @ConfigProperty(name = "mongo.hostname") 26 | private String mongoHostname; 27 | 28 | /** The mongoDB port */ 29 | @Inject 30 | @ConfigProperty(name = "mongo.port") 31 | private int mongoPort; 32 | 33 | /** Cached DB reference used by all threads. */ 34 | private DB database = null; 35 | 36 | /** Get a connection to Mongo */ 37 | public synchronized DB getMongoDB() { 38 | if (database == null) { 39 | try { 40 | MongoClient client = new MongoClient(mongoHostname, mongoPort); 41 | database = client.getDB("gifts-group"); 42 | } catch (UnknownHostException uhe) { 43 | throw new RuntimeException(uhe); 44 | } 45 | } 46 | 47 | return database; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /microservice-occasion/src/main/java/net/wasdev/samples/microProfile/occasions/MongoAccess.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.samples.microProfile.occasions; 12 | 13 | import com.mongodb.DB; 14 | import com.mongodb.MongoClient; 15 | import java.net.UnknownHostException; 16 | import javax.enterprise.context.ApplicationScoped; 17 | import javax.inject.Inject; 18 | import org.eclipse.microprofile.config.inject.ConfigProperty; 19 | 20 | /** Holds the MongoDB instance that the JAX-RS resources will use. */ 21 | @ApplicationScoped 22 | public class MongoAccess { 23 | /** The mongoDB hostname */ 24 | @Inject 25 | @ConfigProperty(name = "mongo.hostname") 26 | private String mongoHostname; 27 | 28 | /** The mongoDB port */ 29 | @Inject 30 | @ConfigProperty(name = "mongo.port") 31 | private int mongoPort; 32 | 33 | /** Cached DB reference used by all threads. */ 34 | private DB database = null; 35 | 36 | /** Get a connection to Mongo */ 37 | public synchronized DB getMongoDB() { 38 | if (database == null) { 39 | try { 40 | MongoClient client = new MongoClient(mongoHostname, mongoPort); 41 | database = client.getDB("gifts-occasion"); 42 | } catch (UnknownHostException uhe) { 43 | throw new RuntimeException(uhe); 44 | } 45 | } 46 | 47 | return database; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /front-end-ui/src/app/group/group-add-member.component.html: -------------------------------------------------------------------------------- 1 | 10 |
11 |
12 |
13 | 14 | 15 | {{eventMessageError}} 16 |
17 |
18 |
19 |

20 | 21 | 22 |

23 |
24 | 25 |
26 |

Members

27 | 28 |
29 |
30 | 33 |
34 |


35 |
36 |
37 |
38 | 43 |
44 | -------------------------------------------------------------------------------- /microservice-group/src/main/liberty/config/server.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | microProfile-1.0 13 | mpConfig-1.1 14 | mpJwt-1.0 15 | ssl-1.0 16 | 17 | 18 | 19 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 38 | 39 | 42 | 44 | 45 | -------------------------------------------------------------------------------- /front-end-ui/src/app/group/group-create.component.html: -------------------------------------------------------------------------------- 1 | 10 |
11 |
12 |
13 | 14 | 15 | {{eventMessageError}} 16 |
17 |
18 |
19 |

20 |
21 |
22 | 23 | 25 | 26 |
27 |


28 |
29 |
30 |

Group Name

31 | 33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | 45 |
46 | -------------------------------------------------------------------------------- /front-end-ui/npm_build/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "front-end-ui", 3 | "version": "0.0.0", 4 | "license": "EPL-1.0", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "ng serve", 8 | "build": "ng build", 9 | "test": "ng test", 10 | "lint": "ng lint front-end-ui --fix", 11 | "e2e": "ng e2e", 12 | "preinstall": "npx npm-force-resolutions" 13 | }, 14 | "private": true, 15 | "dependencies": { 16 | "@angular/animations": "^13.3.12", 17 | "@angular/cdk": "^12.2.13", 18 | "@angular/common": "^13.3.12", 19 | "@angular/compiler": "^13.3.12", 20 | "@angular/core": "^13.3.12", 21 | "@angular/forms": "^13.3.12", 22 | "@angular/material": "^12.2.13", 23 | "@angular/platform-browser": "^13.3.12", 24 | "@angular/platform-browser-dynamic": "^13.3.12", 25 | "@angular/router": "^13.3.12", 26 | "acorn": "^6.4.1", 27 | "core-js": "^2.5.5", 28 | "rxjs": "^6.2.2", 29 | "rxjs-compat": "^6.2.2", 30 | "zone.js": "~0.11.4" 31 | }, 32 | "devDependencies": { 33 | "@angular-devkit/build-angular": "^13.3.10", 34 | "@angular-eslint/builder": "13.5.0", 35 | "@angular-eslint/eslint-plugin": "13.5.0", 36 | "@angular-eslint/eslint-plugin-template": "13.5.0", 37 | "@angular-eslint/schematics": "13.5.0", 38 | "@angular-eslint/template-parser": "13.5.0", 39 | "@angular/cli": "^13.3.10", 40 | "@angular/compiler-cli": "^13.3.12", 41 | "@angular/language-service": "^13.3.12", 42 | "@types/jasmine": "~2.5.53", 43 | "@types/jasminewd2": "~2.0.2", 44 | "@types/node": "~8.9.4", 45 | "@typescript-eslint/eslint-plugin": "5.27.1", 46 | "@typescript-eslint/parser": "5.27.1", 47 | "cssnano-preset-default": "~5.0.1", 48 | "eslint": "^8.17.0", 49 | "jasmine-core": "~2.6.2", 50 | "jasmine-spec-reporter": "~4.1.0", 51 | "karma": "^6.3.2", 52 | "karma-chrome-launcher": "~2.1.1", 53 | "karma-cli": "~2.0.0", 54 | "karma-coverage-istanbul-reporter": "^1.2.1", 55 | "karma-jasmine": "~1.1.0", 56 | "karma-jasmine-html-reporter": "^0.2.2", 57 | "protractor": "~7.0.0", 58 | "ts-node": "~5.0.0", 59 | "typescript": "~4.6.4" 60 | }, 61 | "resolutions": { 62 | "dns-packet": "1.3.4", 63 | "tar": "6.1.9" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /run-app/src/main/resources/cxf.xml: -------------------------------------------------------------------------------- 1 | 10 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 36 | .*_EXPORT_.* 37 | .*_EXPORT1024_.* 38 | .*_WITH_DES_.* 39 | .*_WITH_AES_.* 40 | .*_WITH_NULL_.* 41 | .*_DH_anon_.* 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /front-end-ui/src/app/login/services/login.service.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; 12 | import { Injectable } from '@angular/core'; 13 | import { Observable } from 'rxjs/Rx'; 14 | 15 | @Injectable() 16 | export class LoginService { 17 | 18 | // Maven fills in these variables from the pom.xml 19 | private url = '${user.service.login.url}'; 20 | 21 | constructor(private http: HttpClient) { 22 | this.url = this.url + ((this.url.indexOf('/', this.url.length - 1) === -1) ? '/': '') ; 23 | } 24 | 25 | login(payload: string): Observable> { 26 | let headers = new HttpHeaders(); 27 | headers = headers.set('Content-Type', 'application/json'); 28 | headers = headers.set('Authorization', sessionStorage.jwt); 29 | 30 | return this.http.post>(this.url, payload, { headers: headers, observe: 'response'}).map(data => data); 31 | } 32 | 33 | loginWithTwitter(): Observable> { 34 | let headers = new HttpHeaders(); 35 | headers = headers.set('Authorization', sessionStorage.jwt); 36 | 37 | return this.http.get(this.url + 'twitter', {headers: headers, observe: 'response'}).map(data => data); 38 | } 39 | 40 | loginWithTwitterVerify(payload: string): Observable> { 41 | let headers = new HttpHeaders(); 42 | headers = headers.set('Content-Type', 'application/json'); 43 | headers = headers.set('Authorization', sessionStorage.jwt); 44 | 45 | return this.http.post>( 46 | this.url + 'twitter/verify', payload, { headers: headers, observe: 'response'}).map(data => data); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /microservice-group/src/test/resources/cxf.xml: -------------------------------------------------------------------------------- 1 | 10 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 36 | .*_EXPORT_.* 37 | .*_EXPORT1024_.* 38 | .*_WITH_DES_.* 39 | .*_WITH_AES_.* 40 | .*_WITH_NULL_.* 41 | .*_DH_anon_.* 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /microservice-occasion/src/test/resources/cxf.xml: -------------------------------------------------------------------------------- 1 | 10 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 36 | .*_EXPORT_.* 37 | .*_EXPORT1024_.* 38 | .*_WITH_DES_.* 39 | .*_WITH_AES_.* 40 | .*_WITH_NULL_.* 41 | .*_DH_anon_.* 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /microservice-user/src/main/java/net/wasdev/sample/microprofile/user/MongoAccess.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.sample.microprofile.user; 12 | 13 | import com.mongodb.DB; 14 | import com.mongodb.MongoClient; 15 | import java.net.UnknownHostException; 16 | import javax.enterprise.context.ApplicationScoped; 17 | import javax.inject.Inject; 18 | import org.eclipse.microprofile.config.inject.ConfigProperty; 19 | 20 | /** Holds the MongoDB instance that the JAX-RS resources will use. */ 21 | @ApplicationScoped 22 | public class MongoAccess { 23 | /** 24 | * The mongoDB hostname is injected by MP Config. The hostname is defined in the project's POM, 25 | * and copied into Liberty's bootstrap.properties during the Maven build. bootstrap.properties is 26 | * a pre-configured config source for MP Config. 27 | */ 28 | @Inject 29 | @ConfigProperty(name = "mongo.hostname") 30 | private String mongoHostname; 31 | 32 | /** 33 | * The mongoDB port is injected by MP Config. The port is defined in the proejct's POM, and copied 34 | * into Liberty's bootstrap.properties during the Maven build. bootstrap.properties is a 35 | * pre-configured config source for MP Config. 36 | */ 37 | @Inject 38 | @ConfigProperty(name = "mongo.port") 39 | private int mongoPort; 40 | 41 | /** Cached Mongo DB reference used by all threads. */ 42 | private DB database = null; 43 | 44 | /** Get a connection to Mongo. */ 45 | public synchronized DB getMongoDB() { 46 | if (database == null) { 47 | try { 48 | MongoClient client = new MongoClient(mongoHostname, mongoPort); 49 | database = client.getDB("gifts-user"); 50 | } catch (UnknownHostException uhe) { 51 | throw new RuntimeException(uhe); 52 | } 53 | } 54 | 55 | return database; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /run-app/src/main/resources/occasions.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "occasion1", 4 | "date": "year-month-day", 5 | "groupId": "group1", 6 | "name": "John's Birthday", 7 | "organizerId": "user2", 8 | "recipientId": "user1", 9 | "contributions" : [ 10 | { 11 | "userId": "user2", 12 | "amount": 50 13 | }, 14 | { 15 | "userId": "user3", 16 | "amount": 100 17 | } 18 | ] 19 | }, 20 | { 21 | "id": "occasion2", 22 | "date": "year-month-day", 23 | "groupId": "group2", 24 | "name": "John's Birthday", 25 | "organizerId": "user4", 26 | "recipientId": "user1", 27 | "contributions" : [ 28 | { 29 | "userId": "user4", 30 | "amount": 80 31 | }, 32 | { 33 | "userId": "user5", 34 | "amount": 60 35 | } 36 | ] 37 | }, 38 | { 39 | "id": "occasion3", 40 | "date": "year-month-day", 41 | "groupId": "group1", 42 | "name": "Stacy's Retirement Party", 43 | "organizerId": "user1", 44 | "recipientId": "user3", 45 | "contributions" : [ 46 | { 47 | "userId": "user1", 48 | "amount": 50 49 | }, 50 | { 51 | "userId": "user2", 52 | "amount": 50 53 | } 54 | ] 55 | }, 56 | { 57 | "id": "occasion4", 58 | "date": "year-month-day", 59 | "groupId": "group2", 60 | "name": "Linda's Birthday", 61 | "organizerId": "user1", 62 | "recipientId": "user4", 63 | "contributions" : [ 64 | { 65 | "userId": "user1", 66 | "amount": 100 67 | }, 68 | { 69 | "userId": "user5", 70 | "amount": 200 71 | } 72 | ] 73 | } 74 | ] -------------------------------------------------------------------------------- /microservice-user/src/test/resources/cxf.xml: -------------------------------------------------------------------------------- 1 | 10 | 12 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 38 | .*_EXPORT_.* 39 | .*_EXPORT1024_.* 40 | .*_WITH_DES_.* 41 | .*_WITH_AES_.* 42 | .*_WITH_NULL_.* 43 | .*_DH_anon_.* 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /front-end-ui/src/app/group/groups.component.html: -------------------------------------------------------------------------------- 1 | 10 |
11 |
12 |
13 | 14 | 15 | {{eventMessageError}} 16 |
17 |
18 |
19 |

20 |
21 | 22 | 23 |
24 |


25 |
26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
GroupAmount
{{onGetGroupName(group)}}{{onGetLoggedInUserTotalGroupContribution(group) | currency:"USD":true}}
39 |
40 |
41 |
42 |
43 |
Total Spending: {{loggedInUserTotalContribution | currency:"USD":true}}
44 |
45 |
46 |


47 |
48 | 53 |
54 | -------------------------------------------------------------------------------- /microservice-occasion/src/main/java/net/wasdev/samples/microProfile/occasions/NotificationRetryBean.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.samples.microProfile.occasions; 12 | 13 | import java.io.IOException; 14 | import javax.enterprise.context.ApplicationScoped; 15 | import javax.json.Json; 16 | import javax.json.JsonBuilderFactory; 17 | import javax.json.JsonObject; 18 | import javax.json.JsonObjectBuilder; 19 | import javax.ws.rs.core.Response; 20 | import org.eclipse.microprofile.faulttolerance.Fallback; 21 | import org.eclipse.microprofile.faulttolerance.Retry; 22 | 23 | @ApplicationScoped 24 | public class NotificationRetryBean { 25 | 26 | // Notification keys 27 | public static final String JSON_KEY_NOTIFICATION = "notification"; 28 | 29 | /* 30 | * Retried twice in the event of failure, after which the fallback handler 31 | * will be driven to try microservice-notification_v1_1 32 | */ 33 | @Retry(maxRetries = 2) 34 | @Fallback(NotificationFallbackHandler.class) 35 | public OccasionResponse makeNotificationConnection( 36 | String message, 37 | Orchestrator orchestrator, 38 | String jwtTokenString, 39 | String notification11ServiceUrl, 40 | String twitterHandle, 41 | String notificationServiceUrl) 42 | throws IOException { 43 | 44 | JsonBuilderFactory factory = Json.createBuilderFactory(null); 45 | JsonObjectBuilder builder = factory.createObjectBuilder(); 46 | JsonObject notificationRequestPayload = builder.add(JSON_KEY_NOTIFICATION, message).build(); 47 | Response notificationResponse = 48 | orchestrator.makeConnection( 49 | "POST", notificationServiceUrl, notificationRequestPayload.toString(), jwtTokenString); 50 | OccasionResponse occasionResponse = 51 | new OccasionResponse(notificationResponse, OccasionResponse.NOTIFICATION_TYPE_LOG, null); 52 | 53 | return occasionResponse; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /microservice-auth/src/test/resources/cxf.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 14 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | 35 | 36 | 40 | .*_EXPORT_.* 41 | .*_EXPORT1024_.* 42 | .*_WITH_DES_.* 43 | .*_WITH_AES_.* 44 | .*_WITH_NULL_.* 45 | .*_DH_anon_.* 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /front-end-ui/src/app/header/header.component.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import { Component, OnInit } from '@angular/core'; 12 | import { DomSanitizer } from '@angular/platform-browser'; 13 | import { MatIconRegistry } from '@angular/material/icon'; 14 | import { Router, ActivatedRoute, ParamMap } from '@angular/router'; 15 | 16 | // This component is responsible for putting the header at the top 17 | // of the page if the user has logged in. 18 | @Component({ 19 | selector: 'app-header', 20 | templateUrl: './header.component.html' 21 | }) 22 | export class HeaderComponent implements OnInit { 23 | 24 | userName: string = null; 25 | userId: string = null; 26 | 27 | constructor(private router: Router, 28 | iconRegistry: MatIconRegistry, 29 | sanitizer: DomSanitizer) { 30 | // Need to register the icon that we'll use to display the menu 31 | // in the header. This is required by the material code that 32 | // we use to display the menu (icon). 33 | iconRegistry.addSvgIcon( 34 | 'hamburger', 35 | sanitizer.bypassSecurityTrustResourceUrl('assets/images/icon_menu.svg')); 36 | } 37 | 38 | ngOnInit() { 39 | this.userName = sessionStorage.userName; 40 | this.userId = sessionStorage.userId; 41 | 42 | // Every time the route changes (user navigates to a new 43 | // page/view), check to see if the user name is still set 44 | // in session storage. If there is a change, the HTML 45 | // for the header will be hidden or shown. 46 | this.router.events.subscribe((event) => { 47 | this.userName = sessionStorage.userName; 48 | this.userId = sessionStorage.userId; 49 | }); 50 | } 51 | 52 | onLogout(): void { 53 | this.router.navigate(['logout']); 54 | } 55 | 56 | onEditProfile(): void { 57 | this.router.navigate(['profiles',sessionStorage.userId, 'edit']); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /shared-keystore/build.gradle: -------------------------------------------------------------------------------- 1 | import org.figurate.gradle.plugin.keytool.KeytoolTask 2 | 3 | apply plugin: 'keytool' 4 | 5 | description = 'Shared Keystore' 6 | dependencies { 7 | compile group: 'junit', name: 'junit', version:'4.12' 8 | compileOnly group: 'javax', name: 'javaee-api', version:'7.0' 9 | compileOnly group: 'org.glassfish', name: 'javax.json', version:'1.0.4' 10 | compileOnly group: 'org.apache.cxf', name: 'cxf-rt-rs-client', version:'3.1.1' 11 | } 12 | 13 | buildscript { 14 | repositories { 15 | mavenCentral() 16 | } 17 | dependencies { 18 | classpath "org.figurate:gradle-keytool-plugin:1.0.0" 19 | } 20 | } 21 | 22 | task generateKeyPair (type: KeytoolTask) { 23 | args '-genkeypair' 24 | options { 25 | keypass = 'secret' 26 | keyalg = 'RSA' 27 | keysize = '2048' 28 | sigalg = 'SHA256withRSA' 29 | alias = 'default' 30 | dname = 'CN=localhost,OU=userServer,O=IBM,C=US' 31 | validity = '999' 32 | keystore = "${projectDir}/src/main/resources/keystore.jceks" 33 | storepass = 'secret' 34 | storetype = 'jceks' 35 | } 36 | onlyIf { ! new File("${projectDir}/src/main/resources/keystore.jceks").exists() } 37 | outputs.file("${projectDir}/src/main/resources/keystore.jceks") // for clean 38 | } 39 | 40 | task addTwitter1 (type: KeytoolTask) { 41 | args '-importcert', '-noprompt' 42 | options { 43 | alias = 'Twitter1' 44 | file = 'certs/DigiCertSHA2HighAssuranceServerCA.crt' 45 | keystore = "${projectDir}/src/main/resources/keystore.jceks" 46 | storepass = 'secret' 47 | storetype = 'jceks' 48 | } 49 | ignoreExitValue = true 50 | 51 | doLast { println ("Ignore duplicate certification keytool error.") } 52 | } 53 | 54 | task addTwitter2 (type: KeytoolTask) { 55 | args '-importcert', '-noprompt' 56 | options { 57 | alias = 'Twitter2' 58 | file = 'certs/DigiCertSHA2SecureServerCA.crt' 59 | keystore = "${projectDir}/src/main/resources/keystore.jceks" 60 | storepass = 'secret' 61 | storetype = 'jceks' 62 | } 63 | ignoreExitValue = true 64 | 65 | doLast { println ("Ignore duplicate certification keytool error.") } 66 | } 67 | 68 | // reinforcement to produce the shared-keystore jar 69 | assemble.dependsOn 'jar' 70 | 71 | processResources.dependsOn 'generateKeyPair' 72 | generateKeyPair.finalizedBy 'addTwitter1', 'addTwitter2' 73 | clean.finalizedBy 'cleanGenerateKeyPair' -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /microservice-occasion/src/main/resources/liberty/config/server.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | microProfile-1.0 14 | mpConfig-1.1 15 | mpFaultTolerance-1.0 16 | mpJwt-1.0 17 | ssl-1.0 18 | 19 | 20 | 21 | 23 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 48 | 50 | 51 | 54 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /docker-build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | MONGO_HOSTNAME="mongo" 4 | MONGO_PORT=27017 5 | DOMAIN="default.svc.cluster.local" 6 | MINIKUBE_IP=$(minikube ip) 7 | 8 | mvn -Dmaven.test.skip=true \ 9 | -Dkeystore_CN=*.$DOMAIN \ 10 | -Duser.mongo.hostname=$MONGO_HOSTNAME \ 11 | -Duser.mongo.port=$MONGO_PORT \ 12 | -Duser.http.port=9080 \ 13 | -Duser.https.port=9443 \ 14 | -Duser.hostname=user.$DOMAIN \ 15 | -Duser.service.url=/service/users \ 16 | -Duser.service.login.url=/service/logins \ 17 | -Dgroup.mongo.hostname=$MONGO_HOSTNAME \ 18 | -Dgroup.mongo.port=$MONGO_PORT \ 19 | -Dgroup.http.port=9080 \ 20 | -Dgroup.https.port=9443 \ 21 | -Dgroup.hostname=group.$DOMAIN \ 22 | -Dgroup.service.url=/service/groups \ 23 | -Doccasion.mongo.hostname=$MONGO_HOSTNAME \ 24 | -Doccasion.mongo.port=$MONGO_PORT \ 25 | -Doccasion.http.port=9080 \ 26 | -Doccasion.https.port=9443 \ 27 | -Doccasion.hostname=occasion.$DOMAIN \ 28 | -Doccasion.service.url=/service/occasions \ 29 | -Dnotification.http.port=9080 \ 30 | -Dnotification.https.port=9443 \ 31 | -Dnotification.hostname=notification.$DOMAIN \ 32 | -Dnotification.log.file=/logs/notifications.log \ 33 | -Dnotification_1_1.http.port=9080 \ 34 | -Dnotification_1_1.https.port=9443 \ 35 | -Dnotification_1_1.hostname=notification11.$DOMAIN \ 36 | -Dnotification_1_1.log.file=/logs/notifications_1_1.log \ 37 | -Dnotification_1_1.fallback.log.file=/logs/notifications_1_1_fallback.log \ 38 | -Dtwitter.app.consumer.key=CHANGE_ME \ 39 | -Dtwitter.app.consumer.secret=CHANGE_ME \ 40 | -Dtwitter.user.access.token=CHANGE_ME \ 41 | -Dtwitter.user.access.secret=CHANGE_ME \ 42 | -Dfrontend.http.port=9080 \ 43 | -Dfrontend.https.port=9443 \ 44 | -Dfrontend.hostname=frontend.$DOMAIN \ 45 | -Dfrontend.url=https://$MINIKUBE_IP \ 46 | -Dauth.http.port=9080 \ 47 | -Dauth.https.port=9443 \ 48 | -Dauth.hostname=auth.$DOMAIN \ 49 | -Dauth.service.url=/service/auth \ 50 | clean package install 51 | 52 | NAMESPACE="acmegifts" 53 | docker build -t $NAMESPACE/front-end-ui:latest front-end-ui 54 | docker build -t $NAMESPACE/microservice-auth:latest microservice-auth 55 | docker build -t $NAMESPACE/microservice-group:latest microservice-group 56 | docker build -t $NAMESPACE/microservice-notification:latest microservice-notification 57 | docker build -t $NAMESPACE/microservice-notification-v1-1:latest microservice-notification_v1_1 58 | docker build -t $NAMESPACE/microservice-occasion:latest microservice-occasion 59 | docker build -t $NAMESPACE/microservice-user:latest microservice-user -------------------------------------------------------------------------------- /front-end-ui/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import { NgModule } from '@angular/core'; 12 | 13 | import { AppComponent } from './app.component'; 14 | import { GroupAddMemberComponent } from './group/group-add-member.component'; 15 | import { GroupComponent} from './group/group.component'; 16 | import { GroupCreateComponent} from './group/group-create.component'; 17 | import { GroupsComponent} from './group/groups.component'; 18 | import { LoginComponent } from './login/login.component'; 19 | import { LogoutComponent } from './logout/logout.component'; 20 | import { OccasionCreationComponent } from './occasion/occasion-create.component'; 21 | import { OccasionEditComponent } from './occasion/occasion-edit.component'; 22 | import { Routes, RouterModule } from '@angular/router'; 23 | import { ProfileCreateComponent } from './signup/profile-create.component'; 24 | import { ProfileEditComponent } from './signup/profile-edit.component'; 25 | import { TwitterLoginComponent } from './login/twitter.login.component'; 26 | import { TwitterVerifyComponent } from './login/twitter.verify.component'; 27 | 28 | const routes: Routes = [ 29 | { path: '', redirectTo: 'login', pathMatch: 'full' }, 30 | { path: 'groups', component: GroupsComponent }, 31 | { path: 'groups/group', component: GroupComponent }, 32 | { path: 'groups/group/create', component: GroupCreateComponent}, 33 | { path: 'groups/member/add', component: GroupAddMemberComponent}, 34 | { path: 'login', component: LoginComponent }, 35 | { path: 'logout', component: LogoutComponent }, 36 | { path: 'login/twitter', component: TwitterLoginComponent }, 37 | { path: 'login/twitter/verify', component: TwitterVerifyComponent }, 38 | { path: 'occasions', component: OccasionCreationComponent }, 39 | { path: 'occasions/:id/edit', component: OccasionEditComponent }, 40 | { path: 'signup', component: ProfileCreateComponent }, 41 | { path: 'profiles/:id/edit', component: ProfileEditComponent } 42 | ]; 43 | 44 | export const routing = RouterModule.forRoot(routes); 45 | -------------------------------------------------------------------------------- /microservice-auth/src/main/liberty/config/server.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | microProfile-1.0 13 | mpConfig-1.1 14 | jwt-1.0 15 | ssl-1.0 16 | 17 | 18 | 20 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 30 | 32 | 37 | 38 | 43 | 45 | 46 | 50 | 52 | 53 | -------------------------------------------------------------------------------- /front-end-ui/src/app/login/twitter.login.component.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import { Component, OnInit } from '@angular/core'; 12 | import { HttpClient, HttpHeaders, HttpErrorResponse, HttpResponse} from '@angular/common/http'; 13 | import { Router } from '@angular/router'; 14 | import { AuthService } from '../auth/services/auth.service'; 15 | import { LoginService } from './services/login.service'; 16 | 17 | @Component({ 18 | template: '', 19 | providers: [AuthService, LoginService] 20 | }) 21 | export class TwitterLoginComponent implements OnInit { 22 | 23 | constructor(private http: HttpClient, private router: Router, 24 | private authService: AuthService, 25 | private loginService: LoginService) {} 26 | 27 | // This performs the first part of the twitter login. We're 28 | // basically delegating to the user microservice, who should 29 | // respond with an oauth token which we'll use to build a URL 30 | // and redirect to Twitter where the user will enter their Twitter 31 | // credentials. 32 | ngOnInit() { 33 | this.authService.getLoginJwt().subscribe((res2: HttpResponse) => { 34 | sessionStorage.jwt = res2.headers.get('Authorization'); 35 | this.loginService.loginWithTwitter().subscribe((response: HttpResponse) => { 36 | let resBody = response.body; 37 | if ('error' in resBody) { 38 | this.router.navigate([ '/login' ], { queryParams: {'retryMessage': resBody['error']} }); 39 | } else { 40 | const oauthToken: string = resBody['oauth_token']; 41 | window.location.href = 'https://api.twitter.com/oauth/authenticate?oauth_token=' + oauthToken; 42 | } 43 | }, (err: any) => { 44 | this.router.navigate([ '/login' ], { queryParams: {'retryMessage': 'serverError'} }); 45 | }); 46 | }, (err: any) => { 47 | this.router.navigate([ '/login' ], { queryParams: {'retryMessage': 'serverError'} }); 48 | }); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /run-app/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | description = "Sub-project wrapper for running the application." 3 | dependencies { 4 | compile group: 'javax', name: 'javaee-api', version:'7.0' 5 | compile project(':shared-keystore') 6 | compile group: 'org.glassfish', name: 'javax.json', version:'1.0.4' 7 | compile group: 'org.apache.cxf', name: 'cxf-rt-rs-client', version:'3.1.1' 8 | compile group: 'org.springframework', name: 'spring-context', version:'4.3.9.RELEASE' 9 | } 10 | 11 | jar { 12 | archiveName = "demoData.jar" 13 | manifest { 14 | attributes( 15 | 'Class-Path': configurations.compile.collect { "$buildDir/dependency-jars/" + it.getName() }.join(' '), 16 | 'Main-Class': 'demo.DemoData') 17 | } 18 | } 19 | 20 | task copyDependencies (type: Copy) { 21 | dependsOn ':shared-keystore:assemble' 22 | from configurations.compile 23 | into "$buildDir/dependency-jars" 24 | } 25 | 26 | task startServers { 27 | dependsOn ':microservice-auth:libertyStart', 28 | ':microservice-user:libertyStart', 29 | ':microservice-group:libertyStart', 30 | ':microservice-notification:libertyStart', 31 | ':microservice-notification_v1_1:libertyStart', 32 | ':front-end-ui:libertyStart', 33 | ':microservice-occasion:libertyStart' 34 | } 35 | 36 | task startDatabases { 37 | dependsOn ':microservice-user:startDatabase', 38 | ':microservice-group:startDatabase', 39 | ':microservice-occasion:startDatabase' 40 | 41 | } 42 | 43 | task stopServers { 44 | dependsOn ':microservice-auth:libertyStop', 45 | ':microservice-user:libertyStop', 46 | ':microservice-group:libertyStop', 47 | ':microservice-notification:libertyStop', 48 | ':microservice-notification_v1_1:libertyStop', 49 | ':front-end-ui:libertyStop', 50 | ':microservice-occasion:libertyStop' 51 | } 52 | 53 | task stopDatabases { 54 | dependsOn ':microservice-user:stopDatabase', 55 | ':microservice-group:stopDatabase', 56 | ':microservice-occasion:stopDatabase' 57 | } 58 | 59 | task demo (type: Exec) { 60 | dependsOn 'assemble', 'start' 61 | 62 | commandLine = 63 | ['java', '-Djavax.net.ssl.keyStorePassword=secret', 64 | '-jar', "$buildDir/libs/demoData.jar", 65 | userHostname, userHttpsPort, 66 | groupHostname, groupHttpsPort, 67 | occasionHostname, occasionHttpsPort, 68 | authHostname, authHttpsPort] 69 | } 70 | 71 | task start { 72 | dependsOn 'startServers', 'startDatabases' 73 | } 74 | 75 | task stop { 76 | dependsOn 'stopServers', 'stopDatabases' 77 | } 78 | 79 | assemble.dependsOn 'copyDependencies' 80 | clean.dependsOn 'stop' -------------------------------------------------------------------------------- /microservice-user/src/main/liberty/config/server.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | microProfile-1.0 13 | mpJwt-1.0 14 | mpConfig-1.1 15 | ssl-1.0 16 | 17 | 18 | 20 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | 35 | 36 | 37 | 38 | 40 | 45 | 46 | 51 | 52 | 55 | 57 | 58 | 60 | 62 | 63 | -------------------------------------------------------------------------------- /microservice-notification/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | description = 'Microservice :: Notification' 3 | 4 | buildscript { 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath "net.wasdev.wlp.gradle.plugins:liberty-gradle-plugin:2.1" 10 | } 11 | } 12 | 13 | ext { 14 | warfileName = 'notificationMicroservice' 15 | wlpServerName = 'notificationServer' 16 | notificationLogFile = new File("$buildDir/logs/notifications.log") 17 | } 18 | 19 | war { 20 | archiveName = "${warfileName}.war" 21 | } 22 | 23 | liberty { 24 | server { 25 | name = wlpServerName 26 | apps = [war] 27 | bootstrapProperties = 28 | ['log.file':notificationLogFile, 'app.name':war.archiveName, 29 | 'http.port':notificationHttpPort, 'https.port':notificationHttpsPort, 'jwt.issuer':jwtIssuer] 30 | } 31 | } 32 | 33 | test { 34 | group 'Verification' 35 | reports.html.destination = file("$buildDir/reports/unit") 36 | reports.junitXml.destination = file("$buildDir/test-reports/unit") 37 | exclude '**/test/**' 38 | 39 | // run every time when called 40 | outputs.upToDateWhen { false } 41 | } 42 | 43 | task integrationTest(type: Test) { 44 | group 'Verification' 45 | description 'Runs the integration tests.' 46 | reports.html.destination = file("$buildDir/reports/it") 47 | reports.junitXml.destination = file("$buildDir/test-reports/it") 48 | include '**/test/**' 49 | 50 | systemProperties = ['log.file': notificationLogFile, 51 | 'liberty.test.hostname': notificationHostname, 52 | 'liberty.test.port': notificationHttpPort, 53 | 'jwt.issuer': jwtIssuer, 54 | 'javax.net.ssl.keyStorePassword': "secret"] 55 | 56 | // run every time when called 57 | outputs.upToDateWhen { false } 58 | } 59 | 60 | task copyKeystore (type: Copy) { 61 | configurations.keystore.each { 62 | from(zipTree(it)) { 63 | include "keystore.jceks" 64 | } 65 | } 66 | into "$buildDir/wlp/usr/servers/${wlpServerName}/resources/security" 67 | outputs.file("$buildDir/wlp/usr/servers/${wlpServerName}/resources/security/keystore.jceks") 68 | } 69 | 70 | task testKeystore(type: Copy) { 71 | dependsOn 'copyKeystore' 72 | from "$buildDir/wlp/usr/servers/${wlpServerName}/resources/security" 73 | into "$buildDir/resources/test/truststore/" 74 | outputs.file("$buildDir/resources/test/truststore/keystore.jceks") 75 | } 76 | 77 | check.dependsOn 'integrationTest' 78 | integrationTest.dependsOn 'libertyStart', 'testKeystore' 79 | integrationTest.finalizedBy 'libertyStop' 80 | libertyStart.dependsOn 'copyKeystore' 81 | clean.dependsOn 'libertyStop' 82 | copyKeystore.dependsOn ':shared-keystore:assemble', 'libertyCreate' -------------------------------------------------------------------------------- /microservice-auth/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | description = 'Microservice :: Authentication' 3 | 4 | dependencies { 5 | compile group: 'javax', name: 'javaee-api', version:'7.0' 6 | compile group: 'com.ibm.websphere.appserver.api', name: 'com.ibm.websphere.appserver.api.jwt', version:'1.0.16' 7 | } 8 | 9 | buildscript { 10 | repositories { 11 | mavenCentral() 12 | } 13 | dependencies { 14 | classpath "net.wasdev.wlp.gradle.plugins:liberty-gradle-plugin:2.1" 15 | } 16 | } 17 | 18 | ext { 19 | warfileName = 'authMicroservice' 20 | wlpServerName = 'authServer' 21 | } 22 | 23 | war { 24 | archiveName = "${warfileName}.war" 25 | } 26 | 27 | liberty { 28 | server { 29 | name = wlpServerName 30 | apps = [war] 31 | bootstrapProperties = 32 | ['app.name':war.archiveName, 'http.port':authHttpPort, 'https.port':authHttpsPort, 33 | 'jwt.issuer':jwtIssuer] 34 | looseApplication = false 35 | } 36 | } 37 | 38 | task url { 39 | doLast { println authURL + '/auth'} 40 | } 41 | 42 | test { 43 | group 'Verification' 44 | reports.html.destination = file("$buildDir/reports/unit") 45 | reports.junitXml.destination = file("$buildDir/test-reports/unit") 46 | exclude '**/test/**' 47 | 48 | // run every time when called 49 | outputs.upToDateWhen { false } 50 | } 51 | 52 | task integrationTest(type: Test) { 53 | group 'Verification' 54 | description 'Runs the integration tests.' 55 | reports.html.destination = file("$buildDir/reports/it") 56 | reports.junitXml.destination = file("$buildDir/test-reports/it") 57 | include '**/test/**' 58 | 59 | systemProperties = ['liberty.test.auth.service.url': authServiceURL, 60 | 'javax.net.ssl.keyStorePassword': "secret"] 61 | 62 | // run every time when called 63 | outputs.upToDateWhen { false } 64 | } 65 | 66 | task copyKeystore(type: Copy) { 67 | configurations.keystore.each { 68 | from(zipTree(it)) { 69 | include "keystore.jceks" 70 | } 71 | } 72 | into "$buildDir/wlp/usr/servers/${wlpServerName}/resources/security" 73 | outputs.file("$buildDir/wlp/usr/servers/${wlpServerName}/resources/security/keystore.jceks") 74 | } 75 | 76 | task testKeystore(type: Copy) { 77 | dependsOn 'copyKeystore' 78 | from "$buildDir/wlp/usr/servers/${wlpServerName}/resources/security" 79 | into "$buildDir/resources/test/truststore/" 80 | outputs.file("$buildDir/resources/test/truststore/keystore.jceks") 81 | } 82 | 83 | check.dependsOn 'integrationTest' 84 | integrationTest.dependsOn 'libertyStart', 'testKeystore' 85 | integrationTest.finalizedBy 'libertyStop' 86 | libertyStart.dependsOn 'copyKeystore' 87 | clean.dependsOn 'libertyStop' 88 | copyKeystore.dependsOn ':shared-keystore:assemble', 'libertyCreate' 89 | -------------------------------------------------------------------------------- /microservice-occasion/src/main/java/net/wasdev/samples/microProfile/occasions/NotificationFallbackHandler.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.samples.microProfile.occasions; 12 | 13 | import java.io.IOException; 14 | import javax.enterprise.context.Dependent; 15 | import javax.json.Json; 16 | import javax.json.JsonObjectBuilder; 17 | import javax.ws.rs.core.Response; 18 | import org.eclipse.microprofile.faulttolerance.ExecutionContext; 19 | import org.eclipse.microprofile.faulttolerance.FallbackHandler; 20 | 21 | @Dependent 22 | public class NotificationFallbackHandler implements FallbackHandler { 23 | 24 | private static final String JSON_KEY_NOTIFICATION = "notification"; 25 | private static final String JSON_KEY_TWITTER_HANDLE = "twiterHandle"; 26 | private static final String JSON_KEY_MESSAGE = "message"; 27 | private static final String JSON_KEY_TWITTER_NOTIF_MODE = "notificationMode"; 28 | 29 | private static final String JSON_KEY_TWITTER_NOTIF_MODE_POST_MENTION = "mention"; 30 | 31 | @Override 32 | public OccasionResponse handle(ExecutionContext context) { 33 | 34 | Object[] connectParameters = context.getParameters(); 35 | String message = (String) connectParameters[0]; 36 | Orchestrator orchestrator = (Orchestrator) connectParameters[1]; 37 | String jwtTokenString = (String) connectParameters[2]; 38 | String notification11ServiceUrl = (String) connectParameters[3]; 39 | String twitterRecepientHandle = (String) connectParameters[4]; 40 | 41 | JsonObjectBuilder content = Json.createObjectBuilder(); 42 | content.add(JSON_KEY_TWITTER_HANDLE, twitterRecepientHandle); 43 | content.add(JSON_KEY_TWITTER_NOTIF_MODE, JSON_KEY_TWITTER_NOTIF_MODE_POST_MENTION); 44 | content.add(JSON_KEY_MESSAGE, message); 45 | JsonObjectBuilder notification = Json.createObjectBuilder(); 46 | notification.add(JSON_KEY_NOTIFICATION, content.build()); 47 | String payload = notification.build().toString(); 48 | 49 | Response notificationResponse = null; 50 | try { 51 | notificationResponse = 52 | orchestrator.makeConnection("POST", notification11ServiceUrl, payload, jwtTokenString); 53 | } catch (IOException e) { 54 | e.printStackTrace(); 55 | } 56 | OccasionResponse occasionResponse = 57 | new OccasionResponse(notificationResponse, OccasionResponse.NOTIFICATION_TYPE_TWEET, null); 58 | return occasionResponse; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /microservice-group/src/main/webapp/META-INF/swagger.json: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "info": { 4 | "title": "Group Service API", 5 | "description": "Group Service API", 6 | "version": "1.0.0" 7 | }, 8 | "paths":{ 9 | "/groups":{ 10 | "post":{ 11 | "summary":"Creates a group", 12 | "parameters":[{ 13 | "name":"group", 14 | "in":"body", 15 | "required":"true", 16 | "schema":{ 17 | "$ref":"#/definitions/Group" 18 | } 19 | }], 20 | "responses":{ 21 | "200":{ 22 | "description": "Group is successfully created", 23 | "schema":{ 24 | "type":"object", 25 | "properties":[{ 26 | "id":{ 27 | "type":"string" 28 | } 29 | }] 30 | } 31 | } 32 | } 33 | } 34 | }, 35 | "/groups/{id}":{ 36 | "get":{ 37 | "summary":"Gets group info for a specified group id", 38 | "parameters":{ 39 | "name":"id", 40 | "required":"true", 41 | "in":"path", 42 | "type":"string" 43 | }, 44 | "responses":{ 45 | "200":{ 46 | "description": "Group information is successfully retrieved", 47 | "schema":{ 48 | "$ref":"#/definitions/Group" 49 | } 50 | }, 51 | "400":{ 52 | "description": "Group is not found" 53 | } 54 | } 55 | }, 56 | "delete":{ 57 | "summary":"Deletes a group with a specified group id", 58 | "parameters":{ 59 | "name":"id", 60 | "required":"true", 61 | "in":"path", 62 | "type":"string" 63 | }, 64 | "responses":{ 65 | "200":{ 66 | "description": "Group is successfully deleted" 67 | }, 68 | "400":{ 69 | "description": "Group is not found" 70 | } 71 | } 72 | }, 73 | "put":{ 74 | "summary":"Updates a group", 75 | "parameters":[{ 76 | "name":"id", 77 | "required":"true", 78 | "in":"path", 79 | "type":"string" 80 | }, 81 | { 82 | "name":"group", 83 | "in":"body", 84 | "required":"true", 85 | "schema":{ 86 | "$ref":"#/definitions/Group" 87 | } 88 | }], 89 | "responses":{ 90 | "200":{ 91 | "description": "Group is successfully updated" 92 | }, 93 | "400":{ 94 | "description": "Group is not found" 95 | } 96 | } 97 | } 98 | } 99 | }, 100 | "definitions":{ 101 | "Group":{ 102 | "type":"object", 103 | "properties":{ 104 | "groupName":{ 105 | "type":"string" 106 | }, 107 | "members":{ 108 | "type":"array", 109 | "items":{ 110 | "type":"string" 111 | } 112 | }, 113 | "occasions":{ 114 | "type":"array", 115 | "items":{ 116 | "type":"string" 117 | } 118 | } 119 | } 120 | } 121 | } 122 | } -------------------------------------------------------------------------------- /front-end-ui/src/app/user/services/user.service.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import 'rxjs/add/operator/map'; 12 | import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; 13 | import { Injectable } from '@angular/core'; 14 | import { Observable } from 'rxjs/Rx'; 15 | import { User } from '../user'; 16 | import { Users } from '../users'; 17 | 18 | /** 19 | * Perform operations with the user backend microservice. 20 | */ 21 | @Injectable() 22 | export class UserService { 23 | private users: User[]; 24 | private url = '${user.service.url}'; 25 | 26 | constructor(private http: HttpClient) { 27 | this.url = this.url + ((this.url.indexOf('/', this.url.length - 1) === -1) ? '/': '') ; 28 | } 29 | 30 | getUsers(): Observable { 31 | let headers = new HttpHeaders(); 32 | headers = headers.set('Authorization', sessionStorage.jwt); 33 | 34 | return this.http.get(this.url, { headers: headers }) 35 | .map(data => data); 36 | } 37 | 38 | getUser(userId: string): Observable { 39 | let headers = new HttpHeaders(); 40 | headers = headers.set('Authorization', sessionStorage.jwt); 41 | 42 | return this.http.get(this.url + userId, { headers: headers }) 43 | .map(data => data); 44 | } 45 | 46 | createUser(user: User): Observable> { 47 | let headers = new HttpHeaders(); 48 | headers = headers.set('Content-Type', 'application/json'); 49 | headers = headers.set('Authorization', sessionStorage.jwt); 50 | const payload = JSON.stringify(user); 51 | 52 | return this.http.post>(this.url, payload, { headers: headers, observe: 'response' }) 53 | .map(data => data); 54 | } 55 | 56 | updateUser(user: User): Observable> { 57 | let headers = new HttpHeaders(); 58 | headers = headers.set('Content-Type', 'application/json'); 59 | headers = headers.set('Authorization', sessionStorage.jwt); 60 | const payload = JSON.stringify(user); 61 | 62 | return this.http.put>(this.url + user.id, payload, { headers: headers, observe: 'response' }) 63 | .map(data => data); 64 | } 65 | 66 | deleteUser(userId: string): Observable> { 67 | let headers = new HttpHeaders(); 68 | headers = headers.set('Authorization', sessionStorage.jwt); 69 | 70 | return this.http.delete>(this.url + userId, { headers: headers }) 71 | .map(data => data); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /microservice-auth/src/main/java/net/wasdev/sample/microprofile/auth/AuthResource.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.sample.microprofile.auth; 12 | 13 | import com.ibm.websphere.security.jwt.Claims; 14 | import com.ibm.websphere.security.jwt.JwtBuilder; 15 | import javax.enterprise.context.RequestScoped; 16 | import javax.ws.rs.GET; 17 | import javax.ws.rs.Path; 18 | import javax.ws.rs.core.HttpHeaders; 19 | import javax.ws.rs.core.Response; 20 | import javax.ws.rs.core.Response.Status; 21 | 22 | /** 23 | * The auth resource is responsible for providing a JWT to the caller, which can be used to login 24 | * with the user service, or create a user with the user service. The JWT is a member of the "login" 25 | * group and therefore can only access resources which this group is permitted to. 26 | * 27 | *

In the future, the auth resource should be modified to contain all JWT creation. Currently, 28 | * the user service will issue a new JWT once the user has logged in, and the occasion service will 29 | * issue its own JWT when an occasion is ready to run. 30 | */ 31 | @Path("/auth") 32 | @RequestScoped 33 | public class AuthResource { 34 | 35 | /** 36 | * Make a JWT that can be used only to login or create a user. The JWT will expire in a short 37 | * amount of time, and the group should only allow a login. 38 | */ 39 | @GET 40 | public Response generateJwtLogin() { 41 | // Build a JWT that the caller can use to create a new user or login. 42 | // The builder ID is specified in server.xml. We build this first 43 | // because we don't want to add the user if we can't build the response. 44 | String jwtTokenString = null; 45 | try { 46 | jwtTokenString = 47 | JwtBuilder.create("jwtAuthLoginBuilder") 48 | .claim(Claims.SUBJECT, "unauthenticated") 49 | .claim("upn", "unauthenticated") /* MP-JWT defined subject claim */ 50 | .claim( 51 | "groups", 52 | "login") /* MP-JWT defined group, seems Liberty makes an array from a comma separated list */ 53 | .buildJwt() 54 | .compact(); 55 | } catch (Throwable t) { 56 | return Response.status(Status.INTERNAL_SERVER_ERROR) 57 | .entity("Erorr building authorization token") 58 | .build(); 59 | } 60 | 61 | return Response.ok() 62 | .header(HttpHeaders.AUTHORIZATION, "Bearer " + jwtTokenString) 63 | .header("Access-Control-Expose-Headers", HttpHeaders.AUTHORIZATION) 64 | .build(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /microservice-notification_v1_1/src/main/java/net/wasdev/sample/microprofile/notification/extended/NotificationRetryBean.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.sample.microprofile.notification.extended; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.logging.Level; 16 | import java.util.logging.Logger; 17 | import javax.enterprise.context.ApplicationScoped; 18 | import org.eclipse.microprofile.faulttolerance.Fallback; 19 | import org.eclipse.microprofile.faulttolerance.Retry; 20 | import twitter4j.Twitter; 21 | 22 | @ApplicationScoped 23 | public class NotificationRetryBean { 24 | 25 | /** 26 | * Retry twice in the event of failure, after which the fallback handler will be driven to write 27 | * the message to a fallback log. 28 | */ 29 | @Retry(maxRetries = 2) 30 | @Fallback(NotificationFallbackHandler.class) 31 | public String tweet( 32 | String message, Twitter twitter, Logger fbLogger, String handle, Logger logger) 33 | throws Exception { 34 | try { 35 | // Tweet the occasion (AcmeGifts Twitter account). If the message is 36 | // longer that 140 chars, the message is split. 37 | // For example: abcdef: "abc ..." "... def". 38 | List msgList = preProcessMessage(message); 39 | for (String msg : msgList) { 40 | twitter.updateStatus(msg); 41 | } 42 | 43 | // Send a direct message to the occasion recipient. 44 | twitter.sendDirectMessage(handle, message); 45 | } catch (Exception e) { 46 | logger.log(Level.WARNING, "Tweet error", e); 47 | throw e; 48 | } 49 | 50 | return null; 51 | } 52 | 53 | /** 54 | * Returns a list of strings that are less than or equal to 140 chars in length. 55 | * Partial/continuing strings are suffixed/prefixed with "... " respectively. 56 | * 57 | * @param message The message to process. 58 | * @return The list processed strings. 59 | */ 60 | public List preProcessMessage(String message) { 61 | List messages = new ArrayList(); 62 | boolean split = true; 63 | while (split) { 64 | if (message.length() <= 140) { 65 | messages.add(message); 66 | split = false; 67 | } 68 | if (message.length() > 140) { 69 | int i = message.lastIndexOf(" ", 132); 70 | String partial = message.substring(0, i) + " ..."; 71 | messages.add(partial); 72 | message = "... " + message.substring(i + 1, message.length()); 73 | } 74 | } 75 | 76 | return messages; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /front-end-ui/src/app/group/services/group.service.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import 'rxjs/add/operator/map'; 12 | import { Group } from '../group'; 13 | import { Groups } from '../groups'; 14 | import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; 15 | import { Injectable } from '@angular/core'; 16 | import { Observable } from 'rxjs/Rx'; 17 | 18 | /** 19 | * Perform operations with the group backend microservice. 20 | */ 21 | @Injectable() 22 | export class GroupService { 23 | private groups: Group[]; 24 | 25 | // Maven fills in these variables from the pom.xml 26 | private url = '${group.service.url}'; 27 | 28 | constructor(private http: HttpClient) { 29 | this.url = this.url + ((this.url.indexOf('/', this.url.length - 1) === -1) ? '/': '') ; 30 | 31 | if (sessionStorage.jwt == null) { 32 | console.log('JSON Web Token is not available. Login before you continue.'); 33 | } 34 | } 35 | 36 | getGroups(userId: string): Observable { 37 | let headers = new HttpHeaders(); 38 | headers = headers.set('Authorization', sessionStorage.jwt); 39 | 40 | return this.http.get(this.url + '?userId=' + userId, { headers: headers }) 41 | .map(data => data) 42 | } 43 | 44 | getGroup(groupId: string): Observable { 45 | let headers = new HttpHeaders(); 46 | headers = headers.set('Authorization', sessionStorage.jwt); 47 | 48 | return this.http.get(this.url + groupId, { headers: headers }) 49 | .map(data => data) 50 | } 51 | 52 | createGroup(payload: string): Observable> { 53 | let headers = new HttpHeaders(); 54 | headers = headers.set('Content-Type', 'application/json'); 55 | headers = headers.set('Authorization', sessionStorage.jwt); 56 | 57 | return this.http.post>(this.url, payload, { headers: headers }) 58 | .map(data => data); 59 | } 60 | 61 | updateGroup(groupId: string, payload: string): Observable> { 62 | let headers = new HttpHeaders(); 63 | headers = headers.set('Content-Type', 'application/json'); 64 | headers = headers.set('Authorization', sessionStorage.jwt); 65 | 66 | return this.http.put>(this.url + groupId, payload, { headers: headers }) 67 | .map(data => data); 68 | } 69 | 70 | deleteGroup(groupId: string): Observable> { 71 | let headers = new HttpHeaders(); 72 | headers = headers.set('Authorization', sessionStorage.jwt); 73 | 74 | return this.http.delete>(this.url + groupId, { headers: headers }) 75 | .map(data => data); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /front-end-ui/build.gradle: -------------------------------------------------------------------------------- 1 | import org.ysb33r.gradle.nodejs.tasks.NpmTask 2 | 3 | apply plugin: 'org.ysb33r.nodejs.npm' 4 | 5 | description = 'Microservice :: Frontend UI' 6 | 7 | dependencies { 8 | providedCompile project(':shared-keystore') 9 | } 10 | 11 | buildscript { 12 | repositories { 13 | mavenCentral() 14 | maven { 15 | url "https://plugins.gradle.org/m2/" 16 | } 17 | } 18 | dependencies { 19 | classpath "gradle.plugin.org.ysb33r.gradle:nodejs-gradle-plugin:0.1" 20 | classpath "net.wasdev.wlp.gradle.plugins:liberty-gradle-plugin:2.1" 21 | } 22 | } 23 | 24 | ext { 25 | warfileName = 'UIService' 26 | wlpServerName = 'UIServer' 27 | } 28 | 29 | war { 30 | archiveName = "${warfileName}.war" 31 | } 32 | 33 | nodejs { 34 | executable version : '10.13.0' 35 | } 36 | 37 | npm { 38 | homeDirectory "$projectDir/npm_build" 39 | } 40 | 41 | task npmInstall (type: NpmTask) { 42 | description = 'Run npm install from Gradle.' 43 | command 'install' 44 | outputs.dir("$projectDir/npm_build/node_modules") 45 | } 46 | 47 | task cpySrc (type: Copy) { 48 | from 'src' 49 | into 'npm_build/src' 50 | outputs.dir("npm_build/src") 51 | } 52 | 53 | task npmBuild(type: NpmTask) { 54 | description = 'Run npm run build from Gradle.' 55 | command 'run' 56 | cmdArgs 'build' 57 | dependsOn 'cpySrc', 'npmInstall' 58 | outputs.dir("$projectDir/src/main/webapp") 59 | } 60 | 61 | task npmLint (type: NpmTask) { 62 | description = 'Run npm run lint from Gradle.' 63 | command 'run' 64 | cmdArgs 'lint' 65 | dependsOn 'npmBuild' 66 | // run onlyIf npmBuild is not UP-TO-DATE 67 | outputs.dir("$projectDir/src/main/webapp") 68 | } 69 | 70 | liberty { 71 | server { 72 | name = wlpServerName 73 | apps = [war] 74 | configFile = new File("$projectDir/liberty/config/server.xml") 75 | bootstrapProperties = 76 | ['server.http.port':frontendHttpPort, 'server.https.port':frontendHttpsPort, 'application.name':war.archiveName] 77 | looseApplication = false 78 | } 79 | } 80 | 81 | task copyKeystore (type: Copy) { 82 | configurations.keystore.each { 83 | from(zipTree(it)) { 84 | include "keystore.jceks" 85 | } 86 | } 87 | into "$buildDir/wlp/usr/servers/${wlpServerName}/resources/security" 88 | outputs.file("$buildDir/wlp/usr/servers/${wlpServerName}/resources/security/keystore.jceks") 89 | } 90 | 91 | task url { 92 | doLast { println frontendURL + '/login'} 93 | } 94 | 95 | gradle.taskGraph.whenReady { graph -> 96 | if (graph.hasTask(":front-end-ui:libertyStart")) { 97 | libertyStart.doLast { 98 | println ("Application should be running on ${frontendURL}") 99 | } 100 | } 101 | } 102 | 103 | // tie node into build 104 | build.dependsOn 'npmLint' 105 | 106 | // create servers during build 107 | build.finalizedBy 'libertyCreate' 108 | 109 | // make sure webapp is built 110 | libertyStart.dependsOn 'npmLint' 111 | 112 | clean.dependsOn 'libertyStop' 113 | copyKeystore.dependsOn ':shared-keystore:assemble', 'libertyCreate' 114 | -------------------------------------------------------------------------------- /front-end-ui/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | import { BrowserModule } from '@angular/platform-browser'; 12 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 13 | import { FormsModule } from '@angular/forms'; 14 | import { HttpClientModule } from '@angular/common/http'; 15 | import { NgModule } from '@angular/core'; 16 | import { MatButtonModule } from '@angular/material/button'; 17 | import { MatMenuModule } from '@angular/material/menu'; 18 | import { MatIconModule } from '@angular/material/icon'; 19 | import { AppComponent } from './app.component'; 20 | import { GroupAddMemberComponent } from './group/group-add-member.component'; 21 | import { GroupComponent } from './group/group.component'; 22 | import { GroupCreateComponent } from './group/group-create.component'; 23 | import { GroupService } from './group/services/group.service'; 24 | import { GroupsComponent } from './group/groups.component'; 25 | import { HeaderComponent } from './header/header.component'; 26 | import { LoginComponent } from './login/login.component'; 27 | import { LogoutComponent } from './logout/logout.component'; 28 | import { OccasionCreationComponent } from './occasion/occasion-create.component'; 29 | import { OccasionEditComponent } from './occasion/occasion-edit.component'; 30 | import { OccasionService } from './occasion/services/occasion.service'; 31 | import { ProfileEditComponent } from './signup/profile-edit.component'; 32 | import { ProfileCreateComponent } from './signup/profile-create.component'; 33 | import { TwitterLoginComponent } from './login/twitter.login.component'; 34 | import { TwitterVerifyComponent } from './login/twitter.verify.component'; 35 | import { UserService } from './user/services/user.service'; 36 | import { routing } from './app-routing.module'; 37 | 38 | @NgModule({ 39 | declarations: [ 40 | AppComponent, 41 | GroupAddMemberComponent, 42 | GroupComponent, 43 | GroupCreateComponent, 44 | GroupsComponent, 45 | HeaderComponent, 46 | LoginComponent, 47 | LogoutComponent, 48 | OccasionCreationComponent, 49 | OccasionEditComponent, 50 | ProfileCreateComponent, 51 | ProfileEditComponent, 52 | TwitterLoginComponent, 53 | TwitterVerifyComponent 54 | ], 55 | imports: [ 56 | BrowserModule, 57 | BrowserAnimationsModule, 58 | FormsModule, 59 | HttpClientModule, 60 | MatButtonModule, 61 | MatIconModule, 62 | MatMenuModule, 63 | routing 64 | ], 65 | providers: [ 66 | GroupService, 67 | OccasionService, 68 | UserService], 69 | bootstrap: [AppComponent] 70 | }) 71 | 72 | export class AppModule {} 73 | -------------------------------------------------------------------------------- /front-end-ui/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | /** 12 | * This file includes polyfills needed by Angular and is loaded before the app. 13 | * You can add your own extra polyfills to this file. 14 | * 15 | * This file is divided into 2 sections: 16 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 17 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 18 | * file. 19 | * 20 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 21 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 22 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 23 | * 24 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 25 | */ 26 | 27 | /*************************************************************************************************** 28 | * BROWSER POLYFILLS 29 | */ 30 | 31 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 32 | // import 'core-js/es6/symbol'; 33 | // import 'core-js/es6/object'; 34 | // import 'core-js/es6/function'; 35 | // import 'core-js/es6/parse-int'; 36 | // import 'core-js/es6/parse-float'; 37 | // import 'core-js/es6/number'; 38 | // import 'core-js/es6/math'; 39 | // import 'core-js/es6/string'; 40 | // import 'core-js/es6/date'; 41 | // import 'core-js/es6/array'; 42 | // import 'core-js/es6/regexp'; 43 | // import 'core-js/es6/map'; 44 | // import 'core-js/es6/weak-map'; 45 | // import 'core-js/es6/set'; 46 | 47 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 48 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 49 | 50 | /** Evergreen browsers require these. **/ 51 | import 'core-js/es6/reflect'; 52 | import 'core-js/es7/reflect'; 53 | 54 | 55 | /** 56 | * Required to support Web Animations `@angular/animation`. 57 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation 58 | **/ 59 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 60 | 61 | 62 | 63 | /*************************************************************************************************** 64 | * Zone JS is required by Angular itself. 65 | */ 66 | import 'zone.js/dist/zone'; // Included with Angular CLI. 67 | 68 | 69 | 70 | /*************************************************************************************************** 71 | * APPLICATION IMPORTS 72 | */ 73 | 74 | /** 75 | * Date, currency, decimal and percent pipes. 76 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 77 | */ 78 | // import 'intl'; // Run `npm install --save intl`. 79 | /** 80 | * Need to import at least one locale-data with intl. 81 | */ 82 | // import 'intl/locale-data/jsonp/en'; 83 | -------------------------------------------------------------------------------- /microservice-user/src/main/java/net/wasdev/sample/microprofile/user/PasswordUtility.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package net.wasdev.sample.microprofile.user; 12 | 13 | import java.security.MessageDigest; 14 | import java.security.NoSuchAlgorithmException; 15 | import java.security.SecureRandom; 16 | import java.util.Base64; 17 | 18 | /** 19 | * This utility class generates password salt values, and hashes the password for storing in the 20 | * database. 21 | */ 22 | public class PasswordUtility { 23 | /** Source of entropy for things that need random numbers. */ 24 | private static final SecureRandom saltGenerator = new SecureRandom(); 25 | 26 | /** 27 | * Salt value prepended to password bytes to make it harder for someone to look up passwords 28 | * stored in the database using a 'rainbow table'. Each password gets a unique salt value. 29 | */ 30 | private final byte[] salt; 31 | 32 | /** The hashed password that is stored in the database. */ 33 | private final String hashedPassword; 34 | 35 | /** 36 | * Take a cleartext password and generate a salt and the hashed password that we'll put in the 37 | * database. 38 | * 39 | * @throws NoSuchAlgorithmException Thrown if the SHA-256 algorithm is not supported. 40 | */ 41 | PasswordUtility(String userPassword) throws NoSuchAlgorithmException { 42 | // Hash the password for storage in the database. Prepend a random salt to make 43 | // the resulting hash less likely to be useful for someone trying to use the 44 | // password on another site. 45 | salt = new byte[16]; 46 | saltGenerator.nextBytes(salt); 47 | 48 | // Get a new message digest used to hash the password, and prepend it with the 49 | // salt. 50 | MessageDigest md = MessageDigest.getInstance("SHA-256"); 51 | md.update(salt); 52 | 53 | // Add the password to the digest and then Base64 encode the result. 54 | hashedPassword = Base64.getEncoder().encodeToString(md.digest(userPassword.getBytes())); 55 | } 56 | 57 | /** 58 | * Create a new hashed password from an existing salt. 59 | * 60 | * @throws NoSuchAlgorithmException 61 | * @throws Base64Exception 62 | */ 63 | PasswordUtility(String userPassword, String saltString) throws NoSuchAlgorithmException { 64 | salt = Base64.getDecoder().decode(saltString); 65 | 66 | MessageDigest md = MessageDigest.getInstance("SHA-256"); 67 | md.update(salt); 68 | hashedPassword = Base64.getEncoder().encodeToString(md.digest(userPassword.getBytes())); 69 | } 70 | 71 | /** Get the salt as a string, for storage in a document. */ 72 | public String getSalt() { 73 | return Base64.getEncoder().encodeToString(salt); 74 | } 75 | 76 | /** Get the hashed password as a string, for storage in a document. */ 77 | public String getHashedPassword() { 78 | return hashedPassword; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /front-end-ui/src/app/login/login.component.html: -------------------------------------------------------------------------------- 1 | 10 |

11 |
12 |
13 | 14 | 15 | {{eventMessage}} 16 |
17 |
18 | {{firefoxMessage}} 19 |
20 |
21 |
22 |

23 |

Gifts, as a Service

24 |

WELCOME TO ACME GIFTS

25 |
26 |
27 |
28 |
29 | 32 |
Username 33 | is required
34 |
35 |

36 |
37 | 40 |
Password 41 | is required
42 |
43 |


44 |
45 |
46 | 49 |
50 | 53 |
54 |
55 |



56 | 60 |
61 |




62 | 69 |
-------------------------------------------------------------------------------- /microservice-auth/src/test/java/test/AuthResourceTest.java: -------------------------------------------------------------------------------- 1 | // ****************************************************************************** 2 | // Copyright (c) 2017 IBM Corporation and others. 3 | // All rights reserved. This program and the accompanying materials 4 | // are made available under the terms of the Eclipse Public License v1.0 5 | // which accompanies this distribution, and is available at 6 | // http://www.eclipse.org/legal/epl-v10.html 7 | // 8 | // Contributors: 9 | // IBM Corporation - initial API and implementation 10 | // ****************************************************************************** 11 | package test; 12 | 13 | import static org.junit.Assert.assertEquals; 14 | 15 | import java.io.InputStream; 16 | import java.security.KeyStore; 17 | import java.security.PublicKey; 18 | import javax.ws.rs.client.Client; 19 | import javax.ws.rs.client.ClientBuilder; 20 | import javax.ws.rs.client.Entity; 21 | import javax.ws.rs.client.Invocation.Builder; 22 | import javax.ws.rs.client.WebTarget; 23 | import javax.ws.rs.core.HttpHeaders; 24 | import javax.ws.rs.core.MediaType; 25 | import javax.ws.rs.core.Response; 26 | import javax.ws.rs.core.Response.Status; 27 | import org.junit.Test; 28 | 29 | public class AuthResourceTest { 30 | 31 | /** 32 | * This is the URL that the Liberty auth server is listening on. We'll use it to call JAX-RS 33 | * services in our tests. 34 | */ 35 | private static final String authServiceURL = System.getProperty("liberty.test.auth.service.url"); 36 | 37 | /** 38 | * Tests the JWT we get back from the auth service is valid. We test the JWT to make sure it was 39 | * signed correctly. 40 | * 41 | *

We do not validate other things, like the issued at time, expired time, etc. 42 | * 43 | *

The test case has access to the keystore that the server should have used to sign the JWT. 44 | */ 45 | @Test 46 | public void testLoginJwtValidity() throws Exception { 47 | // Get the JWT from the auth service. 48 | Response response = processRequest(authServiceURL, "GET", null, null); 49 | assertEquals( 50 | "HTTP response code should have been " + Status.OK.getStatusCode() + ".", 51 | Status.OK.getStatusCode(), 52 | response.getStatus()); 53 | String authHeader = response.getHeaderString("Authorization"); 54 | 55 | // Open the keystore that the server should have used to sign the JWT. 56 | KeyStore ks = KeyStore.getInstance("JCEKS"); 57 | InputStream ksStream = this.getClass().getResourceAsStream("/keystore.jceks"); 58 | char[] password = new String("secret").toCharArray(); 59 | ks.load(ksStream, password); 60 | java.security.cert.Certificate cert = ks.getCertificate("default"); 61 | PublicKey publicKey = cert.getPublicKey(); 62 | 63 | // Make sure it's valid. Use the server's public key to check. 64 | new JWTVerifier().validateJWT(authHeader, publicKey); 65 | } 66 | 67 | public static Response processRequest( 68 | String url, String method, String payload, String authHeader) { 69 | Client client = ClientBuilder.newClient(); 70 | WebTarget target = client.target(url); 71 | Builder builder = target.request(); 72 | if (payload != null) { 73 | builder.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); 74 | } 75 | if (authHeader != null) { 76 | builder.header(HttpHeaders.AUTHORIZATION, authHeader); 77 | } 78 | return (payload != null) 79 | ? builder.build(method, Entity.json(payload)).invoke() 80 | : builder.build(method).invoke(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /front-end-ui/src/assets/images/modal--img_right.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Group 6 Copy 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /microservice-notification_v1_1/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | description = 'Microservice :: Notification v1_1' 3 | 4 | dependencies { 5 | compile group: 'org.twitter4j', name: 'twitter4j-core', version:'4.0.6' 6 | providedCompile group: 'org.eclipse.microprofile.fault.tolerance', name: 'microprofile-fault-tolerance-api', version:'1.0-RC1' 7 | } 8 | 9 | buildscript { 10 | repositories { 11 | mavenCentral() 12 | } 13 | dependencies { 14 | classpath "net.wasdev.wlp.gradle.plugins:liberty-gradle-plugin:2.1" 15 | } 16 | } 17 | 18 | ext { 19 | warfileName = 'notificiationMicroservice' 20 | wlpServerName = 'notificationServer' 21 | 22 | // Optional Microservice Configuration 23 | notification_v1_1_logfile = new File("$buildDir/logs/notifications_1_1.log") 24 | notification_v1_1_fallback_logfile = new File("$buildDir/logs/notifications_1_1_fallback.log") 25 | } 26 | 27 | war { 28 | archiveName = "${warfileName}.war" 29 | } 30 | 31 | liberty { 32 | server { 33 | name = wlpServerName 34 | bootstrapProperties = 35 | ['log.file':notification_v1_1_logfile, 'fallback.log.file':notification_v1_1_fallback_logfile, 36 | 'twitter.consumer.key':twitterAppConsumerKey, 'twitter.consumer.secret':twitterAppConsumerSecret, 37 | 'twitter.access.token':twitterUserAccessToken, 'twitter.access.secret':twitterUserAccessSecret, 38 | 'http.port':notification_v1_1_HttpPort, 'https.port':notification_v1_1_HttpsPort, 'app.name':war.archiveName, 'jwt.issuer':jwtIssuer] 39 | } 40 | } 41 | 42 | test { 43 | group 'Verification' 44 | reports.html.destination = file("$buildDir/reports/unit") 45 | reports.junitXml.destination = file("$buildDir/test-reports/unit") 46 | exclude '**/test/**' 47 | 48 | // run every time when called 49 | outputs.upToDateWhen { false } 50 | } 51 | 52 | task integrationTest(type: Test) { 53 | group 'Verification' 54 | description 'Runs the integration tests.' 55 | reports.html.destination = file("$buildDir/reports/it") 56 | reports.junitXml.destination = file("$buildDir/test-reports/it") 57 | include '**/test/**' 58 | 59 | systemProperties = ['log.file': notification_v1_1_logfile, 60 | 'fallback.log.file': notification_v1_1_fallback_logfile, 61 | 'twitter.consumer.key': twitterAppConsumerKey, 62 | 'twitter.consumer.secret': twitterAppConsumerSecret, 63 | 'twitter.access.token': twitterUserAccessToken, 64 | 'twitter.access.secret': twitterUserAccessSecret, 65 | 'liberty.test.hostname': notification_v1_1_Hostname, 66 | 'liberty.test.port': notification_v1_1_HttpPort, 67 | 'jwt.issuer': jwtIssuer, 68 | 'javax.net.ssl.keyStorePassword': "secret"] 69 | 70 | // run every time when called 71 | outputs.upToDateWhen { false } 72 | } 73 | 74 | task copyKeystore (type: Copy) { 75 | configurations.keystore.each { 76 | from(zipTree(it)) { 77 | include "keystore.jceks" 78 | } 79 | } 80 | into "$buildDir/wlp/usr/servers/${wlpServerName}/resources/security" 81 | outputs.file("$buildDir/wlp/usr/servers/${wlpServerName}/resources/security/keystore.jceks") 82 | } 83 | 84 | task testKeystore(type: Copy) { 85 | dependsOn 'copyKeystore' 86 | from "$buildDir/wlp/usr/servers/${wlpServerName}/resources/security" 87 | into "$buildDir/resources/test/truststore/" 88 | outputs.file("$buildDir/resources/test/truststore/keystore.jceks") 89 | } 90 | 91 | check.dependsOn 'integrationTest' 92 | integrationTest.dependsOn 'libertyStart', 'testKeystore' 93 | integrationTest.finalizedBy 'libertyStop' 94 | libertyStart.dependsOn 'copyKeystore' 95 | clean.dependsOn 'libertyStop' 96 | copyKeystore.dependsOn ':shared-keystore:assemble', 'libertyCreate' 97 | --------------------------------------------------------------------------------