From 10027f3cd15afd2c8ef341e5cd92de911e07965e Mon Sep 17 00:00:00 2001 From: Instrumental Date: Mon, 26 Mar 2018 14:07:37 -0700 Subject: [PATCH] AT&T 2.0.19 Code drop, stage 4 Issue-ID: AAF-197 Change-Id: Ibe14fed4b583966dca5559710bced7bec868eae9 Signed-off-by: Instrumental --- auth/auth-batch/pom.xml | 6 - auth/pom.xml | 2 +- authz-certman/pom.xml | 247 ------- authz-certman/src/main/config/certman.props | 25 - authz-certman/src/main/config/log4j.properties | 78 --- .../src/main/config/lrm-authz-certman.xml | 82 --- .../org/onap/aaf/authz/cm/api/API_Artifact.java | 130 ---- .../java/org/onap/aaf/authz/cm/api/API_Cert.java | 100 --- .../main/java/org/onap/aaf/authz/cm/ca/AppCA.java | 356 ---------- .../src/main/java/org/onap/aaf/authz/cm/ca/CA.java | 84 --- .../main/java/org/onap/aaf/authz/cm/ca/DevlCA.java | 226 ------- .../java/org/onap/aaf/authz/cm/cert/BCFactory.java | 168 ----- .../java/org/onap/aaf/authz/cm/cert/CSRMeta.java | 329 ---------- .../org/onap/aaf/authz/cm/cert/StandardFields.java | 29 - .../java/org/onap/aaf/authz/cm/data/CertDrop.java | 27 - .../java/org/onap/aaf/authz/cm/data/CertRenew.java | 27 - .../java/org/onap/aaf/authz/cm/data/CertReq.java | 51 -- .../java/org/onap/aaf/authz/cm/data/CertResp.java | 66 -- .../java/org/onap/aaf/authz/cm/facade/Facade.java | 161 ----- .../org/onap/aaf/authz/cm/facade/Facade1_0.java | 47 -- .../onap/aaf/authz/cm/facade/FacadeFactory.java | 43 -- .../org/onap/aaf/authz/cm/facade/FacadeImpl.java | 493 -------------- .../java/org/onap/aaf/authz/cm/mapper/Mapper.java | 52 -- .../org/onap/aaf/authz/cm/mapper/Mapper1_0.java | 246 ------- .../org/onap/aaf/authz/cm/service/CMService.java | 515 --------------- .../org/onap/aaf/authz/cm/service/CertManAPI.java | 285 -------- .../java/org/onap/aaf/authz/cm/service/Code.java | 45 -- .../onap/aaf/authz/cm/validation/Validator.java | 165 ----- .../org/onap/aaf/authz/cm/api/JU_API_Artifact.java | 108 --- .../org/onap/aaf/authz/cm/api/JU_API_Cert.java | 108 --- .../java/org/onap/aaf/authz/cm/ca/JU_AppCA.java | 287 -------- .../java/org/onap/aaf/authz/cm/ca/JU_DevlCA.java | 287 -------- .../org/onap/aaf/authz/cm/cert/JU_BCFactory.java | 132 ---- .../org/onap/aaf/authz/cm/cert/JU_CSRMeta.java | 96 --- .../org/onap/aaf/authz/cm/data/JU_CertReq.java | 88 --- .../onap/aaf/authz/cm/facade/JU_FacadeImpl.java | 195 ------ authz-cmd/aafcli.sh | 13 - authz-cmd/etc/log4j.properties | 54 -- authz-cmd/pom.xml | 254 -------- authz-cmd/src/main/assemble/authz-cmd.xml | 47 -- authz-cmd/src/main/assemble/swm.xml | 34 - authz-cmd/src/main/config/log4j.properties | 54 -- authz-cmd/src/main/config/logging.props | 38 -- .../src/main/java/org/onap/aaf/cmd/AAFcli.java | 722 --------------------- .../src/main/java/org/onap/aaf/cmd/BaseCmd.java | 69 -- .../src/main/java/org/onap/aaf/cmd/BasicAuth.java | 56 -- authz-cmd/src/main/java/org/onap/aaf/cmd/Cmd.java | 499 -------------- authz-cmd/src/main/java/org/onap/aaf/cmd/Help.java | 112 ---- .../java/org/onap/aaf/cmd/MessageException.java | 46 -- .../src/main/java/org/onap/aaf/cmd/Param.java | 38 -- .../src/main/java/org/onap/aaf/cmd/Version.java | 45 -- .../src/main/java/org/onap/aaf/cmd/mgmt/Cache.java | 34 - .../src/main/java/org/onap/aaf/cmd/mgmt/Clear.java | 86 --- .../src/main/java/org/onap/aaf/cmd/mgmt/Deny.java | 102 --- .../src/main/java/org/onap/aaf/cmd/mgmt/Log.java | 111 ---- .../src/main/java/org/onap/aaf/cmd/mgmt/Mgmt.java | 38 -- .../main/java/org/onap/aaf/cmd/mgmt/SessClear.java | 84 --- .../main/java/org/onap/aaf/cmd/mgmt/Session.java | 34 - .../src/main/java/org/onap/aaf/cmd/ns/Admin.java | 106 --- .../src/main/java/org/onap/aaf/cmd/ns/Attrib.java | 115 ---- .../src/main/java/org/onap/aaf/cmd/ns/Create.java | 128 ---- .../src/main/java/org/onap/aaf/cmd/ns/Delete.java | 90 --- .../main/java/org/onap/aaf/cmd/ns/Describe.java | 96 --- .../src/main/java/org/onap/aaf/cmd/ns/List.java | 170 ----- .../java/org/onap/aaf/cmd/ns/ListActivity.java | 81 --- .../org/onap/aaf/cmd/ns/ListAdminResponsible.java | 79 --- .../main/java/org/onap/aaf/cmd/ns/ListByName.java | 105 --- .../java/org/onap/aaf/cmd/ns/ListChildren.java | 82 --- .../org/onap/aaf/cmd/ns/ListNsKeysByAttrib.java | 89 --- .../main/java/org/onap/aaf/cmd/ns/ListUsers.java | 53 -- .../java/org/onap/aaf/cmd/ns/ListUsersInRole.java | 129 ---- .../org/onap/aaf/cmd/ns/ListUsersWithPerm.java | 128 ---- .../src/main/java/org/onap/aaf/cmd/ns/NS.java | 47 -- .../main/java/org/onap/aaf/cmd/ns/Responsible.java | 111 ---- .../main/java/org/onap/aaf/cmd/perm/Create.java | 165 ----- .../main/java/org/onap/aaf/cmd/perm/Delete.java | 90 --- .../main/java/org/onap/aaf/cmd/perm/Describe.java | 102 --- .../src/main/java/org/onap/aaf/cmd/perm/Grant.java | 151 ----- .../src/main/java/org/onap/aaf/cmd/perm/List.java | 129 ---- .../java/org/onap/aaf/cmd/perm/ListActivity.java | 77 --- .../main/java/org/onap/aaf/cmd/perm/ListByNS.java | 72 -- .../java/org/onap/aaf/cmd/perm/ListByName.java | 70 -- .../java/org/onap/aaf/cmd/perm/ListByRole.java | 73 --- .../java/org/onap/aaf/cmd/perm/ListByUser.java | 76 --- .../src/main/java/org/onap/aaf/cmd/perm/Perm.java | 44 -- .../main/java/org/onap/aaf/cmd/perm/Rename.java | 103 --- .../java/org/onap/aaf/cmd/role/CreateDelete.java | 132 ---- .../main/java/org/onap/aaf/cmd/role/Describe.java | 96 --- .../src/main/java/org/onap/aaf/cmd/role/List.java | 169 ----- .../java/org/onap/aaf/cmd/role/ListActivity.java | 76 --- .../main/java/org/onap/aaf/cmd/role/ListByNS.java | 73 --- .../java/org/onap/aaf/cmd/role/ListByNameOnly.java | 73 --- .../java/org/onap/aaf/cmd/role/ListByPerm.java | 79 --- .../java/org/onap/aaf/cmd/role/ListByRole.java | 70 -- .../java/org/onap/aaf/cmd/role/ListByUser.java | 146 ----- .../src/main/java/org/onap/aaf/cmd/role/Role.java | 41 -- .../src/main/java/org/onap/aaf/cmd/role/User.java | 171 ----- .../src/main/java/org/onap/aaf/cmd/user/Cred.java | 153 ----- .../src/main/java/org/onap/aaf/cmd/user/Delg.java | 136 ---- .../src/main/java/org/onap/aaf/cmd/user/List.java | 122 ---- .../java/org/onap/aaf/cmd/user/ListActivity.java | 81 --- .../java/org/onap/aaf/cmd/user/ListApprovals.java | 104 --- .../java/org/onap/aaf/cmd/user/ListDelegates.java | 95 --- .../java/org/onap/aaf/cmd/user/ListForCreds.java | 99 --- .../org/onap/aaf/cmd/user/ListForPermission.java | 104 --- .../java/org/onap/aaf/cmd/user/ListForRoles.java | 93 --- .../src/main/java/org/onap/aaf/cmd/user/Role.java | 158 ----- .../src/main/java/org/onap/aaf/cmd/user/User.java | 38 -- authz-cmd/src/main/scripts/aaflogin | 199 ------ .../src/test/java/org/onap/aaf/cmd/JU_AAFCli.java | 193 ------ .../src/test/java/org/onap/aaf/cmd/JU_BaseCmd.java | 235 ------- .../test/java/org/onap/aaf/cmd/JU_BasicAuth.java | 49 -- .../src/test/java/org/onap/aaf/cmd/JU_Help.java | 92 --- .../src/test/java/org/onap/aaf/cmd/JU_Version.java | 59 -- .../test/java/org/onap/aaf/cmd/mgmt/JU_Clear.java | 63 -- .../test/java/org/onap/aaf/cmd/mgmt/JU_Log.java | 63 -- .../java/org/onap/aaf/cmd/mgmt/JU_SessClear.java | 63 -- .../test/java/org/onap/aaf/cmd/ns/JU_Admin.java | 65 -- .../test/java/org/onap/aaf/cmd/ns/JU_Attrib.java | 65 -- .../test/java/org/onap/aaf/cmd/ns/JU_Create.java | 65 -- .../test/java/org/onap/aaf/cmd/ns/JU_Delete.java | 69 -- .../test/java/org/onap/aaf/cmd/ns/JU_Describe.java | 73 --- .../java/org/onap/aaf/cmd/ns/JU_ListActivity.java | 70 -- .../onap/aaf/cmd/ns/JU_ListAdminResponsible.java | 70 -- .../java/org/onap/aaf/cmd/ns/JU_ListByName.java | 70 -- .../java/org/onap/aaf/cmd/ns/JU_ListChildren.java | 70 -- .../org/onap/aaf/cmd/ns/JU_ListNsKeysByAttrib.java | 70 -- .../org/onap/aaf/cmd/ns/JU_ListUsersInRole.java | 67 -- .../org/onap/aaf/cmd/ns/JU_ListUsersWithPerm.java | 67 -- .../java/org/onap/aaf/cmd/ns/JU_Responsible.java | 69 -- .../test/java/org/onap/aaf/cmd/perm/JU_Create.java | 69 -- .../test/java/org/onap/aaf/cmd/perm/JU_Delete.java | 69 -- .../java/org/onap/aaf/cmd/perm/JU_Describe.java | 69 -- .../test/java/org/onap/aaf/cmd/perm/JU_Grant.java | 69 -- .../org/onap/aaf/cmd/perm/JU_ListActivity.java | 71 -- .../java/org/onap/aaf/cmd/perm/JU_ListByNS.java | 71 -- .../java/org/onap/aaf/cmd/perm/JU_ListByName.java | 71 -- .../java/org/onap/aaf/cmd/perm/JU_ListByRole.java | 71 -- .../java/org/onap/aaf/cmd/perm/JU_ListByUser.java | 71 -- .../test/java/org/onap/aaf/cmd/perm/JU_Rename.java | 69 -- .../org/onap/aaf/cmd/role/JU_CreateDelete.java | 67 -- .../java/org/onap/aaf/cmd/role/JU_Describe.java | 67 -- .../org/onap/aaf/cmd/role/JU_ListActivity.java | 69 -- .../java/org/onap/aaf/cmd/role/JU_ListByNS.java | 69 -- .../org/onap/aaf/cmd/role/JU_ListByNameOnly.java | 69 -- .../java/org/onap/aaf/cmd/role/JU_ListByPerm.java | 69 -- .../java/org/onap/aaf/cmd/role/JU_ListByRole.java | 69 -- .../java/org/onap/aaf/cmd/role/JU_ListByUser.java | 69 -- .../test/java/org/onap/aaf/cmd/role/JU_User.java | 68 -- .../test/java/org/onap/aaf/cmd/user/JU_Cred.java | 125 ---- .../test/java/org/onap/aaf/cmd/user/JU_Delg.java | 81 --- .../org/onap/aaf/cmd/user/JU_ListActivity.java | 70 -- .../org/onap/aaf/cmd/user/JU_ListApprovals.java | 70 -- .../org/onap/aaf/cmd/user/JU_ListDelegates.java | 70 -- .../org/onap/aaf/cmd/user/JU_ListForCreds.java | 70 -- .../onap/aaf/cmd/user/JU_ListForPermission.java | 70 -- .../org/onap/aaf/cmd/user/JU_ListForRoles.java | 70 -- .../test/java/org/onap/aaf/cmd/user/JU_Role.java | 68 -- authz-core/pom.xml | 238 ------- .../java/org/onap/aaf/authz/common/Define.java | 50 -- .../main/java/org/onap/aaf/authz/env/AuthzEnv.java | 264 -------- .../java/org/onap/aaf/authz/env/AuthzTrans.java | 71 -- .../org/onap/aaf/authz/env/AuthzTransFilter.java | 165 ----- .../org/onap/aaf/authz/env/AuthzTransImpl.java | 198 ------ .../onap/aaf/authz/env/AuthzTransOnlyFilter.java | 89 --- .../java/org/onap/aaf/authz/env/NullTrans.java | 225 ------- .../java/org/onap/aaf/authz/layer/FacadeImpl.java | 38 -- .../main/java/org/onap/aaf/authz/layer/Result.java | 325 ---------- .../java/org/onap/aaf/authz/local/AbsData.java | 215 ------ .../java/org/onap/aaf/authz/local/DataFile.java | 185 ------ .../java/org/onap/aaf/authz/local/TextIndex.java | 253 -------- .../java/org/onap/aaf/authz/org/EmailWarnings.java | 34 - .../main/java/org/onap/aaf/authz/org/Executor.java | 35 - .../java/org/onap/aaf/authz/org/Organization.java | 490 -------------- .../onap/aaf/authz/org/OrganizationException.java | 53 -- .../onap/aaf/authz/org/OrganizationFactory.java | 148 ----- .../java/org/onap/aaf/authz/server/AbsServer.java | 150 ----- .../src/main/java/org/onap/aaf/cache/Cache.java | 195 ------ .../java/org/onap/aaf/cssa/rserv/Acceptor.java | 169 ----- .../org/onap/aaf/cssa/rserv/CachingFileAccess.java | 476 -------------- .../java/org/onap/aaf/cssa/rserv/CodeSetter.java | 53 -- .../main/java/org/onap/aaf/cssa/rserv/Content.java | 115 ---- .../java/org/onap/aaf/cssa/rserv/HttpCode.java | 111 ---- .../java/org/onap/aaf/cssa/rserv/HttpMethods.java | 30 - .../main/java/org/onap/aaf/cssa/rserv/Match.java | 211 ------ .../main/java/org/onap/aaf/cssa/rserv/Pair.java | 43 -- .../java/org/onap/aaf/cssa/rserv/RServlet.java | 155 ----- .../main/java/org/onap/aaf/cssa/rserv/Route.java | 142 ---- .../java/org/onap/aaf/cssa/rserv/RouteReport.java | 34 - .../main/java/org/onap/aaf/cssa/rserv/Routes.java | 90 --- .../java/org/onap/aaf/cssa/rserv/TransFilter.java | 136 ---- .../org/onap/aaf/cssa/rserv/TransOnlyFilter.java | 77 --- .../java/org/onap/aaf/cssa/rserv/TypedCode.java | 268 -------- .../main/java/org/onap/aaf/cssa/rserv/Version.java | 93 --- .../java/org/onap/aaf/cssa/rserv/doc/ApiDoc.java | 42 -- .../java/org/onap/aaf/authz/common/JU_Define.java | 64 -- .../java/org/onap/aaf/authz/env/JU_AuthzEnv.java | 70 -- .../onap/aaf/authz/env/JU_AuthzTransFilter.java | 83 --- .../org/onap/aaf/authz/env/JU_AuthzTransImpl.java | 75 --- .../aaf/authz/env/JU_AuthzTransOnlyFilter.java | 51 -- .../java/org/onap/aaf/authz/env/JU_NullTrans.java | 47 -- .../java/org/onap/aaf/authz/layer/JU_Result.java | 54 -- .../java/org/onap/aaf/authz/local/JU_DataFile.java | 67 -- .../org/onap/aaf/authz/local/JU_TextIndex.java | 52 -- .../aaf/authz/org/JU_OrganizationException.java | 49 -- .../onap/aaf/authz/org/JU_OrganizationFactory.java | 65 -- .../onap/aaf/cssa/rserv/JU_CachingFileAccess.java | 50 -- .../org/onap/aaf/cssa/rserv/JU_CodeSetter.java | 69 -- .../test/java/org/onap/aaf/cssa/rserv/JU_Pair.java | 46 -- .../java/org/onap/aaf/cssa/rserv/JU_Routes.java | 72 -- .../java/org/onap/aaf/cssa/rserv/JU_TypedCode.java | 53 -- .../java/org/onap/aaf/cssa/rserv/JU_Version.java | 58 -- .../onap/aaf/cssa/rserv/test/JU_BetterMatch.java | 166 ----- .../org/onap/aaf/cssa/rserv/test/JU_Content.java | 132 ---- authz-defOrg/pom.xml | 207 ------ .../java/org/onap/aaf/osaaf/defOrg/DefaultOrg.java | 596 ----------------- .../onap/aaf/osaaf/defOrg/DefaultOrgIdentity.java | 147 ----- .../onap/aaf/osaaf/defOrg/DefaultOrgWarnings.java | 64 -- .../java/org/onap/aaf/osaaf/defOrg/Identities.java | 144 ---- .../onap/aaf/osaaf/defOrd/test/JU_Identities.java | 111 ---- .../org/onap/aaf/osaaf/defOrg/JU_DefaultOrg.java | 138 ---- .../aaf/osaaf/defOrg/JU_DefaultOrgIdentity.java | 95 --- .../aaf/osaaf/defOrg/JU_DefaultOrgWarnings.java | 84 --- .../org/onap/aaf/osaaf/defOrg/JU_Identities.java | 111 ---- authz-defOrg/src/test/resources/test.txt | 0 cadi/aaf/pom.xml | 2 +- .../onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java | 573 ---------------- cadi/client/pom.xml | 2 +- cadi/core/pom.xml | 2 +- cadi/pom.xml | 4 +- pom.xml | 566 ++-------------- 231 files changed, 46 insertions(+), 26731 deletions(-) delete mode 100644 authz-certman/pom.xml delete mode 100644 authz-certman/src/main/config/certman.props delete mode 100644 authz-certman/src/main/config/log4j.properties delete mode 100644 authz-certman/src/main/config/lrm-authz-certman.xml delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/api/API_Artifact.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/api/API_Cert.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/AppCA.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/CA.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/DevlCA.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/BCFactory.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/CSRMeta.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/StandardFields.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertDrop.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertRenew.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertReq.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertResp.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/Facade.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/Facade1_0.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/FacadeFactory.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/FacadeImpl.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/mapper/Mapper.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/mapper/Mapper1_0.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/service/CMService.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/service/CertManAPI.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/service/Code.java delete mode 100644 authz-certman/src/main/java/org/onap/aaf/authz/cm/validation/Validator.java delete mode 100644 authz-certman/src/test/java/org/onap/aaf/authz/cm/api/JU_API_Artifact.java delete mode 100644 authz-certman/src/test/java/org/onap/aaf/authz/cm/api/JU_API_Cert.java delete mode 100644 authz-certman/src/test/java/org/onap/aaf/authz/cm/ca/JU_AppCA.java delete mode 100644 authz-certman/src/test/java/org/onap/aaf/authz/cm/ca/JU_DevlCA.java delete mode 100644 authz-certman/src/test/java/org/onap/aaf/authz/cm/cert/JU_BCFactory.java delete mode 100644 authz-certman/src/test/java/org/onap/aaf/authz/cm/cert/JU_CSRMeta.java delete mode 100644 authz-certman/src/test/java/org/onap/aaf/authz/cm/data/JU_CertReq.java delete mode 100644 authz-certman/src/test/java/org/onap/aaf/authz/cm/facade/JU_FacadeImpl.java delete mode 100644 authz-cmd/aafcli.sh delete mode 100644 authz-cmd/etc/log4j.properties delete mode 100644 authz-cmd/pom.xml delete mode 100644 authz-cmd/src/main/assemble/authz-cmd.xml delete mode 100644 authz-cmd/src/main/assemble/swm.xml delete mode 100644 authz-cmd/src/main/config/log4j.properties delete mode 100644 authz-cmd/src/main/config/logging.props delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/AAFcli.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/BaseCmd.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/BasicAuth.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/Cmd.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/Help.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/MessageException.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/Param.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/Version.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Cache.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Clear.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Deny.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Log.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Mgmt.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/SessClear.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Session.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Admin.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Attrib.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Create.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Delete.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Describe.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/List.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListActivity.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListAdminResponsible.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListByName.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListChildren.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListNsKeysByAttrib.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsers.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsersInRole.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsersWithPerm.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/NS.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Responsible.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Create.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Delete.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Describe.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Grant.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/perm/List.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListActivity.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByNS.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByName.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByRole.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByUser.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Perm.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Rename.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/role/CreateDelete.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/role/Describe.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/role/List.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListActivity.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByNS.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByNameOnly.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByPerm.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByRole.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByUser.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/role/Role.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/role/User.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/user/Cred.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/user/Delg.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/user/List.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListActivity.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListApprovals.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListDelegates.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForCreds.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForPermission.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForRoles.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/user/Role.java delete mode 100644 authz-cmd/src/main/java/org/onap/aaf/cmd/user/User.java delete mode 100644 authz-cmd/src/main/scripts/aaflogin delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/JU_AAFCli.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/JU_BaseCmd.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/JU_BasicAuth.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/JU_Help.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/JU_Version.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_Clear.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_Log.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_SessClear.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Admin.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Attrib.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Create.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Delete.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Describe.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListActivity.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListAdminResponsible.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListByName.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListChildren.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListNsKeysByAttrib.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListUsersInRole.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListUsersWithPerm.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Responsible.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Create.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Delete.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Describe.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Grant.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListActivity.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByNS.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByName.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByRole.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByUser.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Rename.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_CreateDelete.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_Describe.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListActivity.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByNS.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByNameOnly.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByPerm.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByRole.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByUser.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_User.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Cred.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Delg.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListActivity.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListApprovals.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListDelegates.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForCreds.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForPermission.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForRoles.java delete mode 100644 authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Role.java delete mode 100644 authz-core/pom.xml delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/common/Define.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/env/AuthzEnv.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTrans.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransFilter.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransImpl.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransOnlyFilter.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/env/NullTrans.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/layer/FacadeImpl.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/layer/Result.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/local/AbsData.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/local/DataFile.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/local/TextIndex.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/org/EmailWarnings.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/org/Executor.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/org/Organization.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/org/OrganizationException.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/org/OrganizationFactory.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/authz/server/AbsServer.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cache/Cache.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/Acceptor.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/CachingFileAccess.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/CodeSetter.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/Content.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/HttpCode.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/HttpMethods.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/Match.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/Pair.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/RServlet.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/Route.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/RouteReport.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/Routes.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/TransFilter.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/TransOnlyFilter.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/TypedCode.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/Version.java delete mode 100644 authz-core/src/main/java/org/onap/aaf/cssa/rserv/doc/ApiDoc.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/authz/common/JU_Define.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzEnv.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransFilter.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransImpl.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransOnlyFilter.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/authz/env/JU_NullTrans.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/authz/layer/JU_Result.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/authz/local/JU_DataFile.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/authz/local/JU_TextIndex.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/authz/org/JU_OrganizationException.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/authz/org/JU_OrganizationFactory.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_CachingFileAccess.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_CodeSetter.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Pair.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Routes.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_TypedCode.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Version.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/cssa/rserv/test/JU_BetterMatch.java delete mode 100644 authz-core/src/test/java/org/onap/aaf/cssa/rserv/test/JU_Content.java delete mode 100644 authz-defOrg/pom.xml delete mode 100644 authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrg.java delete mode 100644 authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrgIdentity.java delete mode 100644 authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrgWarnings.java delete mode 100644 authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/Identities.java delete mode 100644 authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrd/test/JU_Identities.java delete mode 100644 authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrg.java delete mode 100644 authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrgIdentity.java delete mode 100644 authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrgWarnings.java delete mode 100644 authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_Identities.java delete mode 100644 authz-defOrg/src/test/resources/test.txt delete mode 100644 cadi/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java diff --git a/auth/auth-batch/pom.xml b/auth/auth-batch/pom.xml index 8aabdf54..d09bd5d3 100644 --- a/auth/auth-batch/pom.xml +++ b/auth/auth-batch/pom.xml @@ -93,12 +93,6 @@ aaf-auth-cass - - org.joda - joda-time - 2.5 - - org.slf4j slf4j-log4j12 diff --git a/auth/pom.xml b/auth/pom.xml index d024e110..99b998c0 100644 --- a/auth/pom.xml +++ b/auth/pom.xml @@ -378,7 +378,7 @@ javax.servlet servlet-api - 3.0 + 2.5 diff --git a/authz-certman/pom.xml b/authz-certman/pom.xml deleted file mode 100644 index 838f8a7a..00000000 --- a/authz-certman/pom.xml +++ /dev/null @@ -1,247 +0,0 @@ - - - - 4.0.0 - - org.onap.aaf.authz - parent - 1.0.1-SNAPSHOT - ../pom.xml - - - authz-certman - AAF Certification Managmenent - Certificate Manager API - https://github.com/att/AAF - - - - Jonathan Gathman - - ATT - - - - - - - 45 - UTF-8 - 1.0.0-SNAPSHOT - - 0.7.7.201606060606 - true - 3.2 - jacoco - - target/code-coverage/jacoco-ut.exec - target/code-coverage/jacoco-it.exec - - **/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/** - https://nexus.onap.org - /content/repositories/snapshots/ - /content/repositories/releases/ - /content/repositories/staging/ - /content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version} - - - - - org.onap.aaf.authz - authz-core - ${project.version} - - - - org.onap.aaf.authz - authz-cass - ${project.version} - - - - - org.onap.aaf.cadi - cadi-aaf - ${project.cadiVersion} - - - - com.google.code.jscep - jscep - 2.4.0 - - - - org.slf4j - slf4j-log4j12 - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - **/*.class - - - 2.3.1 - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.4 - - false - - - - attach-javadocs - - jar - - - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ${nexusproxy} - 176c31dfe190a - ecomp-staging - - - - org.jacoco - jacoco-maven-plugin - ${jacoco.version} - - - **/gen/** - **/generated-sources/** - **/yang-gen/** - **/pax/** - - - - - - pre-unit-test - - prepare-agent - - - ${project.build.directory}/code-coverage/jacoco-ut.exec - surefireArgLine - - - - - - post-unit-test - test - - report - - - ${project.build.directory}/code-coverage/jacoco-ut.exec - ${project.reporting.outputDirectory}/jacoco-ut - - - - pre-integration-test - pre-integration-test - - prepare-agent - - - ${project.build.directory}/code-coverage/jacoco-it.exec - - failsafeArgLine - - - - - - post-integration-test - post-integration-test - - report - - - ${project.build.directory}/code-coverage/jacoco-it.exec - ${project.reporting.outputDirectory}/jacoco-it - - - - - - - - - - - - - ecomp-releases - AAF Release Repository - ${nexusproxy}${releaseNexusPath} - - - ecomp-snapshots - AAF Snapshot Repository - ${nexusproxy}${snapshotNexusPath} - - - ecomp-site - dav:${nexusproxy}${sitePath} - - - - diff --git a/authz-certman/src/main/config/certman.props b/authz-certman/src/main/config/certman.props deleted file mode 100644 index 496d8c37..00000000 --- a/authz-certman/src/main/config/certman.props +++ /dev/null @@ -1,25 +0,0 @@ -## -## AUTHZ Certman (authz-certman) Properties -## - -hostname=_HOSTNAME_ - -## DISCOVERY (DME2) Parameters on the Command Line -AFT_LATITUDE=_AFT_LATITUDE_ -AFT_LONGITUDE=_AFT_LONGITUDE_ -AFT_ENVIRONMENT=_AFT_ENVIRONMENT_ -DEPLOYED_VERSION=_ARTIFACT_VERSION_ - -## Pull in common/security properties - -cadi_prop_files=_COMMON_DIR_/com.att.aaf.common.props;_COMMON_DIR_/com.att.aaf.props - -##DME2 related parameters -DMEServiceName=service=com.att.authz.certman/version=_MAJOR_VER_._MINOR_VER_._PATCH_VER_/envContext=_ENV_CONTEXT_/routeOffer=_ROUTE_OFFER_ -AFT_DME2_PORT_RANGE=_AUTHZ_CERTMAN_PORT_RANGE_ - -# Turn on both AAF TAF & LUR 2.0 -aaf_url=https://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=_MAJOR_VER_._MINOR_VER_/envContext=_ENV_CONTEXT_/routeOffer=_ROUTE_OFFER_ - - - diff --git a/authz-certman/src/main/config/log4j.properties b/authz-certman/src/main/config/log4j.properties deleted file mode 100644 index ed7f1ca4..00000000 --- a/authz-certman/src/main/config/log4j.properties +++ /dev/null @@ -1,78 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START==================================================== -# * org.onap.aaf -# * =========================================================================== -# * Copyright © 2017 AT&T Intellectual Property. All rights reserved. -# * =========================================================================== -# * Licensed under the Apache License, Version 2.0 (the "License"); -# * you may not use this file except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# * ============LICENSE_END==================================================== -# * -# * ECOMP is a trademark and service mark of AT&T Intellectual Property. -# * -#------------------------------------------------------------------------------- -############################################################################### -# Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. -############################################################################### -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -log4j.appender.INIT=org.apache.log4j.DailyRollingFileAppender -log4j.appender.INIT.File=_LOG_DIR_/${LOG4J_FILENAME_init} -log4j.appender.INIT.DatePattern='.'yyyy-MM-dd -#log4j.appender.INIT.MaxFileSize=_MAX_LOG_FILE_SIZE_ -#log4j.appender.INIT.MaxBackupIndex=_MAX_LOG_FILE_BACKUP_COUNT_ -log4j.appender.INIT.layout=org.apache.log4j.PatternLayout -log4j.appender.INIT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSSZ} %m %n - - -log4j.appender.CM=org.apache.log4j.DailyRollingFileAppender -log4j.appender.CM.File=_LOG_DIR_/${LOG4J_FILENAME_cm} -log4j.appender.CM.DatePattern='.'yyyy-MM-dd -#log4j.appender.CM.MaxFileSize=_MAX_LOG_FILE_SIZE_ -#log4j.appender.CM.MaxBackupIndex=_MAX_LOG_FILE_BACKUP_COUNT_ -log4j.appender.CM.layout=org.apache.log4j.PatternLayout -log4j.appender.CM.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSSZ} %p [%c] %m %n - -log4j.appender.AUDIT=org.apache.log4j.DailyRollingFileAppender -log4j.appender.AUDIT.File=_LOG_DIR_/${LOG4J_FILENAME_audit} -log4j.appender.AUDIT.DatePattern='.'yyyy-MM-dd -#log4j.appender.AUDIT.MaxFileSize=_MAX_LOG_FILE_SIZE_ -#log4j.appender.AUDIT.MaxBackupIndex=_MAX_LOG_FILE_BACKUP_COUNT_ -log4j.appender.AUDIT.layout=org.apache.log4j.PatternLayout -log4j.appender.AUDIT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSSZ} %m %n - - -# General Apache libraries -log4j.rootLogger=INFO,CM -log4j.logger.org.apache=WARN,INIT -log4j.logger.dme2=WARN,INIT -log4j.logger.init=INFO,INIT -log4j.logger.authz=_LOG4J_LEVEL_,CM -log4j.logger.audit=INFO,AUDIT -log4j.category.org.jscep=INFO - diff --git a/authz-certman/src/main/config/lrm-authz-certman.xml b/authz-certman/src/main/config/lrm-authz-certman.xml deleted file mode 100644 index 9fd99a3f..00000000 --- a/authz-certman/src/main/config/lrm-authz-certman.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - com.att.authz._ARTIFACT_ID_ - - _MAJOR_VER_ - _MINOR_VER_ - _PATCH_VER_ - - _ROUTE_OFFER_ - - Java - com.att.authz.cm.service.CertManAPI - - process.workdir - _ROOT_DIR_ - - - jvm.version - 1.8 - - - jvm.args - -DAFT_LATITUDE=_AFT_LATITUDE_ -DAFT_LONGITUDE=_AFT_LONGITUDE_ -DAFT_ENVIRONMENT=_AFT_ENVIRONMENT_ -Dplatform=_SCLD_PLATFORM_ -Dcom.sun.jndi.ldap.connect.pool.maxsize=20 -Dcom.sun.jndi.ldap.connect.pool.prefsize=10 -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 - - - jvm.classpath - _ROOT_DIR_/etc:_ROOT_DIR_/lib/*: - - - jvm.heap.min - 1024m - - - jvm.heap.max - 2048m - - - start.class - com.att.authz.cm.service.CertManAPI - - - stdout.redirect - _ROOT_DIR_/logs/SystemOut.log - - - stderr.redirect - _ROOT_DIR_/logs/SystemErr.log - - aft - AUTO - 2 - _RESOURCE_MIN_COUNT_ - _RESOURCE_MAX_COUNT_ - _RESOURCE_REGISTRATION_ - com.att.authz:_ARTIFACT_ID_ - _ARTIFACT_VERSION_ - - diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/api/API_Artifact.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/api/API_Artifact.java deleted file mode 100644 index 29362df9..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/api/API_Artifact.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.api; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aaf.authz.cm.mapper.Mapper.API; -import org.onap.aaf.authz.cm.service.CertManAPI; -import org.onap.aaf.authz.cm.service.Code; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.layer.Result; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import com.att.aft.dme2.internal.jetty.http.HttpStatus; - -/** - * API Deployment Artifact Apis.. using Redirect for mechanism - * - * - */ -public class API_Artifact { - private static final String GET_ARTIFACTS = "Get Artifacts"; - - /** - * Normal Init level APIs - * - * @param cmAPI - * @param facade - * @throws Exception - */ - public static void init(final CertManAPI cmAPI) throws Exception { - cmAPI.route(HttpMethods.POST, "/cert/artifacts", API.ARTIFACTS, new Code(cmAPI,"Create Artifacts") { - @Override - public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - Result r = context.createArtifacts(trans, req, resp); - if(r.isOK()) { - resp.setStatus(HttpStatus.CREATED_201); - } else { - context.error(trans,resp,r); - } - } - }); - - cmAPI.route(HttpMethods.GET, "/cert/artifacts/:mechid/:machine", API.ARTIFACTS, new Code(cmAPI,GET_ARTIFACTS) { - @Override - public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - - Result r = context.readArtifacts(trans, resp, pathParam(req,":mechid"), pathParam(req,":machine")); - if(r.isOK()) { - resp.setStatus(HttpStatus.CREATED_201); - } else { - context.error(trans,resp,r); - } - } - }); - - cmAPI.route(HttpMethods.GET, "/cert/artifacts", API.ARTIFACTS, new Code(cmAPI,GET_ARTIFACTS) { - @Override - public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - Result r = context.readArtifacts(trans, req, resp); - if(r.isOK()) { - resp.setStatus(HttpStatus.CREATED_201); - } else { - context.error(trans,resp,r); - } - } - }); - - cmAPI.route(HttpMethods.PUT, "/cert/artifacts", API.ARTIFACTS, new Code(cmAPI,"Update Artifacts") { - @Override - public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - Result r = context.updateArtifacts(trans, req, resp); - if(r.isOK()) { - resp.setStatus(HttpStatus.OK_200); - } else { - context.error(trans,resp,r); - } - } - }); - - cmAPI.route(HttpMethods.DELETE, "/cert/artifacts/:mechid/:machine", API.VOID, new Code(cmAPI,"Delete Artifacts") { - @Override - public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - Result r = context.deleteArtifacts(trans, resp, - pathParam(req, ":mechid"), pathParam(req,":machine")); - if(r.isOK()) { - resp.setStatus(HttpStatus.OK_200); - } else { - context.error(trans,resp,r); - } - } - }); - - - cmAPI.route(HttpMethods.DELETE, "/cert/artifacts", API.VOID, new Code(cmAPI,"Delete Artifacts") { - @Override - public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - Result r = context.deleteArtifacts(trans, req, resp); - if(r.isOK()) { - resp.setStatus(HttpStatus.OK_200); - } else { - context.error(trans,resp,r); - } - } - }); - - - } -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/api/API_Cert.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/api/API_Cert.java deleted file mode 100644 index d8cdf26c..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/api/API_Cert.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.api; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aaf.authz.cm.ca.CA; -import org.onap.aaf.authz.cm.mapper.Mapper.API; -import org.onap.aaf.authz.cm.service.CertManAPI; -import org.onap.aaf.authz.cm.service.Code; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.layer.Result; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import com.att.aft.dme2.internal.jetty.http.HttpStatus; -import org.onap.aaf.inno.env.Slot; -import org.onap.aaf.inno.env.TransStore; - -/** - * API Apis.. using Redirect for mechanism - * - * - */ -public class API_Cert { - public static final String CERT_AUTH = "CertAuthority"; - private static Slot sCertAuth; - - /** - * Normal Init level APIs - * - * @param cmAPI - * @param facade - * @throws Exception - */ - public static void init(final CertManAPI cmAPI) throws Exception { - // Check for Created Certificate Authorities in TRANS - sCertAuth = ((TransStore) cmAPI.env).slot(CERT_AUTH); - - //////// - // Overall APIs - /////// - cmAPI.route(HttpMethods.PUT,"/cert/:ca",API.CERT_REQ,new Code(cmAPI,"Request Certificate") { - @Override - public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - String key = pathParam(req, ":ca"); - CA ca; - if((ca = cmAPI.getCA(key))==null) { - context.error(trans,resp,Result.ERR_BadData,"CA %s is not supported",key); - } else { - trans.put(sCertAuth, ca); - - Result r = context.requestCert(trans, req, resp, req.getParameter("withTrust")!=null); - if(r.isOK()) { - resp.setStatus(HttpStatus.OK_200); - } else { - context.error(trans,resp,r); - } - } - } - }); - - /** - * - */ - cmAPI.route(HttpMethods.GET, "/cert/may/:perm", API.VOID, new Code(cmAPI,"Check Permission") { - @Override - public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - Result r = context.check(trans, resp, pathParam(req,"perm")); - if(r.isOK()) { - resp.setStatus(HttpStatus.OK_200); - } else { - trans.checkpoint(r.errorString()); - context.error(trans,resp,Result.err(Result.ERR_Denied,"%s does not have Permission.",trans.user())); - } - } - }); - - } -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/AppCA.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/AppCA.java deleted file mode 100644 index 79e7fff2..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/AppCA.java +++ /dev/null @@ -1,356 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.ca; - -import java.io.File; -import java.io.IOException; -import java.net.Authenticator; -import java.net.MalformedURLException; -import java.net.PasswordAuthentication; -import java.net.URL; -import java.security.cert.CertStore; -import java.security.cert.CertStoreException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.List; - -import org.bouncycastle.operator.OperatorCreationException; -import org.bouncycastle.pkcs.PKCS10CertificationRequest; -import org.jscep.client.Client; -import org.jscep.client.ClientException; -import org.jscep.client.EnrollmentResponse; -import org.jscep.client.verification.CertificateVerifier; -import org.jscep.transaction.TransactionException; -import org.onap.aaf.authz.cm.cert.BCFactory; -import org.onap.aaf.authz.cm.cert.CSRMeta; -import org.onap.aaf.authz.cm.cert.StandardFields; -import org.onap.aaf.authz.common.Define; - -import org.onap.aaf.cadi.cm.CertException; -import org.onap.aaf.cadi.cm.Factory; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.routing.GreatCircle; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; -import org.onap.aaf.inno.env.util.Split; - -public class AppCA extends CA { - public static final String CA_PERM_TYPE = Define.ROOT_NS+".ca"; // Permission Type for validation - private static final String AAF_DATA_DIR = "aaf_data_dir"; - private static final String CA_PREFIX = "http://"; - private static final String CA_POSTFIX="/certsrv/mscep_admin/mscep.dll"; - - private final static String MS_PROFILE="1"; - private static final String CM_TRUST_CAS = "cm_trust_cas"; - private Clients clients; - - private static class AAFStdFields implements StandardFields { - private final String env; - public AAFStdFields(Trans trans) throws CertException { - env = trans.getProperty(Config.AAF_ENV); - if(env==null) { - throw new CertException(Config.AAF_ENV + " must be set to create Certificates"); - } - } - @Override - public void set(CSRMeta csr) { - // Environment - csr.environment(env); - // Standard Fields - csr.o("ATT Services,Inc."); - csr.l("St Louis"); - csr.st("Missouri"); - csr.c("US"); - } - } - - public AppCA(final Trans trans, final String name, final String urlstr, final String id, final String pw) throws IOException, CertificateException, CertException { - super(name,new AAFStdFields(trans), CA_PERM_TYPE); - - clients = new Clients(trans,urlstr); - - - // Set this for NTLM password Microsoft - Authenticator.setDefault(new Authenticator() { - public PasswordAuthentication getPasswordAuthentication () { - return new PasswordAuthentication ( - id, - trans.decryptor().decrypt(pw).toCharArray()); - } - }); - - - - try { - StringBuilder sb = new StringBuilder("CA Reported Trusted Certificates"); - List trustCerts = new ArrayList(); - for(Client client : clients) { - CertStore cs = client.getCaCertificate(MS_PROFILE); - - Collection cc = cs.getCertificates(null); - for(Certificate c : cc) { - X509Certificate xc = (X509Certificate)c; - // Avoid duplicate Certificates from multiple servers - X509Certificate match = null; - for(X509Certificate t : trustCerts) { - if(t.getSerialNumber().equals(xc.getSerialNumber())) { - match = xc; - break; - } - } - if(match==null && xc.getSubjectDN().getName().startsWith("CN=ATT ")) { - sb.append("\n\t"); - sb.append(xc.getSubjectDN()); - sb.append("\n\t\tSerial Number: "); - String bi = xc.getSerialNumber().toString(16); - for(int i=0;i1 && i%2==0) { - sb.append(':'); - } - sb.append(bi.charAt(i)); - } - sb.append("\n\t\tIssuer: "); - sb.append(xc.getIssuerDN()); - sb.append("\n\t\tNot Before: "); - sb.append(xc.getNotBefore()); - sb.append("\n\t\tNot After: "); - sb.append(xc.getNotAfter()); - sb.append("\n\t\tSigAlgorithm: "); - sb.append(xc.getSigAlgName()); - sb.append("\n\t\tType: "); - sb.append(xc.getType()); - sb.append("\n\t\tVersion: "); - sb.append(xc.getVersion()); - - trustCerts.add(xc); - } - } - } - trans.init().log(sb); - // Add Additional ones from Property - String data_dir = trans.getProperty(AAF_DATA_DIR); - if(data_dir!=null) { - File data = new File(data_dir); - if(data.exists()) { - String trust_cas = trans.getProperty(CM_TRUST_CAS); - byte[] bytes; - if(trust_cas!=null) { - for(String fname : Split.split(';', trust_cas)) { - File crt = new File(data,fname); - if(crt.exists()) { - bytes = Factory.decode(crt); - try { - Collection cc = Factory.toX509Certificate(bytes); - for(Certificate c : cc) { - trustCerts.add((X509Certificate)c); - } - } catch (CertificateException e) { - throw new CertException(e); - } - } - } - } - } - } - - String[] trustChain = new String[trustCerts.size()]; - int i=-1; - for( Certificate cert : trustCerts) { - trustChain[++i]=BCFactory.toString(trans,cert); - } - - setTrustChain(trustChain); - } catch (ClientException | CertStoreException e) { - // Note: Cannot validly start without all Clients, because we need to read all Issuing Certificates - // This is acceptable risk for most things, as we're not real time in general - throw new CertException(e); - } - } - - - @Override - public X509Certificate sign(Trans trans, CSRMeta csrmeta) throws IOException, CertException { - TimeTaken tt = trans.start("Generating CSR and Keys for New Certificate", Env.SUB); - PKCS10CertificationRequest csr; - try { - csr = csrmeta.generateCSR(trans); - if(trans.info().isLoggable()) { - trans.info().log(BCFactory.toString(trans, csr)); - } - if(trans.info().isLoggable()) { - trans.info().log(csr); - } - } finally { - tt.done(); - } - - tt = trans.start("Enroll CSR", Env.SUB); - Client client = null; - try { - client = clients.best(); - EnrollmentResponse er = client.enrol( - csrmeta.initialConversationCert(trans), - csrmeta.keypair(trans).getPrivate(), - csr, - MS_PROFILE /* profile... MS can't deal with blanks*/); - while(true) { - if(er.isSuccess()) { - for( Certificate cert : er.getCertStore().getCertificates(null)) { - return (X509Certificate)cert; - } - break; - } else if (er.isPending()) { - trans.checkpoint("Polling, waiting on CA to complete"); - Thread.sleep(3000); - } else if (er.isFailure()) { - throw new CertException(er.getFailInfo().toString()); - } - } - } catch (ClientException e) { - trans.error().log(e,"SCEP Client Error, Temporarily Invalidating Client"); - if(client!=null) { - clients.invalidate(client); - } - } catch (InterruptedException|TransactionException|CertificateException|OperatorCreationException | CertStoreException e) { - trans.error().log(e); - } finally { - tt.done(); - } - - return null; - } - - - private class Clients implements Iterable{ - /** - * CSO Servers are in Dallas and St Louis - * GEO_LOCATION LATITUDE LONGITUDE ZIPCODE TIMEZONE - * ------------ -------- --------- ------- -------- - * DLLSTXCF 32.779295 -96.800014 75202 America/Chicago - * STLSMORC 38.627345 -90.193774 63101 America/Chicago - * - * The online production issuing CA servers are: - * AAF - CADI Issuing CA 01 135.41.45.152 MOSTLS1AAFXXA02 - * AAF - CADI Issuing CA 02 135.31.72.154 TXDLLS2AAFXXA02 - */ - - private final Client[] client; - private final Date[] failure; - private int preferred; - - public Clients(Trans trans, String urlstr) throws MalformedURLException { - String[] urlstrs = Split.split(',', urlstr); - client = new Client[urlstrs.length]; - failure = new Date[urlstrs.length]; - double distance = Double.MAX_VALUE; - String localLat = trans.getProperty("AFT_LATITUDE","39.833333"); //Note: Defaulting to GEO center of US - String localLong = trans.getProperty("AFT_LONGITUDE","-98.583333"); - for(int i=0;i iterator() { - return new Iterator() { - private int iter = 0; - @Override - public boolean hasNext() { - return iter < Clients.this.client.length; - } - - @Override - public Client next() { - return Clients.this.client[iter++]; - } - - }; - } - } -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/CA.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/CA.java deleted file mode 100644 index 97b8a7b4..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/CA.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.ca; - -import java.io.IOException; -import java.security.MessageDigest; -import java.security.cert.X509Certificate; - -import org.onap.aaf.authz.cm.cert.CSRMeta; -import org.onap.aaf.authz.cm.cert.StandardFields; - -import org.onap.aaf.cadi.cm.CertException; -import org.onap.aaf.inno.env.Trans; - -public abstract class CA { - private final String name; - private String[] trustChain; - private final StandardFields stdFields; - private MessageDigest messageDigest; - private final String permType; - - protected CA(String name, StandardFields sf, String permType) { - this.name = name; - stdFields = sf; - this.permType = permType; - } - - /* - * NOTE: These two functions must be called in Protected Constructors during their Construction. - */ - protected void setTrustChain(String[] trustChain) { - this.trustChain = trustChain; - } - - protected void setMessageDigest(MessageDigest md) { - messageDigest = md; - } - - /* - * End Required Constructor calls - */ - - public String getName() { - return name; - } - - public String[] getTrustChain() { - return trustChain; - } - - public String getPermType() { - return permType; - } - - public StandardFields stdFields() { - return stdFields; - } - - public abstract X509Certificate sign(Trans trans, CSRMeta csrmeta) throws IOException, CertException; - - public MessageDigest messageDigest() { - return messageDigest; - } -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/DevlCA.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/DevlCA.java deleted file mode 100644 index 8edd287e..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/DevlCA.java +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.ca; - -import java.io.File; -import java.io.IOException; -import java.math.BigInteger; -import java.security.GeneralSecurityException; -import java.security.KeyFactory; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.security.interfaces.RSAPrivateKey; -import java.security.spec.PKCS8EncodedKeySpec; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; -import java.security.SecureRandom; - -import org.bouncycastle.asn1.ASN1Sequence; -import org.bouncycastle.asn1.x500.X500Name; -import org.bouncycastle.asn1.x500.X500NameBuilder; -import org.bouncycastle.asn1.x500.style.BCStyle; -import org.bouncycastle.asn1.x509.BasicConstraints; -import org.bouncycastle.asn1.x509.ExtendedKeyUsage; -import org.bouncycastle.asn1.x509.Extension; -import org.bouncycastle.asn1.x509.GeneralName; -import org.bouncycastle.asn1.x509.GeneralNames; -import org.bouncycastle.asn1.x509.KeyPurposeId; -import org.bouncycastle.asn1.x509.KeyUsage; -import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; -import org.bouncycastle.cert.X509v3CertificateBuilder; -import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter; -import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils; -import org.bouncycastle.operator.OperatorCreationException; -import org.onap.aaf.authz.cm.cert.BCFactory; -import org.onap.aaf.authz.cm.cert.CSRMeta; -import org.onap.aaf.authz.cm.cert.StandardFields; -import org.onap.aaf.authz.common.Define; - -import org.onap.aaf.cadi.cm.CertException; -import org.onap.aaf.cadi.cm.Factory; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; - -public class DevlCA extends CA { - - // Extensions - private static final KeyPurposeId[] ASN_WebUsage = new KeyPurposeId[] { - KeyPurposeId.id_kp_serverAuth, // WebServer - KeyPurposeId.id_kp_clientAuth};// WebClient - - private X509Certificate caCert; - private final RSAPrivateKey caKey; - private final X500Name issuer; - private final SecureRandom random = new SecureRandom(); - private byte[] serialish = new byte[24]; - - public DevlCA(Trans trans, String name, String dirString) throws IOException, CertException { - super(name, new StandardFields() { - @Override - public void set(CSRMeta csr) { - // Standard Fields - csr.o("ATT Services, Inc."); - csr.l("St Louis"); - csr.st("Missouri"); - csr.c("US"); - } - }, Define.ROOT_NS+".ca" // Permission Type for validation - ); - File dir = new File(dirString); - if(!dir.exists()) { - throw new CertException(dirString + " does not exist"); - } - - File ca = new File(dir,"ca.crt"); - if(ca.exists()) { - byte[] bytes = Factory.decode(ca); - Collection certs; - try { - certs = Factory.toX509Certificate(bytes); - } catch (CertificateException e) { - throw new CertException(e); - } - List lTrust = new ArrayList(); - caCert=null; - for(Certificate c : certs) { - if(caCert==null) { - caCert = (X509Certificate)c; - } else { - lTrust.add(Factory.toString(trans,c)); - } - break; - } - } - - this.setTrustChain(new String[]{Factory.toString(trans,caCert)}); - - /* - * Private key needs to be converted to "DER" format, with no password. - * Use chmod 400 on key - * - * openssl pkcs8 -topk8 -outform DER -nocrypt -in ca.key -out ca.der - * - */ - ca = new File(dir,"ca.der"); - if(ca.exists()) { - byte[] bytes = Factory.binary(ca); - -// EncryptedPrivateKeyInfo ekey=new EncryptedPrivateKeyInfo(bytes); -// Cipher cip=Cipher.getInstance(ekey.getAlgName()); -// PBEKeySpec pspec=new PBEKeySpec("password".toCharArray()); -// SecretKeyFactory skfac=SecretKeyFactory.getInstance(ekey.getAlgName()); -// Key pbeKey=skfac.generateSecret(pspec); -// AlgorithmParameters algParams=ekey.getAlgParameters(); -// cip.init(Cipher.DECRYPT_MODE,pbeKey,algParams); - - KeyFactory keyFactory; - try { - keyFactory = KeyFactory.getInstance("RSA"); - PKCS8EncodedKeySpec privSpec = new PKCS8EncodedKeySpec(bytes); - - caKey = (RSAPrivateKey) keyFactory.generatePrivate(privSpec); - } catch (GeneralSecurityException e) { - throw new CertException(e); - } - - X500NameBuilder xnb = new X500NameBuilder(); - xnb.addRDN(BCStyle.C,"US"); - xnb.addRDN(BCStyle.ST,"Missouri"); - xnb.addRDN(BCStyle.L,"Arnold"); - xnb.addRDN(BCStyle.O,"ATT Services, Inc."); - xnb.addRDN(BCStyle.OU,"AAF"); - xnb.addRDN(BCStyle.CN,"aaf.att.com"); - xnb.addRDN(BCStyle.EmailAddress,"DL-aaf-support@att.com"); - issuer = xnb.build(); - } else { - throw new CertException(ca.getPath() + " does not exist"); - } - } - - /* (non-Javadoc) - * @see org.onap.aaf.authz.cm.service.CA#sign(org.bouncycastle.pkcs.PKCS10CertificationRequest) - */ - @Override - public X509Certificate sign(Trans trans, CSRMeta csrmeta) throws IOException, CertException { - GregorianCalendar gc = new GregorianCalendar(); - Date start = gc.getTime(); - gc.add(GregorianCalendar.DAY_OF_MONTH, 1); - Date end = gc.getTime(); - X509Certificate x509; - TimeTaken tt = trans.start("Create/Sign Cert",Env.SUB); - try { - BigInteger bi; - synchronized(serialish) { - random.nextBytes(serialish); - bi = new BigInteger(serialish); - } - - X509v3CertificateBuilder xcb = new X509v3CertificateBuilder( - issuer, - bi, // replace with Serialnumber scheme - start, - end, - csrmeta.x500Name(), -// SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(caCert.getPublicKey().getEn) - new SubjectPublicKeyInfo(ASN1Sequence.getInstance(caCert.getPublicKey().getEncoded())) - ); - List lsan = new ArrayList(); - for(String s : csrmeta.sans()) { - lsan.add(new GeneralName(GeneralName.dNSName,s)); - } - GeneralName[] sans = new GeneralName[lsan.size()]; - lsan.toArray(sans); - - JcaX509ExtensionUtils extUtils = new JcaX509ExtensionUtils(); - xcb .addExtension(Extension.basicConstraints, - false, new BasicConstraints(false)) - .addExtension(Extension.keyUsage, - true, new KeyUsage(KeyUsage.digitalSignature - | KeyUsage.keyEncipherment)) - .addExtension(Extension.extendedKeyUsage, - true, new ExtendedKeyUsage(ASN_WebUsage)) - - .addExtension(Extension.authorityKeyIdentifier, - false, extUtils.createAuthorityKeyIdentifier(caCert)) - .addExtension(Extension.subjectKeyIdentifier, - false, extUtils.createSubjectKeyIdentifier(caCert.getPublicKey())) - .addExtension(Extension.subjectAlternativeName, - false, new GeneralNames(sans)) - ; - - x509 = new JcaX509CertificateConverter().getCertificate( - xcb.build(BCFactory.contentSigner(caKey))); - } catch (GeneralSecurityException|OperatorCreationException e) { - throw new CertException(e); - } finally { - tt.done(); - } - return x509; - } - -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/BCFactory.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/BCFactory.java deleted file mode 100644 index 54a71f4e..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/BCFactory.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.cert; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.lang.reflect.Field; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.SignatureException; -import java.util.List; - -import org.bouncycastle.asn1.ASN1Object; -import org.bouncycastle.operator.ContentSigner; -import org.bouncycastle.operator.OperatorCreationException; -import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; -import org.bouncycastle.pkcs.PKCS10CertificationRequest; -import org.onap.aaf.authz.cm.ca.CA; -import org.onap.aaf.authz.cm.validation.Validator; - -import org.onap.aaf.cadi.Symm; -import org.onap.aaf.cadi.cm.CertException; -import org.onap.aaf.cadi.cm.Factory; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; - - -/** - * Additional Factory mechanisms for CSRs, and BouncyCastle. The main Factory - * utilizes only Java abstractions, and is useful in Client code. - * - - * - */ -public class BCFactory extends Factory { - private static final JcaContentSignerBuilder jcsb; - - - static { - // Bouncy - jcsb = new JcaContentSignerBuilder(Factory.SIG_ALGO); - } - - public static ContentSigner contentSigner(PrivateKey pk) throws OperatorCreationException { - return jcsb.build(pk); - } - - public static String toString(Trans trans, PKCS10CertificationRequest csr) throws IOException, CertException { - TimeTaken tt = trans.start("CSR to String", Env.SUB); - try { - if(csr==null) { - throw new CertException("x509 Certificate Request not built"); - } - return textBuilder("CERTIFICATE REQUEST",csr.getEncoded()); - }finally { - tt.done(); - } - } - - public static PKCS10CertificationRequest toCSR(Trans trans, File file) throws IOException { - TimeTaken tt = trans.start("Reconstitute CSR", Env.SUB); - try { - FileReader fr = new FileReader(file); - return new PKCS10CertificationRequest(decode(strip(fr))); - } finally { - tt.done(); - } - } - - public static byte[] sign(Trans trans, ASN1Object toSign, PrivateKey pk) throws IOException, InvalidKeyException, SignatureException, NoSuchAlgorithmException { - TimeTaken tt = trans.start("Encode Security Object", Env.SUB); - try { - return sign(trans,toSign.getEncoded(),pk); - } finally { - tt.done(); - } - } - - public static CSRMeta createCSRMeta(CA ca,final String args[]) throws IllegalArgumentException, IllegalAccessException, CertException { - CSRMeta csr = new CSRMeta(); - ca.stdFields().set(csr); - //TODO should we checkDigest? -// digest = ca.messageDigest(); - - Field[] fld = CSRMeta.class.getDeclaredFields(); - for(int i=0;i+1 fqdns) throws CertException { - CSRMeta csr = new CSRMeta(); - boolean first = true; - // Set CN (and SAN) - for(String fqdn : fqdns) { - if(first) { - first = false; - csr.cn(fqdn); - } else { - csr.san(fqdn); - } - } - - csr.challenge(new String(Symm.randomGen(24))); - ca.stdFields().set(csr); - csr.mechID(mechid); - csr.email(sponsorEmail); - String errs = validate(csr); - if(errs!=null) { - throw new CertException(errs); - } - return csr; - } - - private static String validate(CSRMeta csr) { - Validator v = new Validator(); - if(v.nullOrBlank("cn", csr.cn()) - .nullOrBlank("mechID", csr.mechID()) - .nullOrBlank("email", csr.email()) - .nullOrBlank("o",csr.o()) - .nullOrBlank("l",csr.l()) - .nullOrBlank("st",csr.st()) - .nullOrBlank("c",csr.c()) - .err()) { - return v.errs(); - } else { - return null; - } - } - - -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/CSRMeta.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/CSRMeta.java deleted file mode 100644 index f71163ef..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/CSRMeta.java +++ /dev/null @@ -1,329 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.cert; - -import java.io.IOException; -import java.math.BigInteger; -import java.security.KeyPair; -import java.security.SecureRandom; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; - -import org.bouncycastle.asn1.ASN1Sequence; -import org.bouncycastle.asn1.DERPrintableString; -import org.bouncycastle.asn1.pkcs.Attribute; -import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; -import org.bouncycastle.asn1.x500.X500Name; -import org.bouncycastle.asn1.x500.X500NameBuilder; -import org.bouncycastle.asn1.x500.style.BCStyle; -import org.bouncycastle.asn1.x509.Extension; -import org.bouncycastle.asn1.x509.Extensions; -import org.bouncycastle.asn1.x509.GeneralName; -import org.bouncycastle.asn1.x509.GeneralNames; -import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; -import org.bouncycastle.cert.X509v3CertificateBuilder; -import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter; -import org.bouncycastle.operator.OperatorCreationException; -import org.bouncycastle.pkcs.PKCS10CertificationRequest; -import org.bouncycastle.pkcs.PKCS10CertificationRequestBuilder; -import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilder; - -import org.onap.aaf.cadi.cm.CertException; -import org.onap.aaf.cadi.cm.Factory; -import org.onap.aaf.inno.env.Trans; - -public class CSRMeta { - private String environment; - private String cn; - private String mechID; - private String email; - private String o; - private String l; - private String st; - private String c; - private String challenge; - - private ArrayList sanList = new ArrayList(); - - private KeyPair keyPair; - private X500Name name = null; - private SecureRandom random = new SecureRandom(); - - public X500Name x500Name() throws IOException { - if(name==null) { - X500NameBuilder xnb = new X500NameBuilder(); - xnb.addRDN(BCStyle.CN,cn); - xnb.addRDN(BCStyle.E,email); - if(environment==null) { - xnb.addRDN(BCStyle.OU,mechID); - } else { - xnb.addRDN(BCStyle.OU,mechID+':'+environment); - } - xnb.addRDN(BCStyle.O,o); - xnb.addRDN(BCStyle.L,l); - xnb.addRDN(BCStyle.ST,st); - xnb.addRDN(BCStyle.C,c); - name = xnb.build(); - } - return name; - } - - - public PKCS10CertificationRequest generateCSR(Trans trans) throws IOException, CertException { - PKCS10CertificationRequestBuilder builder = new JcaPKCS10CertificationRequestBuilder(x500Name(),keypair(trans).getPublic()); - if(challenge!=null) { - DERPrintableString password = new DERPrintableString(challenge); - builder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_challengePassword, password); - } - - if(sanList.size()>0) { - GeneralName[] gna = new GeneralName[sanList.size()]; - int i=-1; - for(String s : sanList) { - gna[++i]=new GeneralName(GeneralName.dNSName,s); - } - - builder.addAttribute( - PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, - new Extensions(new Extension[] { - new Extension(Extension.subjectAlternativeName,false,new GeneralNames(gna).getEncoded()) - }) - ); - } -// builder.addAttribute(Extension.basicConstraints,new BasicConstraints(false)) -// .addAttribute(Extension.keyUsage, new KeyUsage(KeyUsage.digitalSignature -// | KeyUsage.keyEncipherment)); - try { - return builder.build(BCFactory.contentSigner(keypair(trans).getPrivate())); - } catch (OperatorCreationException e) { - throw new CertException(e); - } - } - - @SuppressWarnings("deprecation") - public static void dump(PKCS10CertificationRequest csr) { - Attribute[] certAttributes = csr.getAttributes(); - for (Attribute attribute : certAttributes) { - if (attribute.getAttrType().equals(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest)) { - Extensions extensions = Extensions.getInstance(attribute.getAttrValues().getObjectAt(0)); -// Extension ext = extensions.getExtension(Extension.subjectAlternativeName); - GeneralNames gns = GeneralNames.fromExtensions(extensions,Extension.subjectAlternativeName); - GeneralName[] names = gns.getNames(); - for(int k=0; k < names.length; k++) { - String title = ""; - if(names[k].getTagNo() == GeneralName.dNSName) { - title = "dNSName"; - } - else if(names[k].getTagNo() == GeneralName.iPAddress) { - title = "iPAddress"; - // Deprecated, but I don't see anything better to use. - names[k].toASN1Object(); - } - else if(names[k].getTagNo() == GeneralName.otherName) { - title = "otherName"; - } - System.out.println(title + ": "+ names[k].getName()); - } - } - } - } - - public X509Certificate initialConversationCert(Trans trans) throws IOException, CertificateException, OperatorCreationException { - GregorianCalendar gc = new GregorianCalendar(); - Date start = gc.getTime(); - gc.add(GregorianCalendar.DAY_OF_MONTH,2); - Date end = gc.getTime(); - X509v3CertificateBuilder xcb = new X509v3CertificateBuilder( - x500Name(), - new BigInteger(12,random), // replace with Serialnumber scheme - start, - end, - x500Name(), -// SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(caCert.getPublicKey().getEn) - new SubjectPublicKeyInfo(ASN1Sequence.getInstance(keypair(trans).getPublic().getEncoded())) - ); - return new JcaX509CertificateConverter().getCertificate( - xcb.build(BCFactory.contentSigner(keypair(trans).getPrivate()))); - } - - public CSRMeta san(String v) { - sanList.add(v); - return this; - } - - public List sans() { - return sanList; - } - - - public KeyPair keypair(Trans trans) { - if(keyPair == null) { - keyPair = Factory.generateKeyPair(trans); - } - return keyPair; - } - - /** - * @return the cn - */ - public String cn() { - return cn; - } - - - /** - * @param cn the cn to set - */ - public void cn(String cn) { - this.cn = cn; - } - - /** - * Environment of Service MechID is good for - */ - public void environment(String env) { - environment = env; - } - - /** - * - * @return - */ - public String environment() { - return environment; - } - - /** - * @return the mechID - */ - public String mechID() { - return mechID; - } - - - /** - * @param mechID the mechID to set - */ - public void mechID(String mechID) { - this.mechID = mechID; - } - - - /** - * @return the email - */ - public String email() { - return email; - } - - - /** - * @param email the email to set - */ - public void email(String email) { - this.email = email; - } - - - /** - * @return the o - */ - public String o() { - return o; - } - - - /** - * @param o the o to set - */ - public void o(String o) { - this.o = o; - } - - /** - * - * @return the l - */ - public String l() { - return l; - } - - /** - * @param l the l to set - */ - public void l(String l) { - this.l=l; - } - - /** - * @return the st - */ - public String st() { - return st; - } - - - /** - * @param st the st to set - */ - public void st(String st) { - this.st = st; - } - - - /** - * @return the c - */ - public String c() { - return c; - } - - - /** - * @param c the c to set - */ - public void c(String c) { - this.c = c; - } - - - /** - * @return the challenge - */ - public String challenge() { - return challenge; - } - - - /** - * @param challenge the challenge to set - */ - public void challenge(String challenge) { - this.challenge = challenge; - } - -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/StandardFields.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/StandardFields.java deleted file mode 100644 index f298d0d8..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/StandardFields.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.cert; - -import org.onap.aaf.cadi.cm.CertException; - -public interface StandardFields { - public void set(CSRMeta csr) throws CertException; -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertDrop.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertDrop.java deleted file mode 100644 index 03906c05..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertDrop.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.data; - -public class CertDrop { - -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertRenew.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertRenew.java deleted file mode 100644 index a0eb306e..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertRenew.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.data; - -public class CertRenew { - -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertReq.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertReq.java deleted file mode 100644 index 668686a8..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertReq.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.data; - -import java.util.List; - -import javax.xml.datatype.XMLGregorianCalendar; - -import org.onap.aaf.authz.cm.ca.CA; -import org.onap.aaf.authz.cm.cert.BCFactory; -import org.onap.aaf.authz.cm.cert.CSRMeta; - -import org.onap.aaf.cadi.cm.CertException; - -public class CertReq { - // These cannot be null - public CA certAuthority; - public String mechid; - public List fqdns; - // Notify - public List emails; - - - // These may be null - public String sponsor; - public XMLGregorianCalendar start, end; - - public CSRMeta getCSRMeta() throws CertException { - return BCFactory.createCSRMeta(certAuthority, mechid, sponsor,fqdns); - } -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertResp.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertResp.java deleted file mode 100644 index d06f63b4..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertResp.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.data; - -import java.io.IOException; -import java.security.GeneralSecurityException; -import java.security.KeyPair; -import java.security.cert.X509Certificate; - -import org.onap.aaf.authz.cm.cert.CSRMeta; - -import org.onap.aaf.cadi.cm.CertException; -import org.onap.aaf.cadi.cm.Factory; -import org.onap.aaf.inno.env.Trans; - -public class CertResp { - public CertResp(Trans trans, X509Certificate x509, CSRMeta csrMeta, String[] notes) throws IOException, GeneralSecurityException, CertException { - keyPair = csrMeta.keypair(trans); - privateKey = Factory.toString(trans, keyPair.getPrivate()); - certString = Factory.toString(trans,x509); - challenge=csrMeta.challenge(); - this.notes = notes; - } - private KeyPair keyPair; - private String challenge; - - private String privateKey, certString; - private String[] notes; - - - public String asCertString() { - return certString; - } - - public String privateString() throws IOException { - return privateKey; - } - - public String challenge() { - return challenge==null?"":challenge; - } - - public String[] notes() { - return notes; - } -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/Facade.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/Facade.java deleted file mode 100644 index a5c8c650..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/Facade.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.facade; - -import java.io.IOException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aaf.authz.cm.mapper.Mapper; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.layer.Result; - - -/** - * - * - */ -public interface Facade { - -///////////////////// STANDARD ELEMENTS ////////////////// - /** - * @param trans - * @param response - * @param result - */ - void error(AuthzTrans trans, HttpServletResponse response, Result result); - - /** - * - * @param trans - * @param response - * @param status - */ - void error(AuthzTrans trans, HttpServletResponse response, int status, String msg, String ... detail); - - /** - * Permission checker - * - * @param trans - * @param resp - * @param perm - * @return - * @throws IOException - */ - Result check(AuthzTrans trans, HttpServletResponse resp, String perm) throws IOException; - - /** - * - * @return - */ - public Mapper mapper(); - -///////////////////// STANDARD ELEMENTS ////////////////// - - /** - * - * @param trans - * @param resp - * @param rservlet - * @return - */ - public abstract Result requestCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, boolean withTrust); - - /** - * - * @param trans - * @param req - * @param resp - * @return - */ - public abstract Result renewCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, boolean withTrust); - - /** - * - * @param trans - * @param req - * @param resp - * @return - */ - public abstract Result dropCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp); - - /** - * - * @param trans - * @param req - * @param resp - * @return - */ - Result createArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp); - - /** - * - * @param trans - * @param req - * @param resp - * @return - */ - Result readArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp); - - /** - * - * @param trans - * @param resp - * @param mechid - * @param machine - * @return - */ - Result readArtifacts(AuthzTrans trans, HttpServletResponse resp, String mechid, String machine); - - /** - * - * @param trans - * @param req - * @param resp - * @return - */ - Result updateArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp); - - /** - * - * @param trans - * @param req - * @param resp - * @return - */ - Result deleteArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp); - - /** - * - * @param trans - * @param resp - * @param mechid - * @param machine - * @return - */ - Result deleteArtifacts(AuthzTrans trans, HttpServletResponse resp, String mechid, String machine); - - - -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/Facade1_0.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/Facade1_0.java deleted file mode 100644 index 525b38a1..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/Facade1_0.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.facade; - -import org.onap.aaf.authz.cm.mapper.Mapper; -import org.onap.aaf.authz.cm.service.CMService; -import org.onap.aaf.authz.cm.service.CertManAPI; - -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Data; - -import aaf.v2_0.Error; -import certman.v1_0.Artifacts; -import certman.v1_0.BaseRequest; -import certman.v1_0.CertInfo; - -/** - * - */ -public class Facade1_0 extends FacadeImpl { - public Facade1_0(CertManAPI certman, - CMService service, - Mapper mapper, - Data.TYPE type) throws APIException { - super(certman, service, mapper, type); - } -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/FacadeFactory.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/FacadeFactory.java deleted file mode 100644 index 0c19837f..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/FacadeFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.facade; - -import org.onap.aaf.authz.cm.mapper.Mapper1_0; -import org.onap.aaf.authz.cm.service.CMService; -import org.onap.aaf.authz.cm.service.CertManAPI; -import org.onap.aaf.authz.env.AuthzTrans; - -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Data; - - -public class FacadeFactory { - public static Facade1_0 v1_0(CertManAPI certman, AuthzTrans trans, CMService service, Data.TYPE type) throws APIException { - return new Facade1_0( - certman, - service, - new Mapper1_0(), - type); - } - -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/FacadeImpl.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/FacadeImpl.java deleted file mode 100644 index 468aacd9..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/FacadeImpl.java +++ /dev/null @@ -1,493 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.facade; - -import static org.onap.aaf.authz.layer.Result.ERR_ActionNotCompleted; -import static org.onap.aaf.authz.layer.Result.ERR_BadData; -import static org.onap.aaf.authz.layer.Result.ERR_ConflictAlreadyExists; -import static org.onap.aaf.authz.layer.Result.ERR_Denied; -import static org.onap.aaf.authz.layer.Result.ERR_NotFound; -import static org.onap.aaf.authz.layer.Result.ERR_NotImplemented; -import static org.onap.aaf.authz.layer.Result.ERR_Policy; -import static org.onap.aaf.authz.layer.Result.ERR_Security; -import static org.onap.aaf.authz.layer.Result.OK; - -import java.io.IOException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aaf.authz.cm.api.API_Cert; -import org.onap.aaf.authz.cm.ca.CA; -import org.onap.aaf.authz.cm.data.CertResp; -import org.onap.aaf.authz.cm.mapper.Mapper; -import org.onap.aaf.authz.cm.mapper.Mapper.API; -import org.onap.aaf.authz.cm.service.CMService; -import org.onap.aaf.authz.cm.service.CertManAPI; -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.layer.Result; -import org.onap.aaf.dao.aaf.cass.ArtiDAO; -import org.onap.aaf.dao.aaf.cass.Status; - -import org.onap.aaf.cadi.aaf.AAFPermission; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Data; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.Slot; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.util.Split; -import org.onap.aaf.rosetta.env.RosettaDF; -import org.onap.aaf.rosetta.env.RosettaData; - -/** - * AuthzFacade - * - * This Service Facade encapsulates the essence of the API Service can do, and provides - * a single created object for elements such as RosettaDF. - * - * The Responsibilities of this class are to: - * 1) Interact with the Service Implementation (which might be supported by various kinds of Backend Storage) - * 2) Validate incoming data (if applicable) - * 3) Convert the Service response into the right Format, and mark the Content Type - * a) In the future, we may support multiple Response Formats, aka JSON or XML, based on User Request. - * 4) Log Service info, warnings and exceptions as necessary - * 5) When asked by the API layer, this will create and write Error content to the OutputStream - * - * Note: This Class does NOT set the HTTP Status Code. That is up to the API layer, so that it can be - * clearly coordinated with the API Documentation - * - * - */ -public abstract class FacadeImpl extends org.onap.aaf.authz.layer.FacadeImpl implements Facade - { - private static final String REQUEST_CERT = "Request New Certificate"; - private static final String RENEW_CERT = "Renew Certificate"; - private static final String DROP_CERT = "Drop Certificate"; - private static final String CREATE_ARTIFACTS = "Create Deployment Artifact"; - private static final String READ_ARTIFACTS = "Read Deployment Artifact"; - private static final String UPDATE_ARTIFACTS = "Update Deployment Artifact"; - private static final String DELETE_ARTIFACTS = "Delete Deployment Artifact"; - - private CMService service; - - private final RosettaDF errDF; - private final RosettaDF certRequestDF, certRenewDF, certDropDF; - private final RosettaDF certDF; - private final RosettaDF artiDF; - private Mapper mapper; - private Slot sCertAuth; - private CertManAPI certman; - private final String voidResp; - - public FacadeImpl(CertManAPI certman, - CMService service, - Mapper mapper, - Data.TYPE dataType) throws APIException { - this.service = service; - this.mapper = mapper; - this.certman = certman; - AuthzEnv env = certman.env; - (errDF = env.newDataFactory(mapper.getClass(API.ERROR))).in(dataType).out(dataType); - (certRequestDF = env.newDataFactory(mapper.getClass(API.CERT_REQ))).in(dataType).out(dataType); - (certRenewDF = env.newDataFactory(mapper.getClass(API.CERT_RENEW))).in(dataType).out(dataType); - (certDropDF = env.newDataFactory(mapper.getClass(API.CERT_DROP))).in(dataType).out(dataType); - (certDF = env.newDataFactory(mapper.getClass(API.CERT))).in(dataType).out(dataType); - (artiDF = env.newDataFactory(mapper.getClass(API.ARTIFACTS))).in(dataType).out(dataType); - sCertAuth = env.slot(API_Cert.CERT_AUTH); - if(artiDF.getOutType().name().contains("xml")) { - voidResp = "application/Void+xml;charset=utf-8;version=1.0,application/xml;version=1.0,*/*"; - } else { - voidResp = "application/Void+json;charset=utf-8;version=1.0,application/json;version=1.0,*/*"; - } - } - - public Mapper mapper() { - return mapper; - } - - /* (non-Javadoc) - * @see com.att.authz.facade.AuthzFacade#error(org.onap.aaf.authz.env.AuthzTrans, javax.servlet.http.HttpServletResponse, int) - * - * Note: Conforms to AT&T TSS RESTful Error Structure - */ - @Override - public void error(AuthzTrans trans, HttpServletResponse response, Result result) { - error(trans, response, result.status, - result.details==null?"":result.details.trim(), - result.variables==null?new String[0]:result.variables); - } - - @Override - public void error(AuthzTrans trans, HttpServletResponse response, int status, final String _msg, final String ... _detail) { - String msgId; - String prefix; - switch(status) { - case 202: - case ERR_ActionNotCompleted: - msgId = "SVC1202"; - prefix = "Accepted, Action not complete"; - response.setStatus(/*httpstatus=*/202); - break; - - case 403: - case ERR_Policy: - case ERR_Security: - case ERR_Denied: - msgId = "SVC1403"; - prefix = "Forbidden"; - response.setStatus(/*httpstatus=*/403); - break; - - case 404: - case ERR_NotFound: - msgId = "SVC1404"; - prefix = "Not Found"; - response.setStatus(/*httpstatus=*/404); - break; - - case 406: - case ERR_BadData: - msgId="SVC1406"; - prefix = "Not Acceptable"; - response.setStatus(/*httpstatus=*/406); - break; - - case 409: - case ERR_ConflictAlreadyExists: - msgId = "SVC1409"; - prefix = "Conflict Already Exists"; - response.setStatus(/*httpstatus=*/409); - break; - - case 501: - case ERR_NotImplemented: - msgId = "SVC1501"; - prefix = "Not Implemented"; - response.setStatus(/*httpstatus=*/501); - break; - - - default: - msgId = "SVC1500"; - prefix = "General Service Error"; - response.setStatus(/*httpstatus=*/500); - break; - } - - try { - StringBuilder holder = new StringBuilder(); - errDF.newData(trans).load( - mapper().errorFromMessage(holder, msgId,prefix + ": " + _msg,_detail)).to(response.getOutputStream()); - - holder.append(']'); - trans.checkpoint( - "ErrResp [" + - holder, - Env.ALWAYS); - } catch (Exception e) { - trans.error().log(e,"unable to send response for",_msg); - } - } - - @Override - public Result check(AuthzTrans trans, HttpServletResponse resp, String perm) throws IOException { - String[] p = Split.split('|',perm); - if(p.length!=3) { - return Result.err(Result.ERR_BadData,"Invalid Perm String"); - } - AAFPermission ap = new AAFPermission(p[0],p[1],p[2]); - if(certman.aafLurPerm.fish(trans.getUserPrincipal(), ap)) { - resp.setContentType(voidResp); - resp.getOutputStream().write(0); - return Result.ok(); - } else { - return Result.err(Result.ERR_Denied,"%s does not have %s",trans.user(),ap.getKey()); - } - } - - /* (non-Javadoc) - * @see com.att.auth.certman.facade.Facade#requestCert(org.onap.aaf.authz.env.AuthzTrans, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) - */ - @Override - public Result requestCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, boolean withTrust) { - TimeTaken tt = trans.start(REQUEST_CERT, Env.SUB|Env.ALWAYS); - try { - REQ request; - try { - Data rd = certRequestDF.newData().load(req.getInputStream()); - request = rd.asObject(); - } catch(APIException e) { - trans.error().log("Invalid Input",IN,REQUEST_CERT); - return Result.err(Result.ERR_BadData,"Invalid Input"); - } - - Result rcr = service.requestCert(trans,mapper.toReq(trans,request)); - if(rcr.notOK()) { - return Result.err(rcr); - } - - CA certAuth = trans.get(sCertAuth,null); - Result rc = mapper.toCert(trans, rcr, withTrust?certAuth.getTrustChain():null); - switch(rc.status) { - case OK: - RosettaData data = certDF.newData(trans).load(rc.value); - data.to(resp.getOutputStream()); - - setContentType(resp,certDF.getOutType()); - return Result.ok(); - default: - return Result.err(rc); - } - - } catch (Exception e) { - trans.error().log(e,IN,REQUEST_CERT); - return Result.err(e); - } finally { - tt.done(); - } - } - - @Override - public Result renewCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, boolean withTrust) { - TimeTaken tt = trans.start(RENEW_CERT, Env.SUB|Env.ALWAYS); - try { - REQ request; - try { - Data rd = certRenewDF.newData().load(req.getInputStream()); - request = rd.asObject(); - } catch(APIException e) { - trans.error().log("Invalid Input",IN,RENEW_CERT); - return Result.err(Result.ERR_BadData,"Invalid Input"); - } - - String certAuth = trans.get(sCertAuth,null); - Result rcr = service.renewCert(trans,mapper.toRenew(trans,request)); - Result rc = mapper.toCert(trans, rcr, certman.getTrustChain(certAuth)); - - switch(rc.status) { - case OK: - RosettaData data = certDF.newData(trans).load(rc.value); - data.to(resp.getOutputStream()); - - setContentType(resp,certDF.getOutType()); - return Result.ok(); - default: - return Result.err(rc); - } - } catch (Exception e) { - trans.error().log(e,IN,RENEW_CERT); - return Result.err(e); - } finally { - tt.done(); - } - - } - - @Override - public Result dropCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) { - TimeTaken tt = trans.start(DROP_CERT, Env.SUB|Env.ALWAYS); - try { - REQ request; - try { - Data rd = certDropDF.newData().load(req.getInputStream()); - request = rd.asObject(); - } catch(APIException e) { - trans.error().log("Invalid Input",IN,DROP_CERT); - return Result.err(Result.ERR_BadData,"Invalid Input"); - } - - Result rv = service.dropCert(trans,mapper.toDrop(trans, request)); - switch(rv.status) { - case OK: - setContentType(resp,certRequestDF.getOutType()); - return Result.ok(); - default: - return Result.err(rv); - } - } catch (Exception e) { - trans.error().log(e,IN,DROP_CERT); - return Result.err(e); - } finally { - tt.done(); - } - } - - //////////////////////////// - // Artifacts - //////////////////////////// - @Override - public Result createArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) { - TimeTaken tt = trans.start(CREATE_ARTIFACTS, Env.SUB); - try { - ARTIFACTS arti; - try { - Data rd = artiDF.newData().load(req.getInputStream()); - arti = rd.asObject(); - } catch(APIException e) { - trans.error().log("Invalid Input",IN,CREATE_ARTIFACTS); - return Result.err(Result.ERR_BadData,"Invalid Input"); - } - - return service.createArtifact(trans,mapper.toArtifact(trans,arti)); - } catch (Exception e) { - - trans.error().log(e,IN,CREATE_ARTIFACTS); - return Result.err(e); - } finally { - tt.done(); - } - } - - @Override - public Result readArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) { - TimeTaken tt = trans.start(READ_ARTIFACTS, Env.SUB); - try { - String mechid = req.getParameter("mechid"); - String machine = req.getParameter("machine"); - - Result ra; - if( machine !=null && mechid == null) { - ra = mapper.fromArtifacts(service.readArtifactsByMachine(trans, machine)); - } else if(mechid!=null && machine==null) { - ra = mapper.fromArtifacts(service.readArtifactsByMechID(trans, mechid)); - } else if(mechid!=null && machine!=null) { - ArtiDAO.Data add = new ArtiDAO.Data(); - add.mechid = mechid; - add.machine = machine; - ra = mapper.fromArtifacts(service.readArtifacts(trans,add)); - } else { - ra = Result.err(Status.ERR_BadData,"Invalid request inputs"); - } - - if(ra.isOK()) { - RosettaData data = artiDF.newData(trans).load(ra.value); - data.to(resp.getOutputStream()); - setContentType(resp,artiDF.getOutType()); - return Result.ok(); - } else { - return Result.err(ra); - } - - } catch (Exception e) { - trans.error().log(e,IN,READ_ARTIFACTS); - return Result.err(e); - } finally { - tt.done(); - } - } - - @Override - public Result readArtifacts(AuthzTrans trans, HttpServletResponse resp, String mechid, String machine) { - TimeTaken tt = trans.start(READ_ARTIFACTS, Env.SUB); - try { - ArtiDAO.Data add = new ArtiDAO.Data(); - add.mechid = mechid; - add.machine = machine; - Result ra = mapper.fromArtifacts(service.readArtifacts(trans,add)); - if(ra.isOK()) { - RosettaData data = artiDF.newData(trans).load(ra.value); - data.to(resp.getOutputStream()); - setContentType(resp,artiDF.getOutType()); - return Result.ok(); - } else { - return Result.err(ra); - } - } catch (Exception e) { - trans.error().log(e,IN,READ_ARTIFACTS); - return Result.err(e); - } finally { - tt.done(); - } - } - - - @Override - public Result updateArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) { - TimeTaken tt = trans.start(UPDATE_ARTIFACTS, Env.SUB); - try { - ARTIFACTS arti; - try { - Data rd = artiDF.newData().load(req.getInputStream()); - arti = rd.asObject(); - } catch(APIException e) { - trans.error().log("Invalid Input",IN,UPDATE_ARTIFACTS); - return Result.err(Result.ERR_BadData,"Invalid Input"); - } - - return service.updateArtifact(trans,mapper.toArtifact(trans,arti)); - } catch (Exception e) { - trans.error().log(e,IN,UPDATE_ARTIFACTS); - return Result.err(e); - } finally { - tt.done(); - } - } - - @Override - public Result deleteArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) { - TimeTaken tt = trans.start(DELETE_ARTIFACTS, Env.SUB); - try { - ARTIFACTS arti; - try { - Data rd = artiDF.newData().load(req.getInputStream()); - arti = rd.asObject(); - } catch(APIException e) { - trans.error().log("Invalid Input",IN,DELETE_ARTIFACTS); - return Result.err(Result.ERR_BadData,"Invalid Input"); - } - - Result rv = service.deleteArtifact(trans,mapper.toArtifact(trans,arti)); - switch(rv.status) { - case OK: - setContentType(resp,artiDF.getOutType()); - } - return rv; - } catch (Exception e) { - trans.error().log(e,IN,DELETE_ARTIFACTS); - return Result.err(e); - } finally { - tt.done(); - } - } - - @Override - public Result deleteArtifacts(AuthzTrans trans, HttpServletResponse resp, String mechid, String machine) { - TimeTaken tt = trans.start(DELETE_ARTIFACTS, Env.SUB); - try { - Result rv = service.deleteArtifact(trans, mechid, machine); - switch(rv.status) { - case OK: - setContentType(resp,artiDF.getOutType()); - } - return rv; - } catch (Exception e) { - trans.error().log(e,IN,DELETE_ARTIFACTS); - return Result.err(e); - } finally { - tt.done(); - } - } - - -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/mapper/Mapper.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/mapper/Mapper.java deleted file mode 100644 index a04ac250..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/mapper/Mapper.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.mapper; - -import java.io.IOException; -import java.util.List; - -import org.onap.aaf.authz.cm.data.CertDrop; -import org.onap.aaf.authz.cm.data.CertRenew; -import org.onap.aaf.authz.cm.data.CertReq; -import org.onap.aaf.authz.cm.data.CertResp; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.layer.Result; -import org.onap.aaf.dao.aaf.cass.ArtiDAO; - -public interface Mapper -{ - public enum API{ERROR,VOID,CERT,CERT_REQ,CERT_RENEW,CERT_DROP,ARTIFACTS}; - - public Class getClass(API api); - public A newInstance(API api); - - public ERROR errorFromMessage(StringBuilder holder, String msgID, String text, String... detail); - - public Result toCert(AuthzTrans trans, Result in, String[] trustChain) throws IOException; - public Result toReq(AuthzTrans trans, REQ req); - public Result toRenew(AuthzTrans trans, REQ req); - public Result toDrop(AuthzTrans trans, REQ req); - - public List toArtifact(AuthzTrans trans, ARTIFACTS arti); - public Result fromArtifacts(Result> readArtifactsByMachine); -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/mapper/Mapper1_0.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/mapper/Mapper1_0.java deleted file mode 100644 index 2cb861c4..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/mapper/Mapper1_0.java +++ /dev/null @@ -1,246 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.mapper; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.onap.aaf.authz.cm.data.CertDrop; -import org.onap.aaf.authz.cm.data.CertRenew; -import org.onap.aaf.authz.cm.data.CertReq; -import org.onap.aaf.authz.cm.data.CertResp; -import org.onap.aaf.authz.cm.validation.Validator; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.layer.Result; -import org.onap.aaf.dao.aaf.cass.ArtiDAO; -import org.onap.aaf.dao.aaf.cass.ArtiDAO.Data; - -import aaf.v2_0.Error; -import certman.v1_0.Artifacts; -import certman.v1_0.Artifacts.Artifact; -import certman.v1_0.BaseRequest; -import certman.v1_0.CertInfo; -import certman.v1_0.CertificateDrop; -import certman.v1_0.CertificateRenew; -import certman.v1_0.CertificateRequest; - -import org.onap.aaf.cadi.aaf.v2_0.AAFCon; -import org.onap.aaf.cadi.util.Vars; - - -public class Mapper1_0 implements Mapper { - - @Override - public Class getClass(API api) { - switch(api) { - case CERT_REQ: return CertificateRequest.class; - case CERT_RENEW: return CertificateRenew.class; - case CERT_DROP: return CertificateDrop.class; - case CERT: return CertInfo.class; - case ARTIFACTS: return Artifacts.class; - case ERROR: return Error.class; - case VOID: return Void.class; - } - return null; - } - - @SuppressWarnings("unchecked") - @Override - public A newInstance(API api) { - switch(api) { - case CERT_REQ: return (A) new CertificateRequest(); - case CERT_RENEW: return (A) new CertificateRenew(); - case CERT_DROP: return (A) new CertificateDrop(); - case CERT: return (A) new CertInfo(); - case ARTIFACTS: return (A) new Artifacts(); - case ERROR: return (A)new Error(); - case VOID: return null; - } - return null; - } - - ////////////// Mapping Functions ///////////// - @Override - public Error errorFromMessage(StringBuilder holder, String msgID, String text, String... var) { - Error err = new Error(); - err.setMessageId(msgID); - // AT&T Restful Error Format requires numbers "%" placements - err.setText(Vars.convert(holder, text, var)); - for(String s : var) { - err.getVariables().add(s); - } - return err; - } - - /* (non-Javadoc) - * @see com.att.authz.certman.mapper.Mapper#toCert(org.onap.aaf.authz.env.AuthzTrans, org.onap.aaf.authz.layer.Result) - */ - @Override - public Result toCert(AuthzTrans trans, Result in, String[] trustChain) throws IOException { - if(in.isOK()) { - CertResp cin = in.value; - CertInfo cout = newInstance(API.CERT); - cout.setPrivatekey(cin.privateString()); - String value; - if((value=cin.challenge())!=null) { - cout.setChallenge(value); - } - cout.getCerts().add(cin.asCertString()); - if(trustChain!=null) { - for(String c : trustChain) { - cout.getCerts().add(c); - } - } - if(cin.notes()!=null) { - boolean first = true; - StringBuilder sb = new StringBuilder(); - for(String n : cin.notes()) { - if(first) { - first = false; - } else { - sb.append('\n'); - } - sb.append(n); - } - cout.setNotes(sb.toString()); - } - return Result.ok(cout); - } else { - return Result.err(in); - } - } - - /* (non-Javadoc) - * @see com.att.authz.certman.mapper.Mapper#toReq(org.onap.aaf.authz.env.AuthzTrans, java.lang.Object) - */ - @Override - public Result toReq(AuthzTrans trans, BaseRequest req) { - CertificateRequest in; - try { - in = (CertificateRequest)req; - } catch(ClassCastException e) { - return Result.err(Result.ERR_BadData,"Request is not a CertificateRequest"); - } - - CertReq out = new CertReq(); - Validator v = new Validator(); - if(v.isNull("CertRequest", req) - .nullOrBlank("MechID", out.mechid=in.getMechid()) - .nullBlankMin("FQDNs", out.fqdns=in.getFqdns(),1) - .err()) { - return Result.err(Result.ERR_BadData, v.errs()); - } - out.emails = in.getEmail(); - out.sponsor=in.getSponsor(); - out.start = in.getStart(); - out.end = in.getEnd(); - return Result.ok(out); - } - - /* (non-Javadoc) - * @see com.att.authz.certman.mapper.Mapper#toRenew(org.onap.aaf.authz.env.AuthzTrans, java.lang.Object) - */ - @Override - public Result toRenew(AuthzTrans trans, BaseRequest req) { - return Result.err(Result.ERR_NotImplemented,"Not Implemented... yet"); - } - - /* (non-Javadoc) - * @see com.att.authz.certman.mapper.Mapper#toDrop(org.onap.aaf.authz.env.AuthzTrans, java.lang.Object) - */ - @Override - public Result toDrop(AuthzTrans trans, BaseRequest req) { - return Result.err(Result.ERR_NotImplemented,"Not Implemented... yet"); - } - - /* (non-Javadoc) - * @see org.onap.aaf.authz.cm.mapper.Mapper#toArtifact(org.onap.aaf.authz.env.AuthzTrans, java.lang.Object) - */ - @Override - public List toArtifact(AuthzTrans trans, Artifacts artifacts) { - List ladd = new ArrayList(); - for(Artifact arti : artifacts.getArtifact()) { - ArtiDAO.Data data = new ArtiDAO.Data(); - data.mechid = arti.getMechid(); - data.machine = arti.getMachine(); - data.type(true).addAll(arti.getType()); - data.ca = arti.getCa(); - data.dir = arti.getDir(); - data.os_user = arti.getOsUser(); - // Optional (on way in) - data.appName = arti.getAppName(); - data.renewDays = arti.getRenewDays(); - data.notify = arti.getNotification(); - - // Ignored on way in for create/update - data.sponsor = arti.getSponsor(); - data.expires = null; - - // Derive Optional Data from Machine (Domain) if exists - if(data.machine!=null) { - if(data.ca==null) { - if(data.machine.endsWith(".att.com")) { - data.ca = "aaf"; // default - } - } - if(data.appName==null ) { - data.appName=AAFCon.reverseDomain(data.machine); - } - } - - ladd.add(data); - } - return ladd; - } - - /* (non-Javadoc) - * @see org.onap.aaf.authz.cm.mapper.Mapper#fromArtifacts(org.onap.aaf.authz.layer.Result) - */ - @Override - public Result fromArtifacts(Result> lArtiDAO) { - if(lArtiDAO.isOK()) { - Artifacts artis = new Artifacts(); - for(ArtiDAO.Data arti : lArtiDAO.value) { - Artifact a = new Artifact(); - a.setMechid(arti.mechid); - a.setMachine(arti.machine); - a.setSponsor(arti.sponsor); - a.setAppName(arti.appName); - a.setCa(arti.ca); - a.setDir(arti.dir); - a.getType().addAll(arti.type(false)); - a.setOsUser(arti.os_user); - a.setRenewDays(arti.renewDays); - a.setNotification(arti.notify); - artis.getArtifact().add(a); - } - return Result.ok(artis); - } else { - return Result.err(lArtiDAO); - } - } - - - -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/service/CMService.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/service/CMService.java deleted file mode 100644 index 9924973c..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/service/CMService.java +++ /dev/null @@ -1,515 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.service; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.nio.ByteBuffer; -import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.onap.aaf.authz.cm.api.API_Cert; -import org.onap.aaf.authz.cm.ca.CA; -import org.onap.aaf.authz.cm.cert.BCFactory; -import org.onap.aaf.authz.cm.cert.CSRMeta; -import org.onap.aaf.authz.cm.data.CertDrop; -import org.onap.aaf.authz.cm.data.CertRenew; -import org.onap.aaf.authz.cm.data.CertReq; -import org.onap.aaf.authz.cm.data.CertResp; -import org.onap.aaf.authz.cm.validation.Validator; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.layer.Result; -import org.onap.aaf.authz.org.Organization; -import org.onap.aaf.authz.org.OrganizationException; -import org.onap.aaf.authz.org.Organization.Identity; -import org.onap.aaf.dao.CassAccess; -import org.onap.aaf.dao.DAO; -import org.onap.aaf.dao.aaf.cass.ArtiDAO; -import org.onap.aaf.dao.aaf.cass.CacheInfoDAO; -import org.onap.aaf.dao.aaf.cass.CertDAO; -import org.onap.aaf.dao.aaf.cass.CredDAO; -import org.onap.aaf.dao.aaf.cass.HistoryDAO; -import org.onap.aaf.dao.aaf.cass.Status; -import org.onap.aaf.dao.aaf.hl.Question; - -import org.onap.aaf.cadi.Hash; -import org.onap.aaf.cadi.aaf.AAFPermission; -import org.onap.aaf.cadi.aaf.v2_0.AAFCon; -import org.onap.aaf.cadi.cm.Factory; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Slot; -import org.onap.aaf.inno.env.util.Chrono; -import com.datastax.driver.core.Cluster; - - -public class CMService { - // If we add more CAs, may want to parameterize - private static final int STD_RENEWAL = 30; - private static final int MAX_RENEWAL = 60; - private static final int MIN_RENEWAL = 10; - - public static final String REQUEST = "request"; - public static final String RENEW = "renew"; - public static final String DROP = "drop"; - public static final String SANS = "san"; - - private static final String[] NO_NOTES = new String[0]; - private Slot sCertAuth; - private final CertDAO certDAO; - private final CredDAO credDAO; - private final ArtiDAO artiDAO; - private DAO[] daos; - - @SuppressWarnings("unchecked") - public CMService(AuthzTrans trans, CertManAPI certman) throws APIException, IOException { - - sCertAuth = certman.env.slot(API_Cert.CERT_AUTH); - Cluster cluster; - try { - cluster = org.onap.aaf.dao.CassAccess.cluster(certman.env,null); - } catch (IOException e) { - throw new APIException(e); - } - - // jg 4/2015 SessionFilter unneeded... DataStax already deals with Multithreading well - - HistoryDAO hd = new HistoryDAO(trans, cluster, CassAccess.KEYSPACE); - CacheInfoDAO cid = new CacheInfoDAO(trans, hd); - certDAO = new CertDAO(trans, hd, cid); - credDAO = new CredDAO(trans, hd, cid); - artiDAO = new ArtiDAO(trans, hd, cid); - - daos =(DAO[]) new DAO[] { - hd,cid,certDAO,credDAO,artiDAO - }; - - // Setup Shutdown Hooks for Cluster and Pooled Sessions - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - for(DAO dao : daos) { - dao.close(trans); - } - -// sessionFilter.destroy(); - cluster.close(); - } - }); - } - - public Result requestCert(AuthzTrans trans,Result req) { - if(req.isOK()) { - CA ca = trans.get(sCertAuth, null); - if(ca==null) { - return Result.err(Result.err(Result.ERR_BadData, "Invalid Cert Authority requested")); - } - - // Allow only AAF CA without special permission - if(!ca.getName().equals("aaf") && !trans.fish( new AAFPermission(ca.getPermType(), ca.getName(), REQUEST))) { - return Result.err(Status.ERR_Denied, "'%s' does not have permission to request Certificates from Certificate Authority '%s'", - trans.user(),ca.getName()); - } - - List notes = null; - List fqdns; - String email = null; - - try { - Organization org = trans.org(); - - // Policy 1: Requests are only by Pre-Authorized Configurations - ArtiDAO.Data add = null; - try { - for(InetAddress ia : InetAddress.getAllByName(trans.ip())) { - Result> ra = artiDAO.read(trans, req.value.mechid,ia.getHostName()); - if(ra.isOKhasData()) { - add = ra.value.get(0); - break; - } - } - } catch (UnknownHostException e1) { - return Result.err(Result.ERR_BadData,"There is no host for %s",trans.ip()); - } - - if(add==null) { - return Result.err(Result.ERR_BadData,"There is no configuration for %s",req.value.mechid); - } - - // Policy 2: If Config marked as Expired, do not create or renew - Date now = new Date(); - if(add.expires!=null && now.after(add.expires)) { - return Result.err(Result.ERR_Policy,"Configuration for %s %s is expired %s",add.mechid,add.machine,Chrono.dateFmt.format(add.expires)); - } - - // Policy 3: MechID must be current - Identity muser = org.getIdentity(trans, add.mechid); - if(muser == null) { - return Result.err(Result.ERR_Policy,"MechID must exist in %s",org.getName()); - } - - // Policy 4: Sponsor must be current - Identity ouser = muser.owner(); - if(ouser==null) { - return Result.err(Result.ERR_Policy,"%s does not have a current sponsor at %s",add.mechid,org.getName()); - } else if(!ouser.isFound() || !ouser.isResponsible()) { - return Result.err(Result.ERR_Policy,"%s reports that %s cannot be responsible for %s",org.getName(),trans.user()); - } - - // Set Email from most current Sponsor - email = ouser.email(); - - // Policy 5: keep Artifact data current - if(!ouser.fullID().equals(add.sponsor)) { - add.sponsor = ouser.fullID(); - artiDAO.update(trans, add); - } - - // Policy 6: Requester must be granted Change permission in Namespace requested - String mechNS = AAFCon.reverseDomain(req.value.mechid); - if(mechNS==null) { - return Result.err(Status.ERR_Denied, "%s does not reflect a valid AAF Namespace",req.value.mechid); - } - - // Policy 7: Caller must be the MechID or have specifically delegated permissions - if(!trans.user().equals(req.value.mechid) && !trans.fish(new AAFPermission(mechNS + ".certman", ca.getName() , "request"))) { - return Result.err(Status.ERR_Denied, "%s must have access to modify x509 certs in NS %s",trans.user(),mechNS); - } - - - // Policy 8: SANs only allowed by Exception... need permission - fqdns = new ArrayList(); - fqdns.add(add.machine); // machine is first - if(req.value.fqdns.size()>1 && !trans.fish(new AAFPermission(ca.getPermType(), ca.getName(), SANS))) { - if(notes==null) {notes = new ArrayList();} - notes.add("Warning: Subject Alternative Names only allowed by Permission: Get CSO Exception. This Certificate will be created, but without SANs"); - } else { - for(String m : req.value.fqdns) { - if(!add.machine.equals(m)) { - fqdns.add(m); - } - } - } - - } catch (Exception e) { - trans.error().log(e); - return Result.err(Status.ERR_Denied,"MechID Sponsorship cannot be determined at this time. Try later"); - } - - CSRMeta csrMeta; - try { - csrMeta = BCFactory.createCSRMeta( - ca, - req.value.mechid, - email, - fqdns); - X509Certificate x509 = ca.sign(trans, csrMeta); - if(x509==null) { - return Result.err(Result.ERR_ActionNotCompleted,"x509 Certificate not signed by CA"); - } - CertDAO.Data cdd = new CertDAO.Data(); - cdd.ca=ca.getName(); - cdd.serial=x509.getSerialNumber(); - cdd.id=req.value.mechid; - cdd.x500=x509.getSubjectDN().getName(); - cdd.x509=Factory.toString(trans, x509); - certDAO.create(trans, cdd); - - CredDAO.Data crdd = new CredDAO.Data(); - crdd.other = Question.random.nextInt(); - crdd.cred=getChallenge256SaltedHash(csrMeta.challenge(),crdd.other); - crdd.expires = x509.getNotAfter(); - crdd.id = req.value.mechid; - crdd.ns = Question.domain2ns(crdd.id); - crdd.type = CredDAO.CERT_SHA256_RSA; - credDAO.create(trans, crdd); - - CertResp cr = new CertResp(trans,x509,csrMeta, compileNotes(notes)); - return Result.ok(cr); - } catch (Exception e) { - trans.error().log(e); - return Result.err(Result.ERR_ActionNotCompleted,e.getMessage()); - } - } else { - return Result.err(req); - } - } - - public Result renewCert(AuthzTrans trans, Result renew) { - if(renew.isOK()) { - return Result.err(Result.ERR_NotImplemented,"Not implemented yet"); - } else { - return Result.err(renew); - } - } - - public Result dropCert(AuthzTrans trans, Result drop) { - if(drop.isOK()) { - return Result.err(Result.ERR_NotImplemented,"Not implemented yet"); - } else { - return Result.err(drop); - } - } - - /////////////// - // Artifact - ////////////// - public Result createArtifact(AuthzTrans trans, List list) { - Validator v = new Validator().artisRequired(list, 1); - if(v.err()) { - return Result.err(Result.ERR_BadData,v.errs()); - } - for(ArtiDAO.Data add : list) { - try { - // Policy 1: MechID must exist in Org - Identity muser = trans.org().getIdentity(trans, add.mechid); - if(muser == null) { - return Result.err(Result.ERR_Denied,"%s is not valid for %s", add.mechid,trans.org().getName()); - } - - // Policy 2: MechID must have valid Organization Owner - Identity ouser = muser.owner(); - if(ouser == null) { - return Result.err(Result.ERR_Denied,"%s is not a valid Sponsor for %s at %s", - trans.user(),add.mechid,trans.org().getName()); - } - - // Policy 3: Calling ID must be MechID Owner - if(!trans.user().equals(ouser.fullID())) { - return Result.err(Result.ERR_Denied,"%s is not the Sponsor for %s at %s", - trans.user(),add.mechid,trans.org().getName()); - } - - // Policy 4: Renewal Days are between 10 and 60 (constants, may be parameterized) - if(add.renewDaysMAX_RENEWAL) { - add.renewDays = MAX_RENEWAL; - } - - // Policy 5: If Notify is blank, set to Owner's Email - if(add.notify==null || add.notify.length()==0) { - add.notify = "mailto:"+ouser.email(); - } - - // Set Sponsor from Golden Source - add.sponsor = ouser.fullID(); - - - } catch (OrganizationException e) { - return Result.err(e); - } - // Add to DB - Result rv = artiDAO.create(trans, add); - // TODO come up with Partial Reporting Scheme, or allow only one at a time. - if(rv.notOK()) { - return Result.err(rv); - } - } - return Result.ok(); - } - - public Result> readArtifacts(AuthzTrans trans, ArtiDAO.Data add) throws OrganizationException { - Validator v = new Validator().keys(add); - if(v.err()) { - return Result.err(Result.ERR_BadData,v.errs()); - } - String ns = AAFCon.reverseDomain(add.mechid); - - if( trans.user().equals(add.mechid) - || trans.fish(new AAFPermission(ns + ".access", "*", "read")) - || (trans.org().validate(trans,Organization.Policy.OWNS_MECHID,null,add.mechid))==null) { - return artiDAO.read(trans, add); - } else { - return Result.err(Result.ERR_Denied,"%s is not %s, is not the sponsor, and doesn't have delegated permission.",trans.user(),add.mechid); // note: reason is set by 2nd case, if 1st case misses - } - - } - - public Result> readArtifactsByMechID(AuthzTrans trans, String mechid) throws OrganizationException { - Validator v = new Validator().nullOrBlank("mechid", mechid); - if(v.err()) { - return Result.err(Result.ERR_BadData,v.errs()); - } - String ns = AAFCon.reverseDomain(mechid); - - String reason; - if(trans.fish(new AAFPermission(ns + ".access", "*", "read")) - || (reason=trans.org().validate(trans,Organization.Policy.OWNS_MECHID,null,mechid))==null) { - return artiDAO.readByMechID(trans, mechid); - } else { - return Result.err(Result.ERR_Denied,reason); // note: reason is set by 2nd case, if 1st case misses - } - - } - - public Result> readArtifactsByMachine(AuthzTrans trans, String machine) { - Validator v = new Validator().nullOrBlank("machine", machine); - if(v.err()) { - return Result.err(Result.ERR_BadData,v.errs()); - } - - // TODO do some checks? - - Result> rv = artiDAO.readByMachine(trans, machine); - return rv; - } - - public Result updateArtifact(AuthzTrans trans, List list) throws OrganizationException { - Validator v = new Validator().artisRequired(list, 1); - if(v.err()) { - return Result.err(Result.ERR_BadData,v.errs()); - } - - // Check if requesting User is Sponsor - //TODO - Shall we do one, or multiples? - for(ArtiDAO.Data add : list) { - // Policy 1: MechID must exist in Org - Identity muser = trans.org().getIdentity(trans, add.mechid); - if(muser == null) { - return Result.err(Result.ERR_Denied,"%s is not valid for %s", add.mechid,trans.org().getName()); - } - - // Policy 2: MechID must have valid Organization Owner - Identity ouser = muser.owner(); - if(ouser == null) { - return Result.err(Result.ERR_Denied,"%s is not a valid Sponsor for %s at %s", - trans.user(),add.mechid,trans.org().getName()); - } - - // Policy 3: Renewal Days are between 10 and 60 (constants, may be parameterized) - if(add.renewDaysMAX_RENEWAL) { - add.renewDays = MAX_RENEWAL; - } - - // Policy 4: Data is always updated with the latest Sponsor - // Add to Sponsor, to make sure we are always up to date. - add.sponsor = ouser.fullID(); - - // Policy 5: If Notify is blank, set to Owner's Email - if(add.notify==null || add.notify.length()==0) { - add.notify = "mailto:"+ouser.email(); - } - - // Policy 4: only Owner may update info - if(trans.user().equals(add.sponsor)) { - return artiDAO.update(trans, add); - } else { - return Result.err(Result.ERR_Denied,"%s may not update info for %s",trans.user(),muser.fullID()); - } - - } - return Result.err(Result.ERR_BadData,"No Artifacts to update"); - } - - public Result deleteArtifact(AuthzTrans trans, String mechid, String machine) throws OrganizationException { - Validator v = new Validator() - .nullOrBlank("mechid", mechid) - .nullOrBlank("machine", machine); - if(v.err()) { - return Result.err(Result.ERR_BadData,v.errs()); - } - - Result> rlad = artiDAO.read(trans, mechid, machine); - if(rlad.notOKorIsEmpty()) { - return Result.err(Result.ERR_NotFound,"Artifact for %s %s does not exist.",mechid,machine); - } - - return deleteArtifact(trans,rlad.value.get(0)); - } - - private Result deleteArtifact(AuthzTrans trans, ArtiDAO.Data add) throws OrganizationException { - // Policy 1: Record should be delete able only by Existing Sponsor. - String sponsor=null; - Identity muser = trans.org().getIdentity(trans, add.mechid); - if(muser != null) { - Identity ouser = muser.owner(); - if(ouser!=null) { - sponsor = ouser.fullID(); - } - } - // Policy 1.a: If Sponsorship is deleted in system of Record, then - // accept deletion by sponsor in Artifact Table - if(sponsor==null) { - sponsor = add.sponsor; - } - - String ns = AAFCon.reverseDomain(add.mechid); - - if(trans.fish(new AAFPermission(ns + ".access", "*", "write")) - || trans.user().equals(sponsor)) { - return artiDAO.delete(trans, add, false); - } - return null; - } - - public Result deleteArtifact(AuthzTrans trans, List list) { - Validator v = new Validator().artisRequired(list, 1); - if(v.err()) { - return Result.err(Result.ERR_BadData,v.errs()); - } - - try { - boolean partial = false; - Result result=null; - for(ArtiDAO.Data add : list) { - result = deleteArtifact(trans, add); - if(result.notOK()) { - partial = true; - } - } - if(result == null) { - result = Result.err(Result.ERR_BadData,"No Artifacts to delete"); - } else if(partial) { - result.partialContent(true); - } - return result; - } catch(Exception e) { - return Result.err(e); - } - } - - private String[] compileNotes(List notes) { - String[] rv; - if(notes==null) { - rv = NO_NOTES; - } else { - rv = new String[notes.size()]; - notes.toArray(rv); - } - return rv; - } - - private ByteBuffer getChallenge256SaltedHash(String challenge, int salt) throws NoSuchAlgorithmException { - ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE + challenge.length()); - bb.putInt(salt); - bb.put(challenge.getBytes()); - byte[] hash = Hash.hashSHA256(bb.array()); - return ByteBuffer.wrap(hash); - } -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/service/CertManAPI.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/service/CertManAPI.java deleted file mode 100644 index e802db21..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/service/CertManAPI.java +++ /dev/null @@ -1,285 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.service; - -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.TreeMap; - -import org.onap.aaf.authz.cm.api.API_Artifact; -import org.onap.aaf.authz.cm.api.API_Cert; -import org.onap.aaf.authz.cm.ca.CA; -import org.onap.aaf.authz.cm.facade.Facade1_0; -import org.onap.aaf.authz.cm.facade.FacadeFactory; -import org.onap.aaf.authz.cm.mapper.Mapper.API; -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.env.AuthzTransFilter; -import org.onap.aaf.authz.server.AbsServer; -import org.onap.aaf.cache.Cache; -import org.onap.aaf.cache.Cache.Dated; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import com.att.aft.dme2.api.DME2Exception; -//import com.att.aft.dme2.api.DME2FilterHolder; -//import com.att.aft.dme2.api.DME2FilterHolder.RequestDispatcherType; -import com.att.aft.dme2.api.DME2Manager; -import com.att.aft.dme2.api.DME2Server; -import com.att.aft.dme2.api.DME2ServerProperties; -import com.att.aft.dme2.api.DME2ServiceHolder; -import com.att.aft.dme2.api.util.DME2FilterHolder; -import com.att.aft.dme2.api.util.DME2FilterHolder.RequestDispatcherType; -import com.att.aft.dme2.api.util.DME2ServletHolder; -import org.onap.aaf.cadi.Access; -import org.onap.aaf.cadi.Access.Level; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.TrustChecker; -import org.onap.aaf.cadi.aaf.v2_0.AAFAuthn; -import org.onap.aaf.cadi.aaf.v2_0.AAFCon; -import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp; -import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm; -import org.onap.aaf.cadi.aaf.v2_0.AAFTrustChecker; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Data; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.Trans; -import org.onap.aaf.inno.env.util.Split; - -public class CertManAPI extends AbsServer { - - private static final String USER_PERMS = "userPerms"; - private static final Map certAuths = new TreeMap(); - private static final String AAF_CERTMAN_CA_PREFIX = null; - public Facade1_0 facade1_0; // this is the default Facade - public Facade1_0 facade1_0_XML; // this is the XML Facade - public Map cacheUser; - public AAFAuthn aafAuthn; - public AAFLurPerm aafLurPerm; - - private String[] EMPTY; - private AAFCon aafcon; - - /** - * Construct AuthzAPI with all the Context Supporting Routes that Authz needs - * - * @param env - * @param si - * @param dm - * @param decryptor - * @throws APIException - */ - public CertManAPI(AuthzEnv env) throws Exception { - super(env,"CertMan"); - env.setLog4JNames("log4j.properties","authz","cm","audit","init","trace"); - - //aafcon = new AAFConHttp(env); - - aafLurPerm = aafcon.newLur(); - // Note: If you need both Authn and Authz construct the following: - aafAuthn = aafcon.newAuthn(aafLurPerm); - - String aaf_env = env.getProperty(Config.AAF_ENV); - if(aaf_env==null) { - throw new APIException("aaf_env needs to be set"); - } - - // Initialize Facade for all uses - AuthzTrans trans = env.newTrans(); - - // Load Supported Certificate Authorities by property - for(String key : env.existingStaticSlotNames()) { - if(key.startsWith(AAF_CERTMAN_CA_PREFIX)) { - int idx = key.indexOf('.'); - String[] params = Split.split(';', env.getProperty(key)); - if(params.length>1) { - @SuppressWarnings("unchecked") - Class cac = (Class)Class.forName((String)params[0]); - Class ptype[] = new Class[params.length+1]; - ptype[0]=Trans.class; - ptype[1]=String.class; - Object pinst[] = new Object[params.length+1]; - pinst[0]=trans; - pinst[1]= key.substring(idx+1); - for(int i=1;i cons = cac.getConstructor(ptype); - CA ca = cons.newInstance(pinst); - certAuths.put(ca.getName(),ca); - } - } - } - if(certAuths.size()==0) { - throw new APIException("No Certificate Authorities have been configured in CertMan"); - } - - CMService service = new CMService(trans, this); - // note: Service knows how to shutdown Cluster on Shutdown, etc. See Constructor - facade1_0 = FacadeFactory.v1_0(this,trans, service,Data.TYPE.JSON); // Default Facade - facade1_0_XML = FacadeFactory.v1_0(this,trans,service,Data.TYPE.XML); - - - synchronized(env) { - if(cacheUser == null) { - cacheUser = Cache.obtain(USER_PERMS); - Cache.startCleansing(env, USER_PERMS); - Cache.addShutdownHook(); // Setup Shutdown Hook to close cache - } - } - - //////////////////////////////////////////////////////////////////////////// - // APIs - //////////////////////////////////////////////////////////////////////// - API_Cert.init(this); - API_Artifact.init(this); - - StringBuilder sb = new StringBuilder(); - trans.auditTrail(2, sb); - trans.init().log(sb); - } - - public CA getCA(String key) { - return certAuths.get(key); - } - - public String[] getTrustChain(String key) { - CA ca = certAuths.get(key); - if(ca==null) { - return EMPTY; - } else { - return ca.getTrustChain(); - } - } - - /** - * Setup XML and JSON implementations for each supported Version type - * - * We do this by taking the Code passed in and creating clones of these with the appropriate Facades and properties - * to do Versions and Content switches - * - */ - public void route(HttpMethods meth, String path, API api, Code code) throws Exception { - String version = "1.0"; - // Get Correct API Class from Mapper - Class respCls = facade1_0.mapper().getClass(api); - if(respCls==null) throw new Exception("Unknown class associated with " + api.getClass().getName() + ' ' + api.name()); - // setup Application API HTML ContentTypes for JSON and Route - String application = applicationJSON(respCls, version); - route(env,meth,path,code,application,"application/json;version="+version,"*/*"); - - // setup Application API HTML ContentTypes for XML and Route - application = applicationXML(respCls, version); - route(env,meth,path,code.clone(facade1_0_XML),application,"application/xml;version="+version); - - // Add other Supported APIs here as created - } - - public void routeAll(HttpMethods meth, String path, API api, Code code) throws Exception { - route(env,meth,path,code,""); // this will always match - } - - - /** - * Start up AuthzAPI as DME2 Service - * @param env - * @param props - * @throws DME2Exception - * @throws CadiException - */ - public void startDME2(Properties props) throws DME2Exception, CadiException { - DME2Manager dme2 = new DME2Manager("AAF Certman DME2Manager", props); - - - DME2ServiceHolder svcHolder; - List slist = new ArrayList(); - svcHolder = new DME2ServiceHolder(); - String serviceName = env.getProperty("DMEServiceName",null); - if(serviceName!=null) { - svcHolder.setServiceURI(serviceName); - svcHolder.setManager(dme2); - svcHolder.setContext("/"); - - - - DME2ServletHolder srvHolder = new DME2ServletHolder(this, new String[]{"/cert"}); - srvHolder.setContextPath("/*"); - slist.add(srvHolder); - - EnumSet edlist = EnumSet.of( - RequestDispatcherType.REQUEST, - RequestDispatcherType.FORWARD, - RequestDispatcherType.ASYNC - ); - - /////////////////////// - // Apply Filters - /////////////////////// - List flist = new ArrayList(); - - // Secure all GUI interactions with AuthzTransFilter - flist.add(new DME2FilterHolder( - new AuthzTransFilter(env,aafcon,TrustChecker.NOTRUST), - "/*", edlist)); - - - svcHolder.setFilters(flist); - svcHolder.setServletHolders(slist); - - DME2Server dme2svr = dme2.getServer(); - DME2ServerProperties dsprops = dme2svr.getServerProperties(); - dsprops.setGracefulShutdownTimeMs(1000); - - env.init().log("Starting AAF Certman Jetty/DME2 server..."); - dme2svr.start(); - try { -// if(env.getProperty("NO_REGISTER",null)!=null) - dme2.bindService(svcHolder); - env.init().log("DME2 is available as HTTP"+(dsprops.isSslEnable()?"/S":""),"on port:",dsprops.getPort()); - while(true) { // Per DME2 Examples... - Thread.sleep(5000); - } - } catch(InterruptedException e) { - env.init().log("AAF Jetty Server interrupted!"); - } catch(Exception e) { // Error binding service doesn't seem to stop DME2 or Process - env.init().log(e,"DME2 Initialization Error"); - dme2svr.stop(); - System.exit(1); - } - } else { - env.init().log("Properties must contain DMEServiceName"); - } - } - - public static void main(String[] args) { - setup(CertManAPI.class, "certman.props"); - - } - -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/service/Code.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/service/Code.java deleted file mode 100644 index 2e5e389f..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/service/Code.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.service; - -import org.onap.aaf.authz.cm.facade.Facade1_0; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.cssa.rserv.HttpCode; - -public abstract class Code extends HttpCode implements Cloneable { - - public Code(CertManAPI cma, String description, String ... roles) { - super(cma.facade1_0, description, roles); - // Note, the first "Code" will be created with default Facade, "JSON". - // use clone for another Code with XML - } - - - public D clone(Facade1_0 facade) throws Exception { - @SuppressWarnings("unchecked") - D d = (D)clone(); - d.context = facade; - return d; - } - -} diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/validation/Validator.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/validation/Validator.java deleted file mode 100644 index be9f7285..00000000 --- a/authz-certman/src/main/java/org/onap/aaf/authz/cm/validation/Validator.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.validation; - -import java.util.List; - -import org.onap.aaf.authz.layer.Result; -import org.onap.aaf.dao.aaf.cass.ArtiDAO; -import org.onap.aaf.dao.aaf.cass.ArtiDAO.Data; - -/** - * Validator - * Consistently apply content rules for content (incoming) - * - * Note: We restrict content for usability in URLs (because RESTful service), and avoid - * issues with Regular Expressions, and other enabling technologies. - * - */ -public class Validator { - // Repeated Msg fragments - private static final String MECHID = "mechid"; - private static final String MACHINE = "machine"; - private static final String ARTIFACT_LIST_IS_NULL = "Artifact List is null."; - private static final String Y = "y."; - private static final String IES = "ies."; - private static final String ENTR = " entr"; - private static final String MUST_HAVE_AT_LEAST = " must have at least "; - private static final String IS_NULL = " is null."; - private static final String ARTIFACTS_MUST_HAVE_AT_LEAST = "Artifacts must have at least "; - private StringBuilder msgs; - - public Validator nullOrBlank(String name, String str) { - if(str==null) { - msg(name + IS_NULL); - } else if(str.length()==0) { - msg(name + " is blank."); - } - return this; - } - - private void msg(String ... strs) { - if(msgs==null) { - msgs=new StringBuilder(); - } - for(String str : strs) { - msgs.append(str); - } - msgs.append('\n'); - } - - public boolean err() { - return msgs!=null; - } - - public String errs() { - return msgs.toString(); - } - - public Validator notOK(Result res) { - if(res==null) { - msgs.append("Result object is blank"); - } else if(res.notOK()) { - msgs.append(res.getClass().getSimpleName() + " is not OK"); - } - return this; - } - - public Validator isNull(String name, Object obj) { - if(obj==null) { - msg(name + IS_NULL); - } - return this; - } - - public Validator nullBlankMin(String name, List list, int min) { - if(list==null) { - msg(name + IS_NULL); - } else { - if(list.size() list, int min) { - if(list==null) { - msg(ARTIFACT_LIST_IS_NULL); - } else { - if(list.size() list, int min) { - if(list==null) { - msg(ARTIFACT_LIST_IS_NULL); - } else { - if(list.size() getNonCriticalExtensionOIDs() { - - return null; - } - - @Override - public byte[] getExtensionValue(String oid) { - - return null; - } - - @Override - public Set getCriticalExtensionOIDs() { - - return null; - } - - @Override - public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, - InvalidKeyException, NoSuchProviderException, SignatureException { - - - } - - @Override - public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, - NoSuchProviderException, SignatureException { - - - } - - @Override - public String toString() { - - return null; - } - - @Override - public PublicKey getPublicKey() { - - return null; - } - - @Override - public byte[] getEncoded() throws CertificateEncodingException { - - return null; - } - - @Override - public int getVersion() { - - return 0; - } - - @Override - public byte[] getTBSCertificate() throws CertificateEncodingException { - - return null; - } - - @Override - public boolean[] getSubjectUniqueID() { - - return null; - } - - @Override - public Principal getSubjectDN() { - - return null; - } - - @Override - public byte[] getSignature() { - - return null; - } - - @Override - public byte[] getSigAlgParams() { - - return null; - } - - @Override - public String getSigAlgOID() { - - return null; - } - - @Override - public String getSigAlgName() { - - return null; - } - - @Override - public BigInteger getSerialNumber() { - - return null; - } - - @Override - public Date getNotBefore() { - - return null; - } - - @Override - public Date getNotAfter() { - - return null; - } - - @Override - public boolean[] getKeyUsage() { - - return null; - } - - @Override - public boolean[] getIssuerUniqueID() { - - return null; - } - - @Override - public Principal getIssuerDN() { - - return null; - } - - @Override - public int getBasicConstraints() { - - return 0; - } - - @Override - public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException { - - - } - - @Override - public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException { - - } - }; - when(appCA.sign(Mockito.any(Trans.class), Mockito.any(CSRMeta.class))).thenReturn(cert); - certDAO = mock(CachedCertDAO.class, CALLS_REAL_METHODS); - } - - @Test - public void identity_True() throws CertificateException, IOException, CertException { - assertNotNull(appCA.sign(trans, csrMeta)); - } - - - @Test - public void identityNull() throws CertificateException { - try { - assertNotNull(appCA.sign(null, csrMeta)); - } catch (IOException e) { - - e.printStackTrace(); - } catch (CertException e) { - - e.printStackTrace(); - } - } - - @Test - public void identityBothNull() throws CertificateException { - try { - assertNotNull(appCA.sign(null, null)); - } catch (IOException e) { - - e.printStackTrace(); - } catch (CertException e) { - - e.printStackTrace(); - } - } - -} diff --git a/authz-certman/src/test/java/org/onap/aaf/authz/cm/ca/JU_DevlCA.java b/authz-certman/src/test/java/org/onap/aaf/authz/cm/ca/JU_DevlCA.java deleted file mode 100644 index b859bf72..00000000 --- a/authz-certman/src/test/java/org/onap/aaf/authz/cm/ca/JU_DevlCA.java +++ /dev/null @@ -1,287 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.ca; - -import static org.mockito.Mockito.CALLS_REAL_METHODS; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.junit.Assert.*; - -import java.io.IOException; -import java.math.BigInteger; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Principal; -import java.security.PublicKey; -import java.security.SignatureException; -import java.security.cert.CertificateEncodingException; -import java.security.cert.CertificateException; -import java.security.cert.CertificateExpiredException; -import java.security.cert.CertificateNotYetValidException; -import java.security.cert.X509Certificate; -import java.util.Date; -import java.util.Set; - -import javax.security.auth.x500.X500Principal; -import javax.servlet.http.HttpServletRequest; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.authz.cm.ca.DevlCA; -import org.onap.aaf.authz.cm.cert.CSRMeta; -import org.onap.aaf.dao.aaf.cached.CachedCertDAO; -import org.onap.aaf.dao.aaf.cass.CertDAO; - -import com.att.aft.dme2.api.http.HttpResponse; -import com.att.aft.dme2.request.HttpRequest; -import org.onap.aaf.cadi.cm.CertException; -import org.onap.aaf.inno.env.Trans; - - -@RunWith(MockitoJUnitRunner.class) -public class JU_DevlCA { - - @Mock - private static CachedCertDAO certDAO; - - @Mock - private static HttpServletRequest req; - - @Mock - private static CSRMeta csrMeta; - - static Trans trans; - - static X509Certificate cert; - static byte [] name = {1,23,4,54,6,56}; - - private static DevlCA devICA; - - @BeforeClass - public static void setUp() throws CertificateException, CertException, IOException { - String str = "core java api"; - byte[] b = str.getBytes(); - Principal prc = new X500Principal("CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US"); - req = mock(HttpServletRequest.class); - devICA = mock(DevlCA.class); - X509Certificate cert = new X509Certificate() { - - @Override - public boolean hasUnsupportedCriticalExtension() { - return false; - } - - @Override - public Set getNonCriticalExtensionOIDs() { - - return null; - } - - @Override - public byte[] getExtensionValue(String oid) { - - return null; - } - - @Override - public Set getCriticalExtensionOIDs() { - - return null; - } - - @Override - public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, - InvalidKeyException, NoSuchProviderException, SignatureException { - - - } - - @Override - public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, - NoSuchProviderException, SignatureException { - - - } - - @Override - public String toString() { - - return null; - } - - @Override - public PublicKey getPublicKey() { - - return null; - } - - @Override - public byte[] getEncoded() throws CertificateEncodingException { - - return null; - } - - @Override - public int getVersion() { - - return 0; - } - - @Override - public byte[] getTBSCertificate() throws CertificateEncodingException { - - return null; - } - - @Override - public boolean[] getSubjectUniqueID() { - - return null; - } - - @Override - public Principal getSubjectDN() { - - return null; - } - - @Override - public byte[] getSignature() { - - return null; - } - - @Override - public byte[] getSigAlgParams() { - - return null; - } - - @Override - public String getSigAlgOID() { - - return null; - } - - @Override - public String getSigAlgName() { - - return null; - } - - @Override - public BigInteger getSerialNumber() { - - return null; - } - - @Override - public Date getNotBefore() { - - return null; - } - - @Override - public Date getNotAfter() { - - return null; - } - - @Override - public boolean[] getKeyUsage() { - - return null; - } - - @Override - public boolean[] getIssuerUniqueID() { - - return null; - } - - @Override - public Principal getIssuerDN() { - - return null; - } - - @Override - public int getBasicConstraints() { - - return 0; - } - - @Override - public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException { - - - } - - @Override - public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException { - - } - }; - when(devICA.sign(Mockito.any(Trans.class), Mockito.any(CSRMeta.class))).thenReturn(cert); - certDAO = mock(CachedCertDAO.class, CALLS_REAL_METHODS); - } - - @Test - public void identity_True() throws CertificateException, IOException, CertException { - assertNotNull(devICA.sign(trans, csrMeta)); - } - - - @Test - public void identityNull() throws CertificateException { - try { - assertNotNull(devICA.sign(null, csrMeta)); - } catch (IOException e) { - - e.printStackTrace(); - } catch (CertException e) { - - e.printStackTrace(); - } - } - - @Test - public void identityBothNull() throws CertificateException { - try { - assertNotNull(devICA.sign(null, null)); - } catch (IOException e) { - - e.printStackTrace(); - } catch (CertException e) { - - e.printStackTrace(); - } - } - -} diff --git a/authz-certman/src/test/java/org/onap/aaf/authz/cm/cert/JU_BCFactory.java b/authz-certman/src/test/java/org/onap/aaf/authz/cm/cert/JU_BCFactory.java deleted file mode 100644 index 3435d490..00000000 --- a/authz-certman/src/test/java/org/onap/aaf/authz/cm/cert/JU_BCFactory.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.cert; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.security.Key; -import java.security.PrivateKey; -import java.security.PublicKey; - -import org.bouncycastle.operator.OperatorCreationException; -import org.bouncycastle.pkcs.PKCS10CertificationRequest; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.authz.cm.cert.BCFactory; - -import org.onap.aaf.cadi.cm.CertException; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; - -@RunWith(MockitoJUnitRunner.class) -public class JU_BCFactory { - - private static BCFactory bcFactory = new BCFactory(); - - private static BCFactory bcFact; - - private static PrivateKey pk; - - - private static Trans trans; - - - private static PKCS10CertificationRequest req; - - @BeforeClass - public static void setUp() throws IOException { - pk = new XYZKey(); - trans = mock(Trans.class); - req = mock(PKCS10CertificationRequest.class); - when(req.getEncoded()).thenReturn(new byte[1]); - when(trans.start(Mockito.anyString(), Mockito.anyInt())).thenReturn(new TimeTaken(null, 0) { - - @Override - public void output(StringBuilder sb) { - // TODO Auto-generated method stub - - } - }); - bcFact = mock(BCFactory.class); - } - - @Test - public void toStrin() throws OperatorCreationException, IOException, CertException { - assertNotNull(bcFactory.toString(trans, req)); - } - - @Test - public void toStrinMoc() throws OperatorCreationException, IOException, CertException { - assertNotNull(bcFact.toString(trans, req)); - } - - @Rule - public ExpectedException thrown= ExpectedException.none(); - - @Test - public void toCSR() { - try { - assertNotNull(bcFactory.toCSR(trans, new File("/random/path"))); - thrown.expect(FileNotFoundException.class); - } catch (IOException e) { - - e.printStackTrace(); - } - } - -} - -class XYZKey implements Key, PublicKey, PrivateKey { - - int rotValue; - public XYZKey() { - rotValue = 1200213; - } - public String getAlgorithm() { - return "XYZ"; - } - - public String getFormat() { - return "XYZ Special Format"; - } - - public byte[] getEncoded() { - byte b[] = new byte[4]; - b[3] = (byte) ((rotValue << 24) & 0xff); - b[2] = (byte) ((rotValue << 16) & 0xff); - b[1] = (byte) ((rotValue << 8) & 0xff); - b[0] = (byte) ((rotValue << 0) & 0xff); - return b; - } -} diff --git a/authz-certman/src/test/java/org/onap/aaf/authz/cm/cert/JU_CSRMeta.java b/authz-certman/src/test/java/org/onap/aaf/authz/cm/cert/JU_CSRMeta.java deleted file mode 100644 index da6b1984..00000000 --- a/authz-certman/src/test/java/org/onap/aaf/authz/cm/cert/JU_CSRMeta.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.cert; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; - -import java.io.IOException; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; - -import org.bouncycastle.asn1.x500.X500Name; -import org.bouncycastle.operator.OperatorCreationException; -import org.bouncycastle.pkcs.PKCS10CertificationRequest; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.authz.cm.cert.CSRMeta; - -import org.onap.aaf.cadi.cm.CertException; -import org.onap.aaf.inno.env.Trans; - -@RunWith(MockitoJUnitRunner.class) -public class JU_CSRMeta { - - private static CSRMeta csrmeta; - private static Trans trans; - private static PKCS10CertificationRequest req; - - @BeforeClass - public static void setUp() { - trans = mock(Trans.class); - csrmeta = new CSRMeta(); - csrmeta.cn("CN"); - csrmeta.email("pupleti@ht.com"); - csrmeta.mechID("HAKJH787"); - csrmeta.o("O"); - csrmeta.l("L"); - csrmeta.st("ST"); - csrmeta.c("C"); - csrmeta.challenge("Challenge"); - csrmeta.san("CA"); - } - - @Test - public void x500Name() throws IOException { - - X500Name x500 = csrmeta.x500Name(); - assertEquals(x500.toString(),"CN=CN,E=pupleti@ht.com,OU=HAKJH787,O=O,L=L,ST=ST,C=C"); - } - - @Test - public void initialConversationCert() throws CertificateException, OperatorCreationException, IOException { - X509Certificate cert = csrmeta.initialConversationCert(trans); - assertEquals(cert.getBasicConstraints(),-1); - } - - @Test - public void generateCSR() throws IOException, CertException { - req = csrmeta.generateCSR(trans); - assertNotNull(req); - } - - @Rule - public ExpectedException thrown= ExpectedException.none(); - - @Test - public void dump() throws IOException, CertException { - req = csrmeta.generateCSR(trans); - csrmeta.dump(req); - } - -} diff --git a/authz-certman/src/test/java/org/onap/aaf/authz/cm/data/JU_CertReq.java b/authz-certman/src/test/java/org/onap/aaf/authz/cm/data/JU_CertReq.java deleted file mode 100644 index 3ff3088c..00000000 --- a/authz-certman/src/test/java/org/onap/aaf/authz/cm/data/JU_CertReq.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.data; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.List; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.authz.cm.ca.CA; -import org.onap.aaf.authz.cm.cert.BCFactory; -import org.onap.aaf.authz.cm.cert.CSRMeta; -import org.onap.aaf.authz.cm.cert.StandardFields; -import org.onap.aaf.authz.cm.data.CertReq; - -import org.onap.aaf.cadi.cm.CertException; -import org.onap.aaf.inno.env.Trans; - -@RunWith(MockitoJUnitRunner.class) -public class JU_CertReq { - - private static BCFactory bcFact; - - private static CSRMeta value; - - private static CertReq req; - - @BeforeClass - public static void setUp() { - bcFact = mock(BCFactory.class); - value = mock(CSRMeta.class); - req = mock(CertReq.class); - - } - - @Test - public void getCSRMeta() throws CertException { - //req = new CertReq(); - req.mechid = "1213"; - List fqdnsas = new ArrayList(); - fqdnsas.add("String1"); - List emails = new ArrayList(); - emails.add("pupleti@hotmail.com"); - req.emails = emails; - req.fqdns = fqdnsas; - StandardFields sf = mock(StandardFields.class); - req.certAuthority = new CA("testName", sf, "ALL") { - - @Override - public X509Certificate sign(Trans trans, CSRMeta csrmeta) throws IOException, CertException { - - return null; - } - }; - req.sponsor = "asa@df.co"; - assertNull(req.getCSRMeta()); - } -} diff --git a/authz-certman/src/test/java/org/onap/aaf/authz/cm/facade/JU_FacadeImpl.java b/authz-certman/src/test/java/org/onap/aaf/authz/cm/facade/JU_FacadeImpl.java deleted file mode 100644 index 2f305bb4..00000000 --- a/authz-certman/src/test/java/org/onap/aaf/authz/cm/facade/JU_FacadeImpl.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.cm.facade; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.CALLS_REAL_METHODS; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.IOException; - -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.xml.namespace.QName; -import javax.xml.validation.Schema; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.authz.cm.facade.FacadeImpl; -import org.onap.aaf.authz.cm.mapper.Mapper; -import org.onap.aaf.authz.cm.service.CMService; -import org.onap.aaf.authz.cm.service.CertManAPI; -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.layer.Result; - -import org.onap.aaf.cadi.aaf.AAFPermission; -import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Data; -import org.onap.aaf.inno.env.LogTarget; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; -import org.onap.aaf.rosetta.env.RosettaDF; -import org.onap.aaf.rosetta.env.RosettaData; - - -@RunWith(MockitoJUnitRunner.class) -public class JU_FacadeImpl { - - private static AuthzTrans trans; - private static HttpServletResponse resp; - private static CertManAPI certman; - private static FacadeImpl hImpl; - private static CMService service; - private Mapper mapper; - private Data.TYPE dataType; - private static AuthzEnv env; - - private static FacadeImpl fImpl; - private static HttpServletRequest req; - - @Before - public void setUp() throws APIException, IOException { - fImpl = mock(FacadeImpl.class); - env = mock(AuthzEnv.class); - resp = mock(HttpServletResponse.class); - req = mock(HttpServletRequest.class); - hImpl = mock(FacadeImpl.class, CALLS_REAL_METHODS); - Result rvd = (Result) mock(Result.class); - trans = mock(AuthzTrans.class); - when(trans.error()).thenReturn(new LogTarget() { - - @Override - public void printf(String fmt, Object... vars) {} - - @Override - public void log(Throwable e, Object... msgs) { - e.getMessage(); - e.printStackTrace(); - msgs.toString(); - - } - - @Override - public void log(Object... msgs) { - } - - @Override - public boolean isLoggable() { - - return false; - } - }); - when(trans.start(Mockito.anyString(), Mockito.anyInt())).thenReturn(new TimeTaken("Now", 1) { - - @Override - public void output(StringBuilder sb) { - - } - }); - when(fImpl.check(Mockito.any(AuthzTrans.class), Mockito.any(HttpServletResponse.class), Mockito.anyString())).thenReturn(rvd); - when(resp.getOutputStream()).thenReturn(new ServletOutputStream() { - - @Override - public void write(int b) throws IOException { - - - } - }); - - } - - @Test - public void check() throws IOException { - AAFPermission ap = new AAFPermission("str1","str3","str2"); - String perms = ap.getInstance(); - assertNotNull(hImpl.check(trans, resp, perms)); - } - - @Test - public void checkNull() throws IOException { - AAFPermission ap = new AAFPermission(null,"Str3","str2"); - String perms = ap.getInstance(); - assertNotNull(hImpl.check(trans, resp, perms)); - } - - @Test - public void checkTwoNull() throws IOException { - AAFPermission ap = new AAFPermission(null,null,"str2"); - String perms = ap.getInstance(); - assertNotNull(fImpl.check(trans, resp, perms)); - } - - @Test - public void checkAllNull() throws IOException { - AAFPermission ap = new AAFPermission(null,null,null); - String perms = ap.getInstance(); - assertNotNull(fImpl.check(trans, resp, perms)); - } - - @Test - public void checkTrans_null() throws IOException { - AAFPermission ap = new AAFPermission("str1","str3","str2"); - String perms = ap.getInstance(); - assertNotNull(hImpl.check(null, resp, perms)); - } - - @Test - public void checkRespNull() throws IOException { - AAFPermission ap = new AAFPermission("str1","str3","str2"); - String perms = ap.getInstance(); - assertNotNull(hImpl.check(trans, null, perms)); - } - - @Test - public void requestCert() { - assertNotNull(hImpl.requestCert(trans, req, resp, true)); - } - - @Test - public void renewCert() { - assertNotNull(hImpl.renewCert(trans, req, resp, true)); - } - - @Test - public void dropCert() { - assertNotNull(hImpl.renewCert(trans, req, resp, true)); - } - - @Test - public void createArtifacts() { - assertNotNull(hImpl.createArtifacts(trans, req, resp)); - } - - @Test - public void readArtifacts() { - assertNotNull(hImpl.readArtifacts(trans, req, resp)); - } -} diff --git a/authz-cmd/aafcli.sh b/authz-cmd/aafcli.sh deleted file mode 100644 index 5d2f89ea..00000000 --- a/authz-cmd/aafcli.sh +++ /dev/null @@ -1,13 +0,0 @@ -DIR=`pwd` -#DME2REG=$DIR/../dme2reg -DME2REG=/opt/dme2reg -#CLASSPATH=etc:target/authz-cmd-1.0.0-SNAPSHOT-jar-with-dependencies.jar - -#java -cp $CLASSPATH \ - #-Dcadi_prop_files=../authz-service/src/main/sample/authAPI.props \ - #-DDME2_EP_REGISTRY_CLASS=DME2FS -DAFT_DME2_EP_REGISTRY_FS_DIR=$DME2REG \ - #com.att.cmd.AAFcli $* - -CLASSPATH=/opt/app/aaf/authz-service/etc:/opt/app/aaf/authz-service/lib/authz-cmd-1.0.1-SNAPSHOT-jar-with-dependencies.jar -#java -cp $CLASSPATH -Dcadi_prop_files=../authz-service/src/main/sample/authAPI.props -DDME2_EP_REGISTRY_CLASS=DME2FS -DAFT_DME2_EP_REGISTRY_FS_DIR=$DME2REG com.att.cmd.AAFcli $* -java -cp $CLASSPATH -Dcadi_prop_files=/opt/app/aaf/authz-service/etc/authAPI.props -DDME2_EP_REGISTRY_CLASS=DME2FS -DAFT_DME2_EP_REGISTRY_FS_DIR=$DME2REG org.onap.aaf.cmd.AAFcli $* diff --git a/authz-cmd/etc/log4j.properties b/authz-cmd/etc/log4j.properties deleted file mode 100644 index fcd9da85..00000000 --- a/authz-cmd/etc/log4j.properties +++ /dev/null @@ -1,54 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START==================================================== -# * org.onap.aaf -# * =========================================================================== -# * Copyright © 2017 AT&T Intellectual Property. All rights reserved. -# * =========================================================================== -# * Licensed under the Apache License, Version 2.0 (the "License"); -# * you may not use this file except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# * ============LICENSE_END==================================================== -# * -# * ECOMP is a trademark and service mark of AT&T Intellectual Property. -# * -#------------------------------------------------------------------------------- -############################################################################### -# Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. -############################################################################### -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -log4j.appender.SVR=org.apache.log4j.RollingFileAppender -log4j.appender.SVR.File=${user.home}/.aaf/authz-cmd.log -log4j.appender.SVR.MaxFileSize=10000KB -log4j.appender.SVR.MaxBackupIndex=1 -log4j.appender.SVR.layout=org.apache.log4j.PatternLayout -log4j.appender.SVR.layout.ConversionPattern=%d %p [%c] %m %n - -# General Apache libraries -log4j.rootLogger=WARN,SVR - diff --git a/authz-cmd/pom.xml b/authz-cmd/pom.xml deleted file mode 100644 index 130b8644..00000000 --- a/authz-cmd/pom.xml +++ /dev/null @@ -1,254 +0,0 @@ - - - - 4.0.0 - - org.onap.aaf.authz - parent - 1.0.1-SNAPSHOT - ../pom.xml - - - authz-cmd - Authz Command - Command Line Processor for Authz - jar - https://github.com/att/AAF - - - - Jonathan Gathman - - ATT - - - - - - false - 21 - 1.0.0-SNAPSHOT - - 0.7.7.201606060606 - 3.2 - jacoco - - target/code-coverage/jacoco-ut.exec - target/code-coverage/jacoco-it.exec - - **/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/** - https://nexus.onap.org - /content/repositories/snapshots/ - /content/repositories/releases/ - /content/repositories/staging/ - /content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version} - - - - - org.onap.aaf.cadi - cadi-aaf - ${project.cadiVersion} - - - - org.onap.aaf.authz - authz-core - ${project.version} - - - - jline - jline - 2.14.2 - - - - org.slf4j - slf4j-log4j12 - - - - - - - - maven-assembly-plugin - 2.4 - - tests - - - true - - - - - - full - package - - single - - - - src/main/assemble/authz-cmd.xml - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.4 - - false - - - - attach-javadocs - - jar - - - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ${nexusproxy} - 176c31dfe190a - ecomp-staging - - - - org.jacoco - jacoco-maven-plugin - ${jacoco.version} - - - **/gen/** - **/generated-sources/** - **/yang-gen/** - **/pax/** - - - - - - pre-unit-test - - prepare-agent - - - ${project.build.directory}/code-coverage/jacoco-ut.exec - surefireArgLine - - - - - - post-unit-test - test - - report - - - ${project.build.directory}/code-coverage/jacoco-ut.exec - ${project.reporting.outputDirectory}/jacoco-ut - - - - pre-integration-test - pre-integration-test - - prepare-agent - - - ${project.build.directory}/code-coverage/jacoco-it.exec - - failsafeArgLine - - - - - - post-integration-test - post-integration-test - - report - - - ${project.build.directory}/code-coverage/jacoco-it.exec - ${project.reporting.outputDirectory}/jacoco-it - - - - - - - - - - - - - - ecomp-releases - AAF Release Repository - ${nexusproxy}${releaseNexusPath} - - - ecomp-snapshots - AAF Snapshot Repository - ${nexusproxy}${snapshotNexusPath} - - - ecomp-site - dav:${nexusproxy}${sitePath} - - - - diff --git a/authz-cmd/src/main/assemble/authz-cmd.xml b/authz-cmd/src/main/assemble/authz-cmd.xml deleted file mode 100644 index c1f2ad6f..00000000 --- a/authz-cmd/src/main/assemble/authz-cmd.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - jar-with-dependencies - - jar - - - false - - - true - compile - - - - - - src/main/xsd - - - etc - - - diff --git a/authz-cmd/src/main/assemble/swm.xml b/authz-cmd/src/main/assemble/swm.xml deleted file mode 100644 index f2e86838..00000000 --- a/authz-cmd/src/main/assemble/swm.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - swm - - zip - - ${artifactId} - - - target/swm - - - diff --git a/authz-cmd/src/main/config/log4j.properties b/authz-cmd/src/main/config/log4j.properties deleted file mode 100644 index fcd9da85..00000000 --- a/authz-cmd/src/main/config/log4j.properties +++ /dev/null @@ -1,54 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START==================================================== -# * org.onap.aaf -# * =========================================================================== -# * Copyright © 2017 AT&T Intellectual Property. All rights reserved. -# * =========================================================================== -# * Licensed under the Apache License, Version 2.0 (the "License"); -# * you may not use this file except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# * ============LICENSE_END==================================================== -# * -# * ECOMP is a trademark and service mark of AT&T Intellectual Property. -# * -#------------------------------------------------------------------------------- -############################################################################### -# Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. -############################################################################### -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -log4j.appender.SVR=org.apache.log4j.RollingFileAppender -log4j.appender.SVR.File=${user.home}/.aaf/authz-cmd.log -log4j.appender.SVR.MaxFileSize=10000KB -log4j.appender.SVR.MaxBackupIndex=1 -log4j.appender.SVR.layout=org.apache.log4j.PatternLayout -log4j.appender.SVR.layout.ConversionPattern=%d %p [%c] %m %n - -# General Apache libraries -log4j.rootLogger=WARN,SVR - diff --git a/authz-cmd/src/main/config/logging.props b/authz-cmd/src/main/config/logging.props deleted file mode 100644 index 4d0f0f10..00000000 --- a/authz-cmd/src/main/config/logging.props +++ /dev/null @@ -1,38 +0,0 @@ -| ############################################################ -# Default Logging Configuration File -# -# You can use a different file by specifying a filename -# with the java.util.logging.config.file system property. -# For example java -Djava.util.logging.config.file=myfile -############################################################ - -############################################################ -# Global properties -############################################################ - -# "handlers" specifies a comma separated list of log Handler -# classes. These handlers will be installed during VM startup. -# Note that these classes must be on the system classpath. -# By default we only configure a ConsoleHandler, which will only -# show messages at the INFO and above levels. -handlers=java.util.logging.FileHandler - -# Default global logging level. -# This specifies which kinds of events are logged across -# all loggers. For any given facility this global level -# can be overriden by a facility specific level -# Note that the ConsoleHandler also has a separate level -# setting to limit messages printed to the console. -.level=INFO - -############################################################ -# Handler specific properties. -# Describes specific configuration info for Handlers. -############################################################ -java.util.logging.FileHandler.properties=autoFlush,fileName,dataPattern,name -java.util.logging.FileHandler.fileName=%h/.aaf/dme2.log -java.util.logging.FileHandlerFileHandler.autoFlush=true -java.util.logging.FileHandlerFileHandler.name=DailyRollingFileHandler -java.util.logging.FileHandlerFileHandler.datePattern='.'yyyy-MM-dd -com.att.aft.dme2.events.server.summary=WARN - diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/AAFcli.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/AAFcli.java deleted file mode 100644 index 5e0c8023..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/AAFcli.java +++ /dev/null @@ -1,722 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd; - -import java.io.BufferedReader; -import java.io.Console; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.Reader; -import java.io.Writer; -import java.net.HttpURLConnection; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import org.apache.log4j.PropertyConfigurator; -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.cmd.mgmt.Mgmt; -import org.onap.aaf.cmd.ns.NS; -import org.onap.aaf.cmd.perm.Perm; -import org.onap.aaf.cmd.role.Role; -import org.onap.aaf.cmd.user.User; - -import com.att.aft.dme2.api.DME2Manager; -import org.onap.aaf.cadi.Access.Level; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.Locator; -import org.onap.aaf.cadi.SecuritySetter; -import org.onap.aaf.cadi.client.PropertyLocator; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.config.SecurityInfo; -import org.onap.aaf.cadi.config.SecurityInfoC; -import org.onap.aaf.cadi.dme2.DME2Locator; -import org.onap.aaf.cadi.filter.AccessGetter; -import org.onap.aaf.cadi.http.HBasicAuthSS; -import org.onap.aaf.cadi.http.HMangr; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.impl.Log4JLogTarget; -import org.onap.aaf.inno.env.util.Split; - -import jline.console.ConsoleReader; - -public class AAFcli { - - public static final String AAF_DEFAULT_REALM = "aaf_default_realm"; - protected static PrintWriter pw; - protected HMangr hman; - // Storage for last reused client. We can do this - // because we're technically "single" threaded calls. - public Retryable prevCall; - - protected SecuritySetter ss; - protected AuthzEnv env; - private boolean close; - private List cmds; - - // Lex State - private ArrayList expect = new ArrayList(); - private boolean verbose = true; - private int delay; - private SecurityInfo si; - private boolean request = false; - private String force = null; - private boolean gui = false; - - private static int TIMEOUT = Integer.parseInt(Config.AAF_CONN_TIMEOUT_DEF); - private static boolean isConsole = false; - private static boolean isTest = false; - private static boolean showDetails = false; - private static boolean ignoreDelay = false; - private static int globalDelay=0; - - public static int timeout() { - return TIMEOUT; - } - - public AAFcli(AuthzEnv env, Writer wtr, HMangr hman, SecurityInfo si, SecuritySetter ss) throws APIException { - this.env = env; - this.ss = ss; - this.hman = hman; - this.si = si; - if (wtr instanceof PrintWriter) { - pw = (PrintWriter) wtr; - close = false; - } else { - pw = new PrintWriter(wtr); - close = true; - } - - - // client = new DRcli(new URI(aafurl), new - // BasicAuth(user,toPass(pass,true))) - // .apiVersion("2.0") - // .timeout(TIMEOUT); - - /* - * Create Cmd Tree - */ - cmds = new ArrayList(); - - Role role = new Role(this); - cmds.add(new Help(this, cmds)); - cmds.add(new Version(this)); - cmds.add(new Perm(role)); - cmds.add(role); - cmds.add(new User(this)); - cmds.add(new NS(this)); - cmds.add(new Mgmt(this)); - } - - public void verbose(boolean v) { - verbose = v; - } - - public void close() { - if (hman != null) { - hman.close(); - hman = null; - } - if (close) { - pw.close(); - } - } - - public boolean eval(String line) throws Exception { - if (line.length() == 0) { - return true; - } else if (line.startsWith("#")) { - pw.println(line); - return true; - } - - String[] largs = argEval(line); - int idx = 0; - - // Variable replacement - StringBuilder sb = null; - while (idx < largs.length) { - int e = 0; - for (int v = largs[idx].indexOf("@["); v >= 0; v = largs[idx].indexOf("@[", v + 1)) { - if (sb == null) { - sb = new StringBuilder(); - } - sb.append(largs[idx], e, v); - if ((e = largs[idx].indexOf(']', v)) >= 0) { - String p = env.getProperty(largs[idx].substring(v + 2, e++)); - if (p != null) { - sb.append(p); - } - } - } - if (sb != null && sb.length() > 0) { - sb.append(largs[idx], e, largs[idx].length()); - largs[idx] = sb.toString(); - sb.setLength(0); - } - ++idx; - } - - idx = 0; - boolean rv = true; - while (rv && idx < largs.length) { - // Allow Script to change Credential - if (!gui) { - if("as".equalsIgnoreCase(largs[idx])) { - if (largs.length > ++idx) { - // get Password from Props with ID as Key - String user = largs[idx++]; - int colon = user.indexOf(':'); - String pass; - if (colon > 0) { - pass = user.substring(colon + 1); - user = user.substring(0, colon); - } else { - pass = env.getProperty(user); - } - - if (pass != null) { - pass = env.decrypt(pass, false); - env.setProperty(user, pass); - ss = new HBasicAuthSS(user, pass,(SecurityInfoC) si); - pw.println("as " + user); - } else { // get Pass from System Properties, under name of - // Tag - pw.println("ERROR: No password set for " + user); - rv = false; - } - continue; - } - } else if ("expect".equalsIgnoreCase(largs[idx])) { - expect.clear(); - if (largs.length > idx++) { - if (!"nothing".equals(largs[idx])) { - for (String str : largs[idx].split(",")) { - try { - if ("Exception".equalsIgnoreCase(str)) { - expect.add(-1); - } else { - expect.add(Integer.parseInt(str)); - } - } catch (NumberFormatException e) { - throw new CadiException("\"expect\" should be followed by Number"); - } - } - ++idx; - } - } - continue; - // Sleep, typically for reports, to allow DB to update - // Milliseconds - - } else if ("sleep".equalsIgnoreCase(largs[idx])) { - Integer t = Integer.parseInt(largs[++idx]); - pw.println("sleep " + t); - Thread.sleep(t); - ++idx; - continue; - } else if ("delay".equalsIgnoreCase(largs[idx])) { - delay = Integer.parseInt(largs[++idx]); - pw.println("delay " + delay); - ++idx; - continue; - } else if ("pause".equalsIgnoreCase(largs[idx])) { - pw.println("Press to continue..."); - ++idx; - new BufferedReader(new InputStreamReader(System.in)).readLine(); - continue; - } else if ("exit".equalsIgnoreCase(largs[idx])) { - pw.println("Exiting..."); - return false; - } - - } - - if("REQUEST".equalsIgnoreCase(largs[idx])) { - request=true; - ++idx; - } else if("FORCE".equalsIgnoreCase(largs[idx])) { - force="true"; - ++idx; - } else if ("set".equalsIgnoreCase(largs[idx])) { - while (largs.length > ++idx) { - int equals = largs[idx].indexOf('='); - if (equals < 0) { - break; - } - String tag = largs[idx].substring(0, equals); - String value = largs[idx].substring(++equals); - pw.println("set " + tag + ' ' + value); - boolean isTrue = "TRUE".equalsIgnoreCase(value); - if("FORCE".equalsIgnoreCase(tag)) { - force = value; - } else if("REQUEST".equalsIgnoreCase(tag)) { - request = isTrue; - } else if("DETAILS".equalsIgnoreCase(tag)) { - showDetails = isTrue; - } else { - env.setProperty(tag, value); - } - } - continue; - // Allow Script to indicate if Failure is what is expected - } - - int ret = 0; - for (Cmd c : cmds) { - if (largs[idx].equalsIgnoreCase(c.getName())) { - if (verbose) { - pw.println(line); - if (expect.size() > 0) { - pw.print("** Expect "); - boolean first = true; - for (Integer i : expect) { - if (first) { - first = false; - } else { - pw.print(','); - } - pw.print(i); - } - pw.println(" **"); - } - } - try { - ret = c.exec(++idx, largs); - if (delay+globalDelay > 0) { - Thread.sleep(delay+globalDelay); - } - } catch (Exception e) { - if (expect.contains(-1)) { - pw.println(e.getMessage()); - ret = -1; - } else { - throw e; - } - } finally { - clearSingleLineProperties(); - } - rv = expect.isEmpty() ? true : expect.contains(ret); - if (verbose) { - if (rv) { - pw.println(); - } else { - pw.print("!!! Unexpected Return Code: "); - pw.print(ret); - pw.println(", VALIDATE OUTPUT!!!"); - } - } - return rv; - } - } - pw.write("Unknown Instruction \""); - pw.write(largs[idx]); - pw.write("\"\n"); - idx = largs.length;// always end after one command - } - return rv; - } - - private String[] argEval(String line) { - StringBuilder sb = new StringBuilder(); - ArrayList arr = new ArrayList(); - boolean start = true; - char quote = 0; - for (int i = 0; i < line.length(); ++i) { - char ch; - if (Character.isWhitespace(ch = line.charAt(i))) { - if (start) { - continue; // trim - } else if (quote != 0) { - sb.append(ch); - } else { - arr.add(sb.toString()); - sb.setLength(0); - start = true; - } - } else if (ch == '\'' || ch == '"') { // toggle - if (quote == ch) { - quote = 0; - } else { - quote = ch; - } - } else { - start = false; - sb.append(ch); - } - } - if (sb.length() > 0) { - arr.add(sb.toString()); - } - - String[] rv = new String[arr.size()]; - arr.toArray(rv); - return rv; - } - - public static void keyboardHelp() { - System.out.println("'C-' means hold the ctrl key down while pressing the next key."); - System.out.println("'M-' means hold the alt key down while pressing the next key."); - System.out.println("For instance, C-b means hold ctrl key and press b, M-b means hold alt and press b\n"); - - System.out.println("Basic Keybindings:"); - System.out.println("\tC-l - clear screen"); - System.out.println("\tC-a - beginning of line"); - System.out.println("\tC-e - end of line"); - System.out.println("\tC-b - backward character (left arrow also works)"); - System.out.println("\tM-b - backward word"); - System.out.println("\tC-f - forward character (right arrow also works)"); - System.out.println("\tM-f - forward word"); - System.out.println("\tC-d - delete character under cursor"); - System.out.println("\tM-d - delete word forward"); - System.out.println("\tM-backspace - delete word backward"); - System.out.println("\tC-k - delete from cursor to end of line"); - System.out.println("\tC-u - delete entire line, regardless of cursor position\n"); - - System.out.println("Command History:"); - System.out.println("\tC-r - search backward in history (repeating C-r continues the search)"); - System.out.println("\tC-p - move backwards through history (up arrow also works)"); - System.out.println("\tC-n - move forwards through history (down arrow also works)\n"); - - } - - /** - * @param args - */ - public static void main(String[] args) { - int rv = 0; - // Cover for bash's need to escape *... (\\*) - for (int i = 0; i < args.length; ++i) { - if ("\\*".equals(args[i])) { - args[i] = "*"; - } - } - - System.setProperty("java.util.logging.config.file", "etc/logging.props"); - final AuthzEnv env = new AuthzEnv(System.getProperties()); - - // Stop the (exceedingly annoying) DME2/other logs from printing console - InputStream is; - - // Load Log4j too... sigh - is = ClassLoader.getSystemResourceAsStream("log4j.properties"); - if(is==null) { - env.log(Level.WARN, "Cannot find 'log4j.properties' in Classpath. Best option: add 'etc' directory to classpath"); - } else { - try { - Properties props = new Properties(); - props.load(is); - PropertyConfigurator.configure(props); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - is.close(); - } catch (IOException e) { - env.debug().log(e); // only logging to avoid Sonar False positives. - } - } - } - - env.loadFromSystemPropsStartsWith("AFT", "DME2", "aaf", "keyfile"); - try { - Log4JLogTarget.setLog4JEnv("aaf", env); - GetProp gp = new GetProp(env); - String user = gp.get(false,Config.AAF_MECHID,"fully qualified id"); - String pass = gp.get(true, Config.AAF_MECHPASS, "password is hidden"); - if(env.getProperty(Config.AAF_URL)==null) { - String p = env.getProperty("DMEServiceName"); - if(p!=null) { - boolean https = "true".equalsIgnoreCase(env.getProperty("AFT_DME2_SSL_ENABLE")); - env.setProperty(Config.AAF_URL, "http"+(https?"s":"")+"://DME2RESOLVE/"+p); - } - } - String aafUrl = gp.get(false, Config.AAF_URL, "https://DME2RESOLVE or Direct URL:port"); - - if(aafUrl!=null && aafUrl.contains("//DME2")) { - //gp.set(Config.AFT_LATITUDE,"Lookup from a Map App or table"); - //gp.set(Config.AFT_LONGITUDE,"Lookup from a Map App or table"); - //gp.set(Config.AFT_ENVIRONMENT,"Check DME2 Installations"); - } - - if (gp.err() != null) { - gp.err().append("to continue..."); - System.err.println(gp.err()); - System.exit(1); - } - - - Reader rdr = null; - boolean exitOnFailure = true; - /* - * Check for "-" options anywhere in command line - */ - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < args.length; ++i) { - if ("-i".equalsIgnoreCase(args[i])) { - rdr = new InputStreamReader(System.in); - // } else if("-o".equalsIgnoreCase(args[i])) { - // // shall we do something different? Output stream is - // already done... - } else if ("-f".equalsIgnoreCase(args[i])) { - if (args.length > i + 1) { - rdr = new FileReader(args[++i]); - } - } else if ("-a".equalsIgnoreCase(args[i])) { - exitOnFailure = false; - } else if ("-c".equalsIgnoreCase(args[i])) { - isConsole = true; - } else if ("-s".equalsIgnoreCase(args[i]) && args.length > i + 1) { - env.setProperty(Cmd.STARTDATE, args[++i]); - } else if ("-e".equalsIgnoreCase(args[i]) && args.length > i + 1) { - env.setProperty(Cmd.ENDDATE, args[++i]); - } else if ("-t".equalsIgnoreCase(args[i])) { - isTest = true; - } else if ("-d".equalsIgnoreCase(args[i])) { - showDetails = true; - } else if ("-n".equalsIgnoreCase(args[i])) { - ignoreDelay = true; - } else { - if (sb.length() > 0) { - sb.append(' '); - } - sb.append(args[i]); - } - } - - SecurityInfo si = new SecurityInfo(env); - env.loadToSystemPropsStartsWith("AAF", "DME2"); - Locator loc; - if(aafUrl.contains("//DME2RESOLVE")) { - DME2Manager dm = new DME2Manager("AAFcli DME2Manager", System.getProperties()); - loc = new DME2Locator(env, dm, aafUrl); - } else { - loc = new PropertyLocator(aafUrl); - } - - //Config.configPropFiles(new AccessGetter(env), env); - - TIMEOUT = Integer.parseInt(env.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF)); - HMangr hman = new HMangr(env, loc).readTimeout(TIMEOUT).apiVersion("2.0"); - - //TODO: Consider requiring a default in properties - env.setProperty(Config.AAF_DEFAULT_REALM, System.getProperty(Config.AAF_DEFAULT_REALM,Config.getDefaultRealm())); - - AAFcli aafcli = new AAFcli(env, new OutputStreamWriter(System.out), hman, si, - new HBasicAuthSS(user, env.decrypt(pass,false), (SecurityInfoC) si)); - if(!ignoreDelay) { - File delay = new File("aafcli.delay"); - if(delay.exists()) { - BufferedReader br = new BufferedReader(new FileReader(delay)); - try { - globalDelay = Integer.parseInt(br.readLine()); - } catch(Exception e) { - env.debug().log(e); - } finally { - br.close(); - } - } - } - try { - if (isConsole) { - System.out.println("Type 'help' for short help or 'help -d' for detailed help with aafcli commands"); - System.out.println("Type '?' for help with command line editing"); - System.out.println("Type 'q', 'quit', or 'exit' to quit aafcli\n"); - - ConsoleReader reader = new ConsoleReader(); - try { - reader.setPrompt("aafcli > "); - - String line; - while ((line = reader.readLine()) != null) { - showDetails = (line.contains("-d"))?true:false; - - if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("q") || line.equalsIgnoreCase("exit")) { - break; - } else if (line.equalsIgnoreCase("--help -d") || line.equalsIgnoreCase("help -d") - || line.equalsIgnoreCase("help")) { - line = "--help"; - } else if (line.equalsIgnoreCase("cls")) { - reader.clearScreen(); - continue; - } else if (line.equalsIgnoreCase("?")) { - keyboardHelp(); - continue; - } - try { - aafcli.eval(line); - pw.flush(); - } catch (Exception e) { - pw.println(e.getMessage()); - pw.flush(); - } - } - } finally { - reader.close(); - } - } else if (rdr != null) { - BufferedReader br = new BufferedReader(rdr); - String line; - while ((line = br.readLine()) != null) { - if (!aafcli.eval(line) && exitOnFailure) { - rv = 1; - break; - } - } - } else { // just run the command line - aafcli.verbose(false); - if (sb.length() == 0) { - sb.append("--help"); - } - rv = aafcli.eval(sb.toString()) ? 0 : 1; - } - } finally { - aafcli.close(); - - // Don't close if No Reader, or it's a Reader of Standard In - if (rdr != null && !(rdr instanceof InputStreamReader)) { - rdr.close(); - } - } - } catch (MessageException e) { - System.out.println("MessageException caught"); - - System.err.println(e.getMessage()); - } catch (Exception e) { - e.printStackTrace(System.err); - } - System.exit(rv); - - } - - private static class GetProp { - private Console cons = System.console(); - private StringBuilder err = null; - private AuthzEnv env; - - public GetProp(AuthzEnv env) { - this.env = env; - } - - public String get(final boolean pass, final String tag, final String other) { - String data = env.getProperty(tag,null); - if (data == null) { - if(cons!=null) { - if(pass) { - char[] cp = System.console().readPassword("%s: ",tag); - if(cp!=null) { - data=String.valueOf(cp); - } - } else { - cons.writer().format("%s: ", tag); - cons.flush(); - data = cons.readLine(); - } - } - if(data==null) { - if(err == null) { - err = new StringBuilder("Add -D"); - } else { - err.append(", -D"); - } - err.append(tag); - if(other!=null) { - err.append("=<"); - err.append(other); - err.append('>'); - } - } - } - return data; - } - - public void set(final String tag, final String other) { - String data = env.getProperty(tag,null); - if (data == null) { - if(cons!=null) { - cons.writer().format("%s: ", tag); - cons.flush(); - data = cons.readLine(); - } - if(data==null) { - if(err == null) { - err = new StringBuilder("Add -D"); - } else { - err.append(", -D"); - } - err.append(tag); - if(other!=null) { - err.append("=<"); - err.append(other); - err.append('>'); - } - } - } - if(data!=null) { - System.setProperty(tag, data); - } - } - - public StringBuilder err() { - return err; - } - } - - public boolean isTest() { - return AAFcli.isTest; - } - - public boolean isDetailed() { - return AAFcli.showDetails; - } - - public String typeString(Class cls, boolean json) { - return "application/" + cls.getSimpleName() + "+" + (json ? "json" : "xml") + ";version=" + hman.apiVersion(); - } - - public String forceString() { - return force; - } - - public boolean addRequest() { - return request; - } - - public void clearSingleLineProperties() { - force = null; - request = false; - showDetails = false; - } - - public void gui(boolean b) { - gui = b; - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/BaseCmd.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/BaseCmd.java deleted file mode 100644 index ff01b01a..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/BaseCmd.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd; - -import java.util.ArrayList; -import java.util.List; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - - -public class BaseCmd extends Cmd { - protected List cmds; - - public BaseCmd(AAFcli aafcli, String name, Param ... params) { - super(aafcli, null, name, params); - cmds = new ArrayList(); - } - - public BaseCmd(CMD parent, String name, Param ... params) { - super(parent.aafcli, parent, name, params); - cmds = new ArrayList(); - } - - - @Override - public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException { - if(args.length-idx<1) { - pw().println(build(new StringBuilder(),null).toString()); - } else { - String s = args[idx]; - String name; - Cmd empty = null; - for(Cmd c: cmds) { - name = c.getName(); - if(name==null && empty==null) { // Mark with Command is null, and take the first one. - empty = c; - } else if(s.equalsIgnoreCase(c.getName())) - return c.exec(idx+1, args); - } - if(empty!=null) { - return empty.exec(idx, args); // If name is null, don't account for it on command line. jg 4-29 - } - pw().println("Instructions not understood."); - } - return 0; - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/BasicAuth.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/BasicAuth.java deleted file mode 100644 index 3e1f1fbb..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/BasicAuth.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd; - -import java.io.IOException; - -import com.att.aft.dme2.api.DME2Client; -import org.onap.aaf.cadi.SecuritySetter; -import org.onap.aaf.cadi.Symm; - -public class BasicAuth implements SecuritySetter { - private String cred; - private String user; - - public BasicAuth(String user, String pass) throws IOException { - this.user = user; - cred = "Basic " + Symm.base64.encode(user+':'+pass); - } - - @Override - public void setSecurity(DME2Client client) { - client.addHeader("Authorization" , cred); - } - - @Override - public String getID() { - return user; - } - - //@Override - public int setLastResponse(int respCode) { - // TODO Auto-generated method stub - return 0; - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/Cmd.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/Cmd.java deleted file mode 100644 index 3c7f4ac8..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/Cmd.java +++ /dev/null @@ -1,499 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd; - -import java.io.PrintWriter; -import java.io.StringReader; -import java.sql.Date; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.GregorianCalendar; -import java.util.List; -import java.util.Stack; -import java.util.concurrent.ConcurrentHashMap; - -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.cadi.http.HMangr; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Data.TYPE; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.util.Chrono; -import org.onap.aaf.rosetta.env.RosettaDF; -import org.onap.aaf.rosetta.env.RosettaEnv; - -import aaf.v2_0.Error; -import aaf.v2_0.History; -import aaf.v2_0.History.Item; -import aaf.v2_0.Request; - - -public abstract class Cmd { - private static final String AAF_DEFAULT_REALM = "aaf_default_realm"; - - private static final DateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); - protected static final String BLANK = ""; - protected static final String COMMA = ","; // for use in splits - - protected static final int lineLength = 80; - - private final static String hformat = "%-23s %-5s %-20s %-35s\n"; - - public static final String STARTDATE = "startdate"; - public static final String ENDDATE = "enddate"; - - private String name; - private final Param[] params; - private int required; - protected final Cmd parent; - protected final List children; - private final ConcurrentHashMap,RosettaDF> dfs = new ConcurrentHashMap,RosettaDF>(); - public final AAFcli aafcli; - protected Env env; - - public Cmd(AAFcli aafcli, String name, Param ... params) { - this(aafcli,null, name,params); - } - - public Cmd(Cmd parent, String name, Param ... params) { - this(parent.aafcli,parent, name,params); - } - - Cmd(AAFcli aafcli, Cmd parent, String name, Param ... params) { - this.parent = parent; - this.aafcli = aafcli; - this.env = aafcli.env; - if(parent!=null) { - parent.children.add(this); - } - children = new ArrayList(); - this.params = params; - this.name = name; - required=0; - for(Param p : params) { - if(p.required) { - ++required; - } - } - } - - public final int exec(int idx, String ... args) throws CadiException, APIException, LocatorException { - if(args.length-idx cls,boolean head) { - int indent = _indent; - final String meth = hmeth.name(); - if(head) { - sb.append('\n'); - detailLine(sb,indent,"APIs:"); - } - indent+=2; - multiChar(sb,indent,' ',0); - sb.append(meth); - sb.append(' '); - sb.append(pathInfo); - String cliString = aafcli.typeString(cls,true); - if(indent+meth.length()+pathInfo.length()+cliString.length()+2>80) { - sb.append(" ..."); - multiChar(sb,indent+3+meth.length(),' ',0); - } else { // same line - sb.append(' '); - } - sb.append(cliString); - } - - protected void multiChar(StringBuilder sb, int length, char c, int indent) { - sb.append('\n'); - for(int i=0;i ": "] "); - } - - boolean first = true; - for(Cmd child : children) { - if(first) { - first = false; - } else if(detail==null) { - multiChar(sb,indent,' ',0); - } else { - // Write parents for Detailed Report - Stack stack = new Stack(); - for(Cmd c = child.parent;c!=null;c=c.parent) { - if(c.name!=null) { - stack.push(c.name); - } - } - if(!stack.isEmpty()) { - sb.append(" "); - while(!stack.isEmpty()) { - sb.append(stack.pop()); - sb.append(' '); - } - } - } - child.build(sb,detail); - if(detail!=null) { - child.detailedHelp(4, detail); - // If Child wrote something, then add, bracketing by lines - if(detail.length()>0) { - multiChar(sb,80,'-',2); - sb.append(detail); - sb.append('\n'); - multiChar(sb,80,'-',2); - sb.append('\n'); - detail.setLength(0); // reuse - } else { - sb.append('\n'); - } - } - } - return sb; - } - - protected void error(Future future) { - StringBuilder sb = new StringBuilder("Failed"); - String desc = future.body(); - int code = future.code(); - if(desc==null || desc.length()==0) { - withCode(sb,code); - } else if(desc.startsWith("{")) { - StringReader sr = new StringReader(desc); - try { - // Note: 11-18-2013. This rather convoluted Message Structure required by TSS Restful Specs, reflecting "Northbound" practices. - Error err = getDF(Error.class).newData().in(TYPE.JSON).load(sr).asObject(); - sb.append(" ["); - sb.append(err.getMessageId()); - sb.append("]: "); - String messageBody = err.getText(); - List vars = err.getVariables(); - int pipe; - for (int varCounter=0;varCounter= 0) { - if((pipe = var.indexOf('|'))>=0) { // In AAF, we use a PIPE for Choice - if (aafcli.isTest()) { - String expiresStr = var.substring(pipe); - var = var.replace(expiresStr, "[Placeholder]"); - } else { - StringBuilder varsb = new StringBuilder(var); - varsb.deleteCharAt(pipe); - var = varsb.toString(); - } - messageBody = messageBody.replace("%" + varCounter, varCounter-1 + ") " + var); - } else { - messageBody = messageBody.replace("%" + varCounter, var); - } - } - } - sb.append(messageBody); - } catch (Exception e) { - withCode(sb,code); - sb.append(" (Note: Details cannot be obtained from Error Structure)"); - } - } else if(desc.startsWith("")){ // Core Jetty, etc sends HTML for Browsers - withCode(sb,code); - } else { - sb.append(" with code "); - sb.append(code); - sb.append(", "); - sb.append(desc); - } - pw().println(sb); - } - - - private void withCode(StringBuilder sb, Integer code) { - sb.append(" with code "); - sb.append(code); - switch(code) { - case 401: - sb.append(" (HTTP Not Authenticated)"); - break; - case 403: - sb.append(" (HTTP Forbidden)"); - break; - case 404: - sb.append(" (HTTP Not Found)"); - break; - default: - } - } - - /** - * Consistently set start and end dates from Requests (all derived from Request) - * @param req - */ - protected void setStartEnd(Request req) { - // Set Start/End Dates, if exist - String str; - if((str = env.getProperty(Cmd.STARTDATE,null))!=null) { - req.setStart(Chrono.timeStamp(Date.valueOf(str))); - } - - if((str = env.getProperty(Cmd.ENDDATE,null))!=null) { - req.setEnd(Chrono.timeStamp(Date.valueOf(str))); - } - } - - @SuppressWarnings("unchecked") - protected RosettaDF getDF(Class cls) throws APIException { - RosettaDF rdf = (RosettaDF)dfs.get(cls); - if(rdf == null) { - rdf = env().newDataFactory(cls); - dfs.put(cls, rdf); - } - return rdf; - } - - public void activity(History history, String header) { - if (history.getItem().isEmpty()) { - int start = header.indexOf('['); - if (start >= 0) { - pw().println("No Activity Found for " + header.substring(start)); - } - } else { - pw().println(header); - for(int i=0;i items = history.getItem(); - java.util.Collections.sort(items, new Comparator() { - @Override - public int compare(Item o1, Item o2) { - return o2.getTimestamp().compare(o1.getTimestamp()); - } - }); - - for(History.Item item : items) { - GregorianCalendar gc = item.getTimestamp().toGregorianCalendar(); - pw().format(hformat, - dateFmt.format(gc.getTime()), - item.getTarget(), - item.getUser(), - item.getMemo()); - } - } - } - - /** - * Turn String Array into a | delimited String - * @param options - * @return - */ - public static String optionsToString(String[] options) { - StringBuilder sb = new StringBuilder(); - boolean first = true; - for(String s : options) { - if(first) { - first = false; - } else { - sb.append('|'); - } - sb.append(s); - } - return sb.toString(); - } - - /** - * return which index number the Option matches. - * - * throws an Exception if not part of this Option Set - * - * @param options - * @param test - * @return - * @throws Exception - */ - public int whichOption(String[] options, String test) throws CadiException { - for(int i=0;i RET same(Retryable retryable) throws APIException, CadiException, LocatorException { - // We're storing in AAFCli, because we know it's always the same, and single threaded - if(aafcli.prevCall!=null) { - retryable.item(aafcli.prevCall.item()); - retryable.lastClient=aafcli.prevCall.lastClient; - } - - RET ret = aafcli.hman.same(aafcli.ss,retryable); - - // Store last call in AAFcli, because Cmds are all different instances. - aafcli.prevCall = retryable; - return ret; - } - - public RET all(Retryable retryable) throws APIException, CadiException, LocatorException { - this.setQueryParamsOn(retryable.lastClient); - return aafcli.hman.all(aafcli.ss,retryable); - } - - public RET oneOf(Retryable retryable,String host) throws APIException, CadiException, LocatorException { - this.setQueryParamsOn(retryable.lastClient); - return aafcli.hman.oneOf(aafcli.ss,retryable,true,host); - } - - protected PrintWriter pw() { - return AAFcli.pw; - } - - public String getName() { - return name; - } - - public void reportHead(String ... str) { - pw().println(); - boolean first = true; - int i=0; - for(String s : str) { - if(first) { - if(++i>1) { - first = false; - pw().print("["); - } - } else { - pw().print("] ["); - } - pw().print(s); - } - if(!first) { - pw().print(']'); - } - pw().println(); - reportLine(); - } - - public String reportColHead(String format, String ... args) { - pw().format(format,(Object[])args); - reportLine(); - return format; - } - - public void reportLine() { - for(int i=0;i rcli) { - StringBuilder sb=null; - String force; - if((force=aafcli.forceString())!=null) { - sb = new StringBuilder("force="); - sb.append(force); - } - if(aafcli.addRequest()) { - if(sb==null) { - sb = new StringBuilder("request=true"); - } else { - sb.append("&request=true"); - } - } - if(sb!=null && rcli!=null) { - rcli.setQueryParams(sb.toString()); - } - } -// -// /** -// * If Force is set, will return True once only, then revert to "FALSE". -// * -// * @return -// */ -// protected String checkForce() { -// if(TRUE.equalsIgnoreCase(env.getProperty(FORCE, FALSE))) { -// env.setProperty(FORCE, FALSE); -// return "true"; -// } -// return FALSE; -// } - - public String toString() { - StringBuilder sb = new StringBuilder(); - if(parent==null) { // ultimate parent - build(sb,null); - return sb.toString(); - } else { - return parent.toString(); - } - } - - public String getOrgRealm() { - return env.getProperty(AAF_DEFAULT_REALM); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/Help.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/Help.java deleted file mode 100644 index af6e071e..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/Help.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd; - -import java.util.List; - -import com.att.aft.dme2.internal.jetty.http.HttpStatus; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -public class Help extends Cmd { - private List cmds; - - public Help(AAFcli aafcli, List cmds) { - super(aafcli, "--help", - new Param("-d (more details)", false), - new Param("command",false)); - this.cmds = cmds; - } - - @Override - public int _exec( int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - boolean first = true; - StringBuilder sb = new StringBuilder("AAF Command Line Tool"); - StringBuilder details; - if(aafcli.isDetailed() ){ - multiChar(sb, 21, '-',0); - details=new StringBuilder();// use for temporary writing of details - } else { - multiChar(sb, 21, '-',0); - details = null; - } - String comp = args.length>idx?args[idx++]:null; - if("help".equalsIgnoreCase(comp)) { - build(sb,null); - detailedHelp(4, sb); - sb.append('\n'); - } else { - for(Cmd c : cmds) { - if(comp!=null) { - if(comp.equals(c.getName())) { - multiChar(sb,2,' ',0); - c.build(sb,details); - } - } else { - if(first) { - first=false; - } else { - multiChar(sb,80,'-',2); - } - multiChar(sb,2,' ',0); - c.build(sb,details); - if(details!=null) { - c.detailedHelp(4, sb); -// multiChar(sb,80,'-',2); - } - } - } - } - pw().println(sb.toString()); - return HttpStatus.OK_200; - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,"To print main help, enter \"aafcli\" or \"aafcli --help \""); - detailLine(sb,indent,"To print narrow the help content, enter sub-entries after aafcli,"); - detailLine(sb,indent+2,"i.e. \"aafcli perm\""); - detailLine(sb,indent,"To see version of AAF CLI, enter \"aafcli --version \""); - sb.append('\n'); - detailLine(sb,indent,"State Commands: change variables or credentials between calls."); - indent+=4; - detailLine(sb,indent,"set = - Set any System Property to a new value"); - detailLine(sb,indent,"as - Change Credentials. Password may be encrypted"); - detailLine(sb,indent,"expect [int]* - In test mode, check for proper HTTP Status Codes"); - detailLine(sb,indent,"sleep - Wait for seconds"); - sb.append('\n'); - detailLine(sb,indent-4,"CmdLine Arguments: change behavior of the aafcli program"); - detailLine(sb,indent,"-i - Read commands from Shell Standard Input"); - detailLine(sb,indent,"-f - Read commands from a file"); - detailLine(sb,indent,"-a - In test mode, do not stop execution on unexpected error"); - detailLine(sb,indent,"-t - Test Mode will not print variable fields that could break tc runs"); - detailLine(sb,indent+6,"such as expiration dates of a credential"); - detailLine(sb,indent,"-s - Request specific Start Date (not immediately)"); - detailLine(sb,indent+6,"Format YYYY-MM-DD. Can also be set with \"set " + Cmd.STARTDATE + "=\""); - detailLine(sb,indent,"-e - Set Expiration/End Date, where commands support"); - detailLine(sb,indent+6,"Format YYYY-MM-DD. Can also be set with \"set " + Cmd.ENDDATE + "=\""); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/MessageException.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/MessageException.java deleted file mode 100644 index f669ca6a..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/MessageException.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -/** - * - */ -package org.onap.aaf.cmd; - -/** - * An Exception designed simply to give End User message, no stack trace - * - * - */ -public class MessageException extends Exception { - /** - * - */ - private static final long serialVersionUID = 8143933588878259048L; - - /** - * @param Message - */ - public MessageException(String msg) { - super(msg); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/Param.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/Param.java deleted file mode 100644 index 9e9486a1..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/Param.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd; - -public class Param { - public final String tag; - public final boolean required; - - /** - * - * @param t - * @param b - */ - public Param(String t, boolean required) { - tag = t; - this.required=required; - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/Version.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/Version.java deleted file mode 100644 index 8cdb27d3..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/Version.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd; - -import com.att.aft.dme2.internal.jetty.http.HttpStatus; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.inno.env.APIException; - -public class Version extends Cmd { - - - public Version(AAFcli aafcli) { - super(aafcli, "--version"); - } - - @Override - protected int _exec(int idx, String... args) throws CadiException, APIException, LocatorException { - pw().println("AAF Command Line Tool"); - String version = this.env().getProperty(Config.AAF_DEPLOYED_VERSION, "N/A"); - pw().println("Version: " + version); - return HttpStatus.OK_200; - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Cache.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Cache.java deleted file mode 100644 index 7176d0cc..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Cache.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.mgmt; - -import org.onap.aaf.cmd.BaseCmd; - -import org.onap.aaf.inno.env.APIException; - -public class Cache extends BaseCmd { - public Cache(Mgmt mgmt) throws APIException { - super(mgmt, "cache"); - cmds.add(new Clear(this)); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Clear.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Clear.java deleted file mode 100644 index 296b76d0..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Clear.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.mgmt; - -import org.onap.aaf.authz.common.Define; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -/** - * p - * - */ -public class Clear extends Cmd { - public Clear(Cache parent) { - super(parent,"clear", - new Param("name[,name]*",true)); - } - - @Override - public int _exec(int _idx, String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - int rv=409; - for(final String name : args[idx++].split(COMMA)) { - rv = all(new Retryable() { - @Override - public Integer code(Rcli client) throws APIException, CadiException { - int rv = 409; - Future fp = client.delete( - "/mgmt/cache/"+name, - Void.class - ); - if(fp.get(AAFcli.timeout())) { - pw().println("Cleared Cache for " + name + " on " + client); - rv=200; - } else { - if(rv==409)rv = fp.code(); - error(fp); - } - return rv; - } - }); - } - return rv; - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,"Clear the cache for certain tables"); - indent+=2; - detailLine(sb,indent,"name - name of table or 'all'"); - detailLine(sb,indent+14,"Must have admin rights to '" + Define.ROOT_NS + '\''); - indent-=2; - api(sb,indent,HttpMethods.DELETE,"mgmt/cache/:name",Void.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Deny.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Deny.java deleted file mode 100644 index 44b3f8f9..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Deny.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.mgmt; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.BaseCmd; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -public class Deny extends BaseCmd { - private final static String[] options = {"add","del"}; - - public Deny(Mgmt mgmt) throws APIException { - super(mgmt, "deny"); - cmds.add(new DenySomething(this,"ip","ipv4or6[,ipv4or6]*")); - cmds.add(new DenySomething(this,"id","identity[,identity]*")); - } - - public class DenySomething extends Cmd { - - private boolean isID; - - public DenySomething(Deny deny, String type, String repeatable) { - super(deny, type, - new Param(optionsToString(options),true), - new Param(repeatable,true)); - isID = "id".equals(type); - } - - @Override - protected int _exec(int _idx, String... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - String action = args[idx++]; - final int option = whichOption(options, action); - int rv=409; - for(final String name : args[idx++].split(COMMA)) { - final String append; - if(isID && name.indexOf("@")<0) { - append='@'+ env.getProperty(AAFcli.AAF_DEFAULT_REALM); - } else { - append = ""; - } - final String path = "/mgmt/deny/"+getName() + '/'+ name + append; - rv = all(new Retryable() { - @Override - public Integer code(Rcli client) throws APIException, CadiException { - int rv = 409; - Future fp; - String resp; - switch(option) { - case 0: - fp = client.create(path, Void.class); - resp = " added"; - break; - default: - fp = client.delete(path, Void.class); - resp = " deleted"; - } - if(fp.get(AAFcli.timeout())) { - pw().println(name + append + resp + " on " + client); - rv=fp.code(); - } else { - if(rv==409)rv = fp.code(); - error(fp); - } - return rv; - } - }); - } - return rv; - } - - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Log.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Log.java deleted file mode 100644 index 5726d311..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Log.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.mgmt; - -import org.onap.aaf.authz.common.Define; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.BaseCmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -public class Log extends BaseCmd { - private final static String[] options = {"add","del"}; - - public Log(Mgmt mgmt) throws APIException { - super(mgmt, "log", - new Param(optionsToString(options),true), - new Param("id[,id]*",true)); - } - - @Override - public int _exec(int _idx, String ... args) throws CadiException, APIException, LocatorException { - int rv=409; - int idx = _idx; - final int option = whichOption(options, args[idx++]); - - for(String name : args[idx++].split(COMMA)) { - final String fname; - if(name.indexOf("@")<0) { - fname=name+'@'+ env.getProperty(AAFcli.AAF_DEFAULT_REALM); - } else { - fname = name; - } - - - - rv = all(new Retryable() { - @Override - public Integer code(Rcli client) throws APIException, CadiException { - int rv = 409; - Future fp; - String str = "/mgmt/log/id/"+fname; - String msg; - switch(option) { - case 0: - fp = client.create(str,Void.class); - msg = "Added"; - break; - case 1: - fp = client.delete(str,Void.class); - msg = "Deleted"; - break; - default: - fp = null; - msg = "Ignored"; - } - - if(fp!=null) { - if(fp.get(AAFcli.timeout())) { - pw().println(msg + " Special Log for " + fname + " on " + client); - rv=200; - } else { - if(rv==409)rv = fp.code(); - error(fp); - } - return rv; - } - return rv; - } - }); - } - return rv; - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,"Clear the cache for certain tables"); - indent+=2; - detailLine(sb,indent,"name - name of table or 'all'"); - detailLine(sb,indent+14,"Must have admin rights to '" + Define.ROOT_NS + '\''); - indent-=2; - api(sb,indent,HttpMethods.DELETE,"mgmt/cache/:name",Void.class,true); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Mgmt.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Mgmt.java deleted file mode 100644 index d52b60f4..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Mgmt.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.mgmt; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.BaseCmd; - -import org.onap.aaf.inno.env.APIException; - -public class Mgmt extends BaseCmd { - public Mgmt(AAFcli aafcli) throws APIException { - super(aafcli, "mgmt"); - cmds.add(new Cache(this)); - cmds.add(new Deny(this)); - cmds.add(new Log(this)); - cmds.add(new Session(this)); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/SessClear.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/SessClear.java deleted file mode 100644 index 5941a52c..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/SessClear.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.mgmt; - -import org.onap.aaf.authz.common.Define; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -/** - * p - * - */ -public class SessClear extends Cmd { - public SessClear(Session parent) { - super(parent,"clear", - new Param("machine",true)); - } - - @Override - public int _exec(int idx, String ... args) throws CadiException, APIException, LocatorException { - int rv=409; - String machine = args[idx++]; - rv = oneOf(new Retryable() { - @Override - public Integer code(Rcli client) throws APIException, CadiException { - int rv = 409; - Future fp = client.delete( - "/mgmt/dbsession", - Void.class - ); - if(fp.get(AAFcli.timeout())) { - pw().println("Cleared DBSession on " + client); - rv=200; - } else { - if(rv==409)rv = fp.code(); - error(fp); - } - return rv; - } - },machine); - return rv; - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,"Clear the cache for certain tables"); - indent+=2; - detailLine(sb,indent,"name - name of table or 'all'"); - detailLine(sb,indent+14,"Must have admin rights to '" + Define.ROOT_NS + '\''); - indent-=2; - api(sb,indent,HttpMethods.DELETE,"mgmt/cache/:name",Void.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Session.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Session.java deleted file mode 100644 index b49e5233..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Session.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.mgmt; - -import org.onap.aaf.cmd.BaseCmd; - -import org.onap.aaf.inno.env.APIException; - -public class Session extends BaseCmd { - public Session(Mgmt mgmt) throws APIException { - super(mgmt, "dbsession"); - cmds.add(new SessClear(this)); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Admin.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Admin.java deleted file mode 100644 index ff105ce8..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Admin.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.BaseCmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -public class Admin extends BaseCmd { - private final static String[] options = {"add","del"}; - - public Admin(NS ns) throws APIException { - super(ns,"admin", - new Param(optionsToString(options),true), - new Param("name",true), - new Param("id[,id]*",true) - ); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - final int option = whichOption(options, args[idx++]); - final String ns = args[idx++]; - final String ids[] = args[idx++].split(","); - final String realm = getOrgRealm(); -// int rv = 500; - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp = null; - for(String id : ids) { - if (id.indexOf('@') < 0 && realm != null) id += '@' + realm; - String verb; - switch(option) { - case 0: - fp = client.create("/authz/ns/"+ns+"/admin/"+id,Void.class); - verb = " added to "; - break; - case 1: - fp = client.delete("/authz/ns/"+ns+"/admin/"+id,Void.class); - verb = " deleted from "; - break; - default: - throw new CadiException("Bad Argument"); - }; - - if(fp.get(AAFcli.timeout())) { - pw().append("Admin "); - pw().append(id); - pw().append(verb); - pw().println(ns); - } else { - error(fp); - return fp.code(); - } - - } - return fp==null?500:fp.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,"Add or Delete Administrator to/from Namespace"); - indent+=4; - detailLine(sb,indent,"name - Name of Namespace"); - detailLine(sb,indent,"id - Credential of Person(s) to be Administrator"); - sb.append('\n'); - detailLine(sb,indent,"aafcli will call API on each ID presented."); - indent-=4; - api(sb,indent,HttpMethods.POST,"authz/ns//admin/",Void.class,true); - api(sb,indent,HttpMethods.DELETE,"authz/ns//admin/",Void.class,false); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Attrib.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Attrib.java deleted file mode 100644 index 97e2e9a2..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Attrib.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.BaseCmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -public class Attrib extends BaseCmd { - private final static String[] options = {"add","upd","del"}; - - public Attrib(NS ns) throws APIException { - super(ns,"attrib", - new Param(optionsToString(options),true), - new Param("ns",true), - new Param("key",true), - new Param("value",false) - ); - } - - @Override - public int _exec(final int idx, final String ... args) throws CadiException, APIException, LocatorException { - final int option = whichOption(options, args[idx]); - final String ns = args[idx+1]; - final String key = args[idx+2]; - final String value; - if(option!=2) { - if(args.length<=idx+3) { - throw new CadiException("Not added: Need more Data"); - } - value = args[idx+3]; - } else { - value = ""; - } - - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp = null; - String message; - switch(option) { - case 0: - fp = client.create("/authz/ns/"+ns+"/attrib/"+key+'/'+value,Void.class); - message = String.format("Add Attrib %s=%s to %s", - key,value,ns); - break; - case 1: - fp = client.update("/authz/ns/"+ns+"/attrib/"+key+'/'+value); - message = String.format("Update Attrib %s=%s for %s", - key,value,ns); - break; - case 2: - fp = client.delete("/authz/ns/"+ns+"/attrib/"+key,Void.class); - message = String.format("Attrib %s deleted from %s", - key,ns); - break; - default: - throw new CadiException("Bad Argument"); - }; - - if(fp.get(AAFcli.timeout())) { - pw().println(message); - } else { - error(fp); - return fp.code(); - } - - return fp==null?500:fp.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,"Add or Delete Administrator to/from Namespace"); - indent+=4; - detailLine(sb,indent,"name - Name of Namespace"); - detailLine(sb,indent,"id - Credential of Person(s) to be Administrator"); - sb.append('\n'); - detailLine(sb,indent,"aafcli will call API on each ID presented."); - indent-=4; - api(sb,indent,HttpMethods.POST,"authz/ns//admin/",Void.class,true); - api(sb,indent,HttpMethods.DELETE,"authz/ns//admin/",Void.class,false); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Create.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Create.java deleted file mode 100644 index 32ab43f7..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Create.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.NsRequest; - -/** - * p - * - */ -public class Create extends Cmd { - private static final String COMMA = ","; - - public Create(NS parent) { - super(parent,"create", - new Param("name",true), - new Param("responsible (id[,id]*)",true), - new Param("admin (id[,id]*)",false)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - - final NsRequest nr = new NsRequest(); - - String realm = getOrgRealm(); - - nr.setName(args[idx++]); - String[] responsible = args[idx++].split(COMMA); - for(String s : responsible) { - if (s.indexOf('@') < 0 && realm != null) s += '@' + realm; - nr.getResponsible().add(s); - } - String[] admin; - if(args.length>idx) { - admin = args[idx++].split(COMMA); - } else { - admin = responsible; - } - for(String s : admin) { - if (s.indexOf('@') < 0 && realm != null) s += '@' + realm; - nr.getAdmin().add(s); - } - - // Set Start/End commands - setStartEnd(nr); - - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - // Requestable - setQueryParamsOn(client); - Future fp = client.create( - "/authz/ns", - getDF(NsRequest.class), - nr - ); - if(fp.get(AAFcli.timeout())) { - pw().println("Created Namespace"); - } else { - if(fp.code()==202) { - pw().println("Namespace Creation Accepted, but requires Approvals before actualizing"); - } else { - error(fp); - } - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,"Create a Namespace"); - indent+=2; - detailLine(sb,indent,"name - Namespaces are dot-delimited, ex com.att.myapp"); - detailLine(sb,indent+14,"and must be created with parent credentials."); - detailLine(sb,indent+14,"Ex: to create com.att.myapp, you must be admin for com.att"); - detailLine(sb,indent+14,"or com"); - detailLine(sb,indent,"responsible - This is the person(s) who receives Notifications and"); - detailLine(sb,indent+14,"approves Requests regarding this Namespace. Companies have"); - detailLine(sb,indent+14,"Policies as to who may take on this responsibility"); - detailLine(sb,indent,"admin - These are the people who are allowed to make changes on"); - detailLine(sb,indent+14,"the Namespace, including creating Roles, Permissions"); - detailLine(sb,indent+14,"and Credentials"); - sb.append('\n'); - detailLine(sb,indent,"Namespaces can be created even though there are Roles/Permissions which"); - detailLine(sb,indent,"start with the requested sub-namespace. They are reassigned to the"); - detailLine(sb,indent,"Child Namespace"); - indent-=2; - api(sb,indent,HttpMethods.POST,"authz/ns",NsRequest.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Delete.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Delete.java deleted file mode 100644 index 5254d460..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Delete.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -/** - * p - * - */ -public class Delete extends Cmd { - public Delete(NS parent) { - super(parent,"delete", - new Param("name",true)); - } - - @Override - public int _exec(final int idx, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int index = idx; - StringBuilder path = new StringBuilder("/authz/ns/"); - path.append(args[index++]); - - // Send "Force" if set - setQueryParamsOn(client); - Future fp = client.delete(path.toString(),Void.class); - - if(fp.get(AAFcli.timeout())) { - pw().println("Deleted Namespace"); - } else { - error(fp); - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,"Delete a Namespace"); - indent+=4; - detailLine(sb,indent,"Namespaces cannot normally be deleted when there are still credentials,"); - detailLine(sb,indent,"permissions or roles associated with them. These can be deleted"); - detailLine(sb,indent,"automatically by setting \"force\" property."); - detailLine(sb,indent,"i.e. set force=true or just starting with \"force\""); - detailLine(sb,indent," (note force is unset after first use)"); - sb.append('\n'); - detailLine(sb,indent,"If \"set force=move\" is set, credentials are deleted, but "); - detailLine(sb,indent,"Permissions and Roles are assigned to the Parent Namespace instead of"); - detailLine(sb,indent,"being deleted. Similarly, Namespaces can be created even though there"); - detailLine(sb,indent,"are Roles/Perms whose type starts with the requested sub-namespace."); - detailLine(sb,indent,"They are simply reassigned to the Child Namespace"); - indent-=4; - api(sb,indent,HttpMethods.DELETE,"authz/ns/[?force=true]",Void.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Describe.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Describe.java deleted file mode 100644 index 2939964e..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Describe.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.NsRequest; - -public class Describe extends Cmd { - private static final String NS_PATH = "/authz/ns"; - public Describe(NS parent) { - super(parent,"describe", - new Param("name",true), - new Param("description",true)); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - String name = args[idx++]; - StringBuilder desc = new StringBuilder(); - while (idx < args.length) { - desc.append(args[idx++] + ' '); - } - - NsRequest nsr = new NsRequest(); - nsr.setName(name); - nsr.setDescription(desc.toString()); - - // Set Start/End commands - setStartEnd(nsr); - - Future fn = null; - int rv; - - fn = client.update( - NS_PATH, - getDF(NsRequest.class), - nsr - ); - - if(fn.get(AAFcli.timeout())) { - rv=fn.code(); - pw().println("Description added to Namespace"); - } else { - if((rv=fn.code())==202) { - pw().print("Adding description"); - pw().println(" Accepted, but requires Approvals before actualizing"); - } else { - error(fn); - } - } - return rv; - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,"Add a description to a namespace"); - api(sb,indent,HttpMethods.PUT,"authz/ns",NsRequest.class,true); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/List.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/List.java deleted file mode 100644 index 47c9a25b..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/List.java +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import java.util.Collections; -import java.util.Comparator; - -import org.onap.aaf.cmd.BaseCmd; - -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.inno.env.util.Chrono; - -import aaf.v2_0.Nss; -import aaf.v2_0.Nss.Ns; -import aaf.v2_0.Nss.Ns.Attrib; -import aaf.v2_0.Perms; -import aaf.v2_0.Roles; -import aaf.v2_0.Users; -import aaf.v2_0.Users.User; - -public class List extends BaseCmd { - - public List(NS parent) { - super(parent,"list"); - cmds.add(new ListByName(this)); - -// TODO: uncomment when on cassandra 2.1.2 if we like cli command to get all ns's -// a user is admin or responsible for - cmds.add(new ListAdminResponsible(this)); - - cmds.add(new ListActivity(this)); - cmds.add(new ListUsers(this)); - cmds.add(new ListChildren(this)); - cmds.add(new ListNsKeysByAttrib(this)); - } - - private static final String sformat = " %-72s\n"; - protected static final String kformat = " %-72s\n"; - - - public void report(Future fp, String ... str) { - reportHead(str); - if(fp==null) { - pw().println(" *** Namespace Not Found ***"); - } - - if(fp!=null && fp.value!=null) { - for(Ns ns : fp.value.getNs()) { - pw().println(ns.getName()); - if (this.aafcli.isDetailed()) { - pw().println(" Description"); - pw().format(sformat,ns.getDescription()==null?"":ns.getDescription()); - } - if(ns.getAdmin().size()>0) { - pw().println(" Administrators"); - for(String admin : ns.getAdmin()) { - pw().format(sformat,admin); - } - } - if(ns.getResponsible().size()>0) { - pw().println(" Responsible Parties"); - for(String responsible : ns.getResponsible()) { - pw().format(sformat,responsible); - } - } - if(ns.getAttrib().size()>0) { - pw().println(" Namespace Attributes"); - for(Attrib attrib : ns.getAttrib()) { - StringBuilder sb = new StringBuilder(attrib.getKey()); - if(attrib.getValue()==null || attrib.getValue().length()>0) { - sb.append('='); - sb.append(attrib.getValue()); - } - pw().format(sformat,sb.toString()); - } - - } - } - } - } - - public void reportName(Future fp, String ... str) { - reportHead(str); - if(fp!=null && fp.value!=null) { - java.util.List nss = fp.value.getNs(); - Collections.sort(nss, new Comparator() { - @Override - public int compare(Ns ns1, Ns ns2) { - return ns1.getName().compareTo(ns2.getName()); - } - }); - - for(Ns ns : nss) { - pw().println(ns.getName()); - if (this.aafcli.isDetailed() && ns.getDescription() != null) { - pw().println(" " + ns.getDescription()); - } - } - } - } - - public void reportRole(Future fr) { - if(fr!=null && fr.value!=null && fr.value.getRole().size()>0) { - pw().println(" Roles"); - for(aaf.v2_0.Role r : fr.value.getRole()) { - pw().format(sformat,r.getName()); - } - } - } - - private static final String pformat = " %-30s %-24s %-15s\n"; - public void reportPerm(Future fp) { - if(fp!=null && fp.value!=null && fp.value.getPerm().size()>0) { - pw().println(" Permissions"); - for(aaf.v2_0.Perm p : fp.value.getPerm()) { - pw().format(pformat,p.getType(),p.getInstance(),p.getAction()); - } - } - } - - - private static final String cformat = " %-30s %-6s %-24s\n"; - public void reportCred(Future fc) { - if(fc!=null && fc.value!=null && fc.value.getUser().size()>0) { - pw().println(" Credentials"); - java.util.List users = fc.value.getUser(); - Collections.sort(users, new Comparator() { - @Override - public int compare(User u1, User u2) { - return u1.getId().compareTo(u2.getId()); - } - }); - for(aaf.v2_0.Users.User u : users) { - if (this.aafcli.isTest()) { - pw().format(sformat,u.getId()); - } else { - String type; - switch(u.getType()) { - case 1: type = "U/P"; break; - case 10: type="Cert"; break; - case 200: type="x509"; break; - default: type = ""; - } - pw().format(cformat,u.getId(),type,Chrono.niceDateStamp(u.getExpires())); - } - } - } - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListActivity.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListActivity.java deleted file mode 100644 index 74bcb920..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListActivity.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.History; - -/** - * - */ -public class ListActivity extends Cmd { - private static final String HEADER = "List Activity of Namespace"; - - public ListActivity(List parent) { - super(parent,"activity", - new Param("name",true)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - final String ns = args[idx++]; - - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp = client.read( - "/authz/hist/ns/"+ns, - getDF(History.class) - ); - - if(fp.get(AAFcli.timeout())) { - activity(fp.value, HEADER + " [ " + ns + " ]"); - } else { - error(fp); - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/hist/ns/",History.class,true); - } - - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListAdminResponsible.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListAdminResponsible.java deleted file mode 100644 index 87ed924b..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListAdminResponsible.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Nss; - -public class ListAdminResponsible extends Cmd { - private static final String HEADER="List Namespaces with "; - private final static String[] options = {"admin","responsible"}; - - public ListAdminResponsible(List parent) { - super(parent,null, - new Param(optionsToString(options),true), - new Param("user",true)); - } - - @Override - protected int _exec(final int index, final String... args) throws CadiException, APIException, LocatorException { - - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - String title = args[idx++]; - String user = args[idx++]; - if (user.indexOf('@') < 0 && getOrgRealm() != null) user += '@' + getOrgRealm(); - - Future fn = client.read("/authz/nss/"+title+"/"+user,getDF(Nss.class)); - if(fn.get(AAFcli.timeout())) { - ((List)parent).reportName(fn,HEADER + title + " privileges for ",user); - } else if(fn.code()==404) { - ((List)parent).report(null,HEADER + title + " privileges for ",user); - return 200; - } else { - error(fn); - } - return fn.code(); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER + "admin or responsible priveleges for user"); - api(sb,indent,HttpMethods.GET,"authz/nss//",Nss.class,true); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListByName.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListByName.java deleted file mode 100644 index a63aacf6..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListByName.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Nss; -import aaf.v2_0.Nss.Ns; -import aaf.v2_0.Perms; -import aaf.v2_0.Roles; -import aaf.v2_0.Users; - -/** - * - */ -public class ListByName extends Cmd { - private static final String HEADER="List Namespaces by Name"; - - public ListByName(List parent) { - super(parent,"name", - new Param("ns",true)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - final String ns=args[idx++]; - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fn = client.read("/authz/nss/"+ns,getDF(Nss.class)); - if(fn.get(AAFcli.timeout())) { - ((List)parent).report(fn,HEADER,ns); - if(fn.value!=null) { - for(Ns n : fn.value.getNs()) { - Future fr = client.read("/authz/roles/ns/"+n.getName(), getDF(Roles.class)); - if(fr.get(AAFcli.timeout())) { - ((List)parent).reportRole(fr); - } - } - for(Ns n : fn.value.getNs()) { - Future fp = client.read("/authz/perms/ns/"+n.getName(), getDF(Perms.class)); - if(fp.get(AAFcli.timeout())) { - ((List)parent).reportPerm(fp); - } - } - for(Ns n : fn.value.getNs()) { - Future fu = client.read("/authn/creds/ns/"+n.getName(), getDF(Users.class)); - if(fu.get(AAFcli.timeout())) { - ((List)parent).reportCred(fu); - } - } - } - } else if(fn.code()==404) { - ((List)parent).report(null,HEADER,ns); - return 200; - } else { - error(fn); - } - return fn.code(); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/nss/",Nss.class,true); - detailLine(sb,indent,"Indirectly uses:"); - api(sb,indent,HttpMethods.GET,"authz/roles/ns/",Roles.class,false); - api(sb,indent,HttpMethods.GET,"authz/perms/ns/",Perms.class,false); - api(sb,indent,HttpMethods.GET,"authn/creds/ns/",Users.class,false); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListChildren.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListChildren.java deleted file mode 100644 index 670729ec..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListChildren.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Nss; -import aaf.v2_0.Nss.Ns; - -/** - * p - * - */ -public class ListChildren extends Cmd { - private static final String HEADER="List Child Namespaces"; - - public ListChildren(List parent) { - super(parent,"children", - new Param("ns",true)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - final String ns=args[idx++]; - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fn = client.read("/authz/nss/children/"+ns,getDF(Nss.class)); - if(fn.get(AAFcli.timeout())) { - parent.reportHead(HEADER); - for(Ns ns : fn.value.getNs()) { - pw().format(List.kformat, ns.getName()); - } - } else if(fn.code()==404) { - ((List)parent).report(null,HEADER,ns); - return 200; - } else { - error(fn); - } - return fn.code(); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/nss/children/",Nss.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListNsKeysByAttrib.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListNsKeysByAttrib.java deleted file mode 100644 index 516bcd39..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListNsKeysByAttrib.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Keys; -import aaf.v2_0.Nss; -import aaf.v2_0.Perms; -import aaf.v2_0.Roles; -import aaf.v2_0.Users; - -/** - * p - * - */ -public class ListNsKeysByAttrib extends Cmd { - private static final String HEADER="List Namespace Names by Attribute"; - - public ListNsKeysByAttrib(List parent) { - super(parent,"keys", - new Param("attrib",true)); - } - - @Override - public int _exec(final int idx, final String ... args) throws CadiException, APIException, LocatorException { - final String attrib=args[idx]; - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fn = client.read("/authz/ns/attrib/"+attrib,getDF(Keys.class)); - if(fn.get(AAFcli.timeout())) { - parent.reportHead(HEADER); - for(String key : fn.value.getKey()) { - pw().printf(List.kformat, key); - } - } else if(fn.code()==404) { - parent.reportHead(HEADER); - pw().println(" *** No Namespaces Found ***"); - return 200; - } else { - error(fn); - } - return fn.code(); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/nss/",Nss.class,true); - detailLine(sb,indent,"Indirectly uses:"); - api(sb,indent,HttpMethods.GET,"authz/roles/ns/",Roles.class,false); - api(sb,indent,HttpMethods.GET,"authz/perms/ns/",Perms.class,false); - api(sb,indent,HttpMethods.GET,"authn/creds/ns/",Users.class,false); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsers.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsers.java deleted file mode 100644 index f0359013..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsers.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import javax.xml.datatype.XMLGregorianCalendar; - -import org.onap.aaf.cmd.BaseCmd; - -import aaf.v2_0.Users.User; - -public class ListUsers extends BaseCmd { - - public ListUsers(List parent) { - super(parent,"user"); - cmds.add(new ListUsersWithPerm(this)); - cmds.add(new ListUsersInRole(this)); - } - - public void report(String header, String ns) { - ((List)parent).report(null, header,ns); - } - - public void report(String subHead) { - pw().println(subHead); - } - - private static final String uformat = "%s%-50s expires:%02d/%02d/%04d\n"; - public void report(String prefix, User u) { - XMLGregorianCalendar xgc = u.getExpires(); - pw().format(uformat,prefix,u.getId(),xgc.getMonth()+1,xgc.getDay(),xgc.getYear()); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsersInRole.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsersInRole.java deleted file mode 100644 index 8fdee9b3..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsersInRole.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import java.util.HashSet; -import java.util.Set; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Nss; -import aaf.v2_0.Nss.Ns; -import aaf.v2_0.Role; -import aaf.v2_0.Roles; -import aaf.v2_0.Users; -import aaf.v2_0.Users.User; - -/** - * p - * - */ -public class ListUsersInRole extends Cmd { - private static final String HEADER="List Users in Roles of Namespace "; - - public ListUsersInRole(ListUsers parent) { - super(parent,"role", - new Param("ns",true)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - final String ns=args[idx++]; - final boolean detail = aafcli.isDetailed(); - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - ((ListUsers)parent).report(HEADER,ns); - Future fn = client.read("/authz/nss/"+ns,getDF(Nss.class)); - if(fn.get(AAFcli.timeout())) { - if(fn.value!=null) { - Set uset = detail?null:new HashSet(); - for(Ns n : fn.value.getNs()) { - Future fr = client.read("/authz/roles/ns/"+n.getName(), getDF(Roles.class)); - if(fr.get(AAFcli.timeout())) { - for(Role r : fr.value.getRole()) { - if(detail) { - ((ListUsers)parent).report(r.getName()); - } - Future fus = client.read( - "/authz/users/role/"+r.getName(), - getDF(Users.class) - ); - if(fus.get(AAFcli.timeout())) { - for(User u : fus.value.getUser()) { - if(detail) { - ((ListUsers)parent).report(" ",u); - } else { - uset.add(u.getId()); - } - } - } else if(fn.code()==404) { - return 200; - } - } - } - } - if(uset!=null) { - for(String u : uset) { - pw().print(" "); - pw().println(u); - } - } - } - } else if(fn.code()==404) { - return 200; - } else { - error(fn); - } - return fn.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,HEADER); - indent+=4; - detailLine(sb,indent,"Report Users associated with this Namespace's Roles"); - sb.append('\n'); - detailLine(sb,indent,"If \"set details=true\" is specified, then all roles are printed "); - detailLine(sb,indent,"with the associated users and expiration dates"); - indent-=4; - api(sb,indent,HttpMethods.GET,"authz/nss/",Nss.class,true); - api(sb,indent,HttpMethods.GET,"authz/roles/ns/",Roles.class,false); - api(sb,indent,HttpMethods.GET,"authz/users/role/",Users.class,false); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsersWithPerm.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsersWithPerm.java deleted file mode 100644 index ad65faee..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsersWithPerm.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import java.util.HashSet; -import java.util.Set; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Nss; -import aaf.v2_0.Nss.Ns; -import aaf.v2_0.Perm; -import aaf.v2_0.Perms; -import aaf.v2_0.Users; -import aaf.v2_0.Users.User; - -/** - * p - * - */ -public class ListUsersWithPerm extends Cmd { - private static final String HEADER="List Users of Permissions of Namespace "; - - public ListUsersWithPerm(ListUsers parent) { - super(parent,"perm", - new Param("ns",true)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - final String ns=args[idx++]; - final boolean detail = aafcli.isDetailed(); - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - ((ListUsers)parent).report(HEADER,ns); - Future fn = client.read("/authz/nss/"+ns,getDF(Nss.class)); - if(fn.get(AAFcli.timeout())) { - if(fn.value!=null) { - Set uset = detail?null:new HashSet(); - - for(Ns n : fn.value.getNs()) { - Future fp = client.read("/authz/perms/ns/"+n.getName(), getDF(Perms.class)); - if(fp.get(AAFcli.timeout())) { - for(Perm p : fp.value.getPerm()) { - String perm = p.getType()+'/'+p.getInstance()+'/'+p.getAction(); - if(detail)((ListUsers)parent).report(perm); - Future fus = client.read( - "/authz/users/perm/"+perm, - getDF(Users.class) - ); - if(fus.get(AAFcli.timeout())) { - for(User u : fus.value.getUser()) { - if(detail) - ((ListUsers)parent).report(" ",u); - else - uset.add(u.getId()); - } - } else if(fn.code()==404) { - return 200; - } - } - } - } - if(uset!=null) { - for(String u : uset) { - pw().print(" "); - pw().println(u); - } - } - } - } else if(fn.code()==404) { - return 200; - } else { - error(fn); - } - return fn.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,HEADER); - indent+=4; - detailLine(sb,indent,"Report Users associated with this Namespace's Permissions"); - sb.append('\n'); - detailLine(sb,indent,"If \"set detail=true\" is specified, then Permissions are printed with the associated"); - detailLine(sb,indent,"users and expiration dates"); - indent-=4; - api(sb,indent,HttpMethods.GET,"authz/nss/",Nss.class,true); - api(sb,indent,HttpMethods.GET,"authz/perms/ns/",Perms.class,false); - api(sb,indent,HttpMethods.GET,"authz/users/perm///",Users.class,false); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/NS.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/NS.java deleted file mode 100644 index 979e418f..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/NS.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.BaseCmd; - -import org.onap.aaf.inno.env.APIException; - -public class NS extends BaseCmd { -// final Role role; - - public NS(AAFcli aafcli) throws APIException { - super(aafcli, "ns"); -// this.role = role; - - cmds.add(new Create(this)); - cmds.add(new Delete(this)); - cmds.add(new Admin(this)); - cmds.add(new Responsible(this)); - cmds.add(new Describe(this)); - cmds.add(new Attrib(this)); - cmds.add(new List(this)); - } - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Responsible.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Responsible.java deleted file mode 100644 index e84bd4de..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Responsible.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.BaseCmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -public class Responsible extends BaseCmd { - private final static String[] options = {"add","del"}; - - public Responsible(NS ns) throws APIException { - super(ns,"responsible", - new Param(optionsToString(options),true), - new Param("name",true), - new Param("id[,id]*",true) - ); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - - final int option = whichOption(options, args[idx++]); - final String ns = args[idx++]; - final String ids[] = args[idx++].split(","); - final String realm = getOrgRealm(); - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp=null; - for(String id : ids) { - if (id.indexOf('@') < 0 && realm != null) id += '@' + realm; - String verb; - switch(option) { - case 0: - fp = client.create("/authz/ns/"+ns+"/responsible/"+id,Void.class); - verb = " is now "; - break; - case 1: - fp = client.delete("/authz/ns/"+ns+"/responsible/"+id,Void.class); - verb = " is no longer "; - break; - default: - throw new CadiException("Bad Argument"); - }; - - if(fp.get(AAFcli.timeout())) { - pw().append(id); - pw().append(verb); - pw().append("responsible for "); - pw().println(ns); - } else { - error(fp); - return fp.code(); - } - } - return fp==null?500:fp.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,"Add or Delete Responsible person to/from Namespace"); - indent+=2; - detailLine(sb,indent,"Responsible persons receive Notifications and approve Requests "); - detailLine(sb,indent,"regarding this Namespace. Companies have Policies as to who may"); - detailLine(sb,indent,"take on this responsibility"); - - indent+=2; - detailLine(sb,indent,"name - Name of Namespace"); - detailLine(sb,indent,"id - Credential of Person(s) to be made responsible"); - sb.append('\n'); - detailLine(sb,indent,"aafcli will call API on each ID presented."); - indent-=4; - api(sb,indent,HttpMethods.POST,"authz/ns//responsible/",Void.class,true); - api(sb,indent,HttpMethods.DELETE,"authz/ns//responsible/",Void.class,false); - } - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Create.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Create.java deleted file mode 100644 index 2c49269e..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Create.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import com.att.aft.dme2.internal.jetty.http.HttpStatus; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.PermRequest; -import aaf.v2_0.RoleRequest; - -/** - * - * - */ -public class Create extends Cmd { - public Create(Perm parent) { - super(parent,"create", - new Param("type",true), - new Param("instance",true), - new Param("action", true), - new Param("role[,role]* (to Grant to)", false) - ); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - final PermRequest pr = new PermRequest(); - pr.setType(args[idx++]); - pr.setInstance(args[idx++]); - pr.setAction(args[idx++]); - String roleCommas = (args.length>idx)?args[idx++]:null; - String[] roles = roleCommas==null?null:roleCommas.split("\\s*,\\s*"); - boolean force = aafcli.forceString()!=null; - int rv; - - if(roles!=null && force) { // Make sure Roles are Created - RoleRequest rr = new RoleRequest(); - for(String role : roles) { - rr.setName(role);; - Future fr = client.create( - "/authz/role", - getDF(RoleRequest.class), - rr - ); - fr.get(AAFcli.timeout()); - switch(fr.code()){ - case 201: - pw().println("Created Role [" + role + ']'); - break; - case 409: - break; - default: - pw().println("Role [" + role + "] does not exist, and cannot be created."); - return HttpStatus.PARTIAL_CONTENT_206; - } - } - } - - // Set Start/End commands - setStartEnd(pr); - setQueryParamsOn(client); - Future fp = client.create( - "/authz/perm", - getDF(PermRequest.class), - pr - ); - if(fp.get(AAFcli.timeout())) { - rv = fp.code(); - pw().println("Created Permission"); - if(roles!=null) { - if(aafcli.forceString()!=null) { // Make sure Roles are Created - RoleRequest rr = new RoleRequest(); - for(String role : roles) { - rr.setName(role);; - Future fr = client.create( - "/authz/role", - getDF(RoleRequest.class), - rr - ); - fr.get(AAFcli.timeout()); - switch(fr.code()){ - case 201: - case 409:break; - default: - - } - } - } - - try { - if(201!=(rv=((Perm)parent)._exec(0, - new String[] {"grant",pr.getType(),pr.getInstance(),pr.getAction(),roleCommas}))) { - rv = HttpStatus.PARTIAL_CONTENT_206; - } - } catch (LocatorException e) { - throw new CadiException(e); - } - } - } else { - rv = fp.code(); - if(rv==409 && force) { - rv = 201; - } else if(rv==202) { - pw().println("Permission Creation Accepted, but requires Approvals before actualizing"); - if (roles!=null) - pw().println("You need to grant the roles after approval."); - } else { - error(fp); - } - } - return rv; - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,"Create a Permission with:"); - detailLine(sb,indent+=2,"type - A Namespace qualified identifier identifying the kind of"); - detailLine(sb,indent+11,"resource to be protected"); - detailLine(sb,indent,"instance - A name that distinguishes a particular instance of resource"); - detailLine(sb,indent,"action - What kind of action is allowed"); - detailLine(sb,indent,"role(s) - Perms granted to these Comma separated Role(s)"); - detailLine(sb,indent+11,"Nonexistent role(s) will be created, if in same namespace"); - sb.append('\n'); - detailLine(sb,indent+2,"Note: Instance and Action can be a an '*' (enter \\\\* on Unix Shell)"); - api(sb,indent,HttpMethods.POST,"authz/perm",PermRequest.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Delete.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Delete.java deleted file mode 100644 index 80bdf4fd..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Delete.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.PermRequest; - -/** - * - */ -public class Delete extends Cmd { - public Delete(Perm parent) { - super(parent,"delete", - new Param("type",true), - new Param("instance",true), - new Param("action", true)); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - // Object Style Delete - PermRequest pk = new PermRequest(); - pk.setType(args[idx++]); - pk.setInstance(args[idx++]); - pk.setAction(args[idx++]); - - // Set "Force" if set - setQueryParamsOn(client); - Future fp = client.delete( - "/authz/perm", - getDF(PermRequest.class), - pk); - if(fp.get(AAFcli.timeout())) { - pw().println("Deleted Permission"); - } else { - if(fp.code()==202) { - pw().println("Permission Deletion Accepted, but requires Approvals before actualizing"); - } else { - error(fp); - } - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,"Delete a Permission with type,instance and action"); - detailLine(sb,indent+4,"see Create for definitions"); - api(sb,indent,HttpMethods.DELETE,"authz/perm",PermRequest.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Describe.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Describe.java deleted file mode 100644 index 89251996..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Describe.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.PermRequest; - -public class Describe extends Cmd { - private static final String PERM_PATH = "/authz/perm"; - public Describe(Perm parent) { - super(parent,"describe", - new Param("type",true), - new Param("instance", true), - new Param("action", true), - new Param("description",true)); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - String type = args[idx++]; - String instance = args[idx++]; - String action = args[idx++]; - StringBuilder desc = new StringBuilder(); - while (idx < args.length) { - desc.append(args[idx++] + ' '); - } - - PermRequest pr = new PermRequest(); - pr.setType(type); - pr.setInstance(instance); - pr.setAction(action); - pr.setDescription(desc.toString()); - - // Set Start/End commands - setStartEnd(pr); - - Future fp = null; - int rv; - - fp = client.update( - PERM_PATH, - getDF(PermRequest.class), - pr - ); - - if(fp.get(AAFcli.timeout())) { - rv=fp.code(); - pw().println("Description added to Permission"); - } else { - if((rv=fp.code())==202) { - pw().print("Adding description"); - pw().println(" Accepted, but requires Approvals before actualizing"); - } else { - error(fp); - } - } - return rv; - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,"Add a description to a permission"); - api(sb,indent,HttpMethods.PUT,"authz/perm",PermRequest.class,true); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Grant.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Grant.java deleted file mode 100644 index d9145678..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Grant.java +++ /dev/null @@ -1,151 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Pkey; -import aaf.v2_0.RolePermRequest; - -/** - * - * - */ -public class Grant extends Cmd { - private final static String[] options = {"grant","ungrant","setTo"}; - - public Grant(Perm parent) { - super(parent,null, - new Param(optionsToString(options),true), - new Param("type",true), - new Param("instance",true), - new Param("action",true), - new Param("role[,role]* (!REQ S)",false) - ); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - String action = args[idx++]; - int option = whichOption(options, action); - - RolePermRequest rpr = new RolePermRequest(); - Pkey pk = new Pkey(); - pk.setType(args[idx++]); - pk.setInstance(args[idx++]); - pk.setAction(args[idx++]); - rpr.setPerm(pk); - setStartEnd(rpr); - - Future frpr = null; - - if (option != 2) { - String[] roles = args[idx++].split(","); - String strA,strB; - for(String role : roles) { - rpr.setRole(role); - if(option==0) { - // You can request to Grant Permission to a Role - setQueryParamsOn(client); - frpr = client.create( - "/authz/role/perm", - getDF(RolePermRequest.class), - rpr - ); - strA = "Granted Permission ["; - strB = "] to Role ["; - } else { - // You can request to UnGrant Permission to a Role - setQueryParamsOn(client); - frpr = client.delete( - "/authz/role/" + role + "/perm", - getDF(RolePermRequest.class), - rpr - ); - strA = "UnGranted Permission ["; - strB = "] from Role ["; - } - if(frpr.get(AAFcli.timeout())) { - pw().println(strA + pk.getType() + '|' + pk.getInstance() + '|' + pk.getAction() - + strB + role +']'); - } else { - if (frpr.code()==202) { - pw().print("Permission Role "); - pw().print(option==0?"Granted":"Ungranted"); - pw().println(" Accepted, but requires Approvals before actualizing"); - } else { - error(frpr); - idx=Integer.MAX_VALUE; - } - } - } - } else { - String allRoles = ""; - if (idx < args.length) - allRoles = args[idx++]; - - rpr.setRole(allRoles); - frpr = client.update( - "/authz/role/perm", - getDF(RolePermRequest.class), - rpr); - if(frpr.get(AAFcli.timeout())) { - pw().println("Set Permission's Roles to [" + allRoles + "]"); - } else { - error(frpr); - } - } - return frpr==null?0:frpr.code(); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,"Grant a Permission to a Role or Roles OR"); - detailLine(sb,indent,"Ungrant a Permission from a Role or Roles OR"); - detailLine(sb,indent,"Set a Permission's roles to roles supplied."); - detailLine(sb,indent+4,"WARNING: Roles supplied with setTo will be the ONLY roles attached to this permission"); - detailLine(sb,indent+8,"If no roles are supplied, permission's roles are reset."); - detailLine(sb,indent,"see Create for definitions of type,instance and action"); - api(sb,indent,HttpMethods.POST,"authz/role/perm",RolePermRequest.class,true); - api(sb,indent,HttpMethods.DELETE,"authz/role//perm",RolePermRequest.class,false); - api(sb,indent,HttpMethods.PUT,"authz/role/perm",RolePermRequest.class,false); - - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/List.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/List.java deleted file mode 100644 index b29d6ee1..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/List.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.BaseCmd; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Nss; -import aaf.v2_0.Perms; -import aaf.v2_0.Pkey; - - -public class List extends BaseCmd { -// private static final String LIST_PERM_DETAILS = "list permission details"; - - public List(Perm parent) { - super(parent,"list"); - - cmds.add(new ListByUser(this)); - cmds.add(new ListByName(this)); - cmds.add(new ListByNS(this)); - cmds.add(new ListByRole(this)); - cmds.add(new ListActivity(this)); - } - // Package Level on purpose - abstract class ListPerms extends Retryable { - protected int list(Future fp,Rcli client, String header, String parentPerm) throws CadiException, APIException { - if(fp.get(AAFcli.timeout())) { - ArrayList permNss = null; - if (aafcli.isDetailed()) { - permNss = new ArrayList(); - String permNs = null; - for(Pkey perm : fp.value.getPerm()) { - if (permNs != null && perm.getType().contains(permNs)) { - permNss.add(permNs); - } else { - Future fpn = null; - String permType = perm.getType(); - permNs = permType; - do { - permNs = permType.substring(0,permNs.lastIndexOf('.')); - fpn = client.read("/authz/nss/"+permNs,getDF(Nss.class)); - } while (!fpn.get(AAFcli.timeout())); - permNss.add(permNs); - } - } - } - report(fp,permNss,header, parentPerm); - } else { - error(fp); - } - return fp.code(); - } - } - - private static final Comparator permCompare = new Comparator() { - @Override - public int compare(aaf.v2_0.Perm a, aaf.v2_0.Perm b) { - int rc; - if((rc=a.getType().compareTo(b.getType()))!=0) { - return rc; - } - if((rc=a.getInstance().compareTo(b.getInstance()))!=0) { - return rc; - } - return a.getAction().compareTo(b.getAction()); - } - }; - - void report(Future fp, ArrayList permNss, String ... str) { - reportHead(str); - if (this.aafcli.isDetailed()) { - String format = reportColHead("%-20s %-15s %-30s %-15s\n %-75s\n","PERM NS","Type","Instance","Action", "Description"); - Collections.sort(fp.value.getPerm(),permCompare); - for(aaf.v2_0.Perm p : fp.value.getPerm()) { - String permNs = permNss.remove(0); - pw().format(format, - permNs, - p.getType().substring(permNs.length()+1), - p.getInstance(), - p.getAction(), - p.getDescription()==null?"":p.getDescription()); - } - pw().println(); - } else { - String format = reportColHead("%-30s %-30s %-10s\n","PERM Type","Instance","Action"); - - Collections.sort(fp.value.getPerm(),permCompare); - for(aaf.v2_0.Perm p : fp.value.getPerm()) { - pw().format(format, - p.getType(), - p.getInstance(), - p.getAction()); - } - pw().println(); - } - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListActivity.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListActivity.java deleted file mode 100644 index 28709b4a..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListActivity.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.History; - -/** - * - */ -public class ListActivity extends Cmd { - private static final String HEADER = "List Activity of Permission"; - - public ListActivity(List parent) { - super(parent,"activity", - new Param("type",true)); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - String type = args[idx++]; - Future fp = client.read( - "/authz/hist/perm/"+type, - getDF(History.class) - ); - if(fp.get(AAFcli.timeout())) { - activity(fp.value, HEADER + " [ " + type + " ]"); - } else { - error(fp); - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/hist/perm/",History.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByNS.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByNS.java deleted file mode 100644 index 24aa9900..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByNS.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Perms; - -/** - * Return Perms by NS - * - * - */ -public class ListByNS extends Cmd { - private static final String HEADER = "List Perms by NS "; - - public ListByNS(List parent) { - super(parent,"ns", - new Param("name",true)); - } - - public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException { - final String ns=args[idx]; - - return same(((List)parent).new ListPerms() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp = client.read( - "/authz/perms/ns/"+ns, - getDF(Perms.class) - ); - return list(fp,client, HEADER, ns); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/perms/ns/",Perms.class,true); - } - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByName.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByName.java deleted file mode 100644 index b2ae4717..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByName.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Perms; - -/** - * - * - */ -public class ListByName extends Cmd { - private static final String HEADER = "List Child Permissions"; - - public ListByName(List parent) { - super(parent,"name", - new Param("root perm name",true)); - } - - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(((List)parent).new ListPerms() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - String parentPerm=args[index]; - - Future fp = client.read( - "/authz/perms/"+parentPerm, - getDF(Perms.class) - ); - return list(fp,client,HEADER,parentPerm); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/perms/",Perms.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByRole.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByRole.java deleted file mode 100644 index 8f387c06..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByRole.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Perms; - -/** - * Return Perms by Role - * - * - */ -public class ListByRole extends Cmd { - private static final String HEADER = "List Perms by Role "; - - public ListByRole(List parent) { - super(parent,"role", - new Param("name",true)); - } - - public int _exec(final int idx, final String ... args) throws CadiException, APIException, LocatorException { - final String role=args[idx]; - - return same(((List)parent).new ListPerms() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - - Future fp = client.read( - "/authz/perms/role/"+role, - getDF(Perms.class) - ); - return list(fp,client, HEADER, role); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/perms/role/",Perms.class,true); - } - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByUser.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByUser.java deleted file mode 100644 index b08fb4e1..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByUser.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Perms; - -/** - * - * - */ -public class ListByUser extends Cmd { - private static final String HEADER = "List Permissions by User"; - public ListByUser(List parent) { - super(parent,"user", - new Param("id",true)); - } - - public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException { - String user=args[idx]; - String realm = getOrgRealm(); - final String fullUser; - if (user.indexOf('@') < 0 && realm != null) - fullUser = user + '@' + realm; - else - fullUser = user; - - return same(((List)parent).new ListPerms() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp = client.read( - "/authz/perms/user/"+fullUser, - getDF(Perms.class) - ); - return list(fp, client, HEADER, fullUser); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/perms/user/",Perms.class,true); - } - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Perm.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Perm.java deleted file mode 100644 index 5810998c..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Perm.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import org.onap.aaf.cmd.BaseCmd; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.inno.env.APIException; - -public class Perm extends BaseCmd { - Role role; - - public Perm(Role role) throws APIException { - super(role.aafcli, "perm"); - this.role = role; - - cmds.add(new Create(this)); - cmds.add(new Delete(this)); - cmds.add(new Grant(this)); - cmds.add(new Rename(this)); - cmds.add(new Describe(this)); - cmds.add(new List(this)); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Rename.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Rename.java deleted file mode 100644 index 01985693..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Rename.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.PermRequest; - -public class Rename extends Cmd { - public Rename(Perm parent) { - super(parent,"rename", - new Param("type",true), - new Param("instance",true), - new Param("action", true), - new Param("new type",true), - new Param("new instance",true), - new Param("new action", true) - ); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - String origType = args[idx++]; - String origInstance = args[idx++]; - String origAction = args[idx++]; - - //Create new permission - PermRequest pr = new PermRequest(); - pr.setType(args[idx++]); - pr.setInstance(args[idx++]); - pr.setAction(args[idx++]); - - // Set Start/End commands - setStartEnd(pr); - Future fp = client.update( - "/authz/perm/"+origType+"/"+origInstance+"/"+origAction, - getDF(PermRequest.class), - pr - ); - int rv; - if(fp.get(AAFcli.timeout())) { - rv = fp.code(); - pw().println("Updated Permission"); - } else { - rv = fp.code(); - if(rv==202) { - pw().println("Permission Update Accepted, but requires Approvals before actualizing"); - } else { - error(fp); - } - } - return rv; - } - }); - - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,"Rename a Permission from:"); - detailLine(sb,indent+2," "); - detailLine(sb,indent,"to:"); - detailLine(sb,indent+2," "); - sb.append('\n'); - detailLine(sb,indent,"Namespace must be the same in and "); - detailLine(sb,indent+4,"see Create for definitions of type,instance and action"); - api(sb,indent,HttpMethods.PUT,"authz/perm///",PermRequest.class,true); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/CreateDelete.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/role/CreateDelete.java deleted file mode 100644 index 78ab1811..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/CreateDelete.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import com.att.aft.dme2.internal.jetty.http.HttpStatus; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.RoleRequest; - -/** - * - * - */ -public class CreateDelete extends Cmd { - private static final String ROLE_PATH = "/authz/role"; - private final static String[] options = {"create","delete"}; - public CreateDelete(Role parent) { - super(parent,null, - new Param(optionsToString(options),true), - new Param("name",true)); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - String action = args[idx++]; - int option = whichOption(options, action); - - RoleRequest rr = new RoleRequest(); - rr.setName(args[idx++]); - - // Set Start/End commands - setStartEnd(rr); - - Future fp = null; - String verb = null; - int rv; - switch(option) { - case 0: - fp = client.create( - ROLE_PATH, - getDF(RoleRequest.class), - rr - ); - verb = "Create"; - break; - case 1: - // Send "Force" if set - setQueryParamsOn(client); - fp = client.delete( - ROLE_PATH, // +args[idx++], - getDF(RoleRequest.class), - rr - ); - verb = "Delete"; - break; - default: // note, if not an option, whichOption throws Exception - break; - - } - boolean rolesSupplied = (args.length>idx); - if(fp.get(AAFcli.timeout())) { - rv=fp.code(); - pw().print(verb); - pw().println("d Role"); - if(rolesSupplied) { - for(;args.length>idx;++idx ) { - try { - if(201!=(rv=((Role)parent)._exec(0,new String[] {"user","add",rr.getName(),args[idx]}))) { - rv = HttpStatus.PARTIAL_CONTENT_206; - } - } catch (LocatorException e) { - throw new CadiException(e); - } - } - } - } else { - if((rv=fp.code())==202) { - pw().print("Role "); - pw().print(verb); - pw().println(" Accepted, but requires Approvals before actualizing"); - } else { - error(fp); - } - } - return rv; - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,"Create OR Delete a Role"); - detailLine(sb,indent+2,"name - Name of Role to create"); - api(sb,indent,HttpMethods.POST,"authz/role",RoleRequest.class,true); - api(sb,indent,HttpMethods.DELETE,"authz/role",RoleRequest.class,false); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/Describe.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/role/Describe.java deleted file mode 100644 index d5fa19e0..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/Describe.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.RoleRequest; - -public class Describe extends Cmd { - private static final String ROLE_PATH = "/authz/role"; - public Describe(Role parent) { - super(parent,"describe", - new Param("name",true), - new Param("description",true)); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - String role = args[idx++]; - StringBuilder desc = new StringBuilder(); - while (idx < args.length) { - desc.append(args[idx++] + ' '); - } - - RoleRequest rr = new RoleRequest(); - rr.setName(role); - rr.setDescription(desc.toString()); - - // Set Start/End commands - setStartEnd(rr); - - Future fp = null; - int rv; - - fp = client.update( - ROLE_PATH, - getDF(RoleRequest.class), - rr - ); - - if(fp.get(AAFcli.timeout())) { - rv=fp.code(); - pw().println("Description added to role"); - } else { - if((rv=fp.code())==202) { - pw().print("Adding description"); - pw().println(" Accepted, but requires Approvals before actualizing"); - } else { - error(fp); - } - } - return rv; - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,"Add a description to a role"); - api(sb,indent,HttpMethods.PUT,"authz/role",RoleRequest.class,true); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/List.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/role/List.java deleted file mode 100644 index 33f9a99f..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/List.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.BaseCmd; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Nss; -import aaf.v2_0.Pkey; -import aaf.v2_0.Roles; - - - -public class List extends BaseCmd { - private static final String LIST_ROLES_BY_NAME = "list roles for role"; - - public List(Role parent) { - super(parent,"list"); - cmds.add(new ListByUser(this)); - cmds.add(new ListByRole(this)); - cmds.add(new ListByNS(this)); - cmds.add(new ListByNameOnly(this)); - cmds.add(new ListByPerm(this)); - cmds.add(new ListActivity(this)); - } - - // Package Level on purpose - abstract class ListRoles extends Retryable { - protected int list(Future fp,Rcli client, String header) throws APIException, CadiException { - if(fp.get(AAFcli.timeout())) { - Future fn = null; - ArrayList roleNss = null; - ArrayList permNss = null; - if (aafcli.isDetailed()) { - roleNss = new ArrayList(); - permNss = new ArrayList(); - for(aaf.v2_0.Role p : fp.value.getRole()) { - String roleNs = p.getName(); - do { - roleNs = p.getName().substring(0,roleNs.lastIndexOf('.')); - fn = client.read("/authz/nss/"+roleNs,getDF(Nss.class)); - } while (!fn.get(AAFcli.timeout())); - roleNss.add(roleNs); - - for(Pkey perm : p.getPerms()) { - if (perm.getType().contains(roleNs)) - permNss.add(roleNs); - else { - Future fpn = null; - String permType = perm.getType(); - String permNs = permType; - do { - permNs = permType.substring(0,permNs.lastIndexOf('.')); - fpn = client.read("/authz/nss/"+permNs,getDF(Nss.class)); - } while (!fpn.get(AAFcli.timeout())); - permNss.add(permNs); - } - } - } - } - report(fp,roleNss,permNss,null,header); - } else { - error(fp); - } - return fp.code(); - } - } - - private final static String roleFormat = "%-50s\n"; - - private static final Comparator roleCompare = new Comparator() { - @Override - public int compare(aaf.v2_0.Role a, aaf.v2_0.Role b) { - return a.getName().compareTo(b.getName()); - } - }; - public void report(Future fp, ArrayList roleNss, ArrayList permNss, - HashMap expiredMap, String ... str) { - reportHead(str); - if (fp != null && aafcli.isDetailed() && str[0].toLowerCase().contains(LIST_ROLES_BY_NAME)) { - String description = fp.value.getRole().get(0).getDescription(); - if (description == null) description = ""; - reportColHead("%-80s\n","Description: " + description); - } - - if(fp==null) { - pw().println(""); - } else if (aafcli.isDetailed()){ - String permFormat = " %-20s %-15s %-30s %-15s\n"; - String fullFormat = roleFormat+permFormat; - reportColHead(fullFormat,"[ROLE NS].Name","PERM NS","Type","Instance","Action"); - Collections.sort(fp.value.getRole(),roleCompare); - for(aaf.v2_0.Role p : fp.value.getRole()) { - String roleNs = roleNss.remove(0); - pw().format(roleFormat, "["+roleNs+"]"+p.getName().substring(roleNs.length())); - for(Pkey perm : p.getPerms()) { - String permNs = permNss.remove(0); - pw().format(permFormat, - permNs, - perm.getType().substring(permNs.length()+1), - perm.getInstance(), - perm.getAction()); - } - } - } else { - String permFormat = " %-30s %-30s %-15s\n"; - String fullFormat = roleFormat+permFormat; - reportColHead(fullFormat,"ROLE Name","PERM Type","Instance","Action"); - Collections.sort(fp.value.getRole(),roleCompare); - for(aaf.v2_0.Role p : fp.value.getRole()) { - if (expiredMap != null) { - String roleName = p.getName(); - Boolean b = expiredMap.get(roleName); - if (b != null && b.booleanValue()) - pw().format(roleFormat, roleName+"*"); - else { - pw().format(roleFormat, roleName); - for(Pkey perm : p.getPerms()) { - pw().format(permFormat, - perm.getType(), - perm.getInstance(), - perm.getAction()); - } - } - } else { - pw().format(roleFormat, p.getName()); - for(Pkey perm : p.getPerms()) { - pw().format(permFormat, - perm.getType(), - perm.getInstance(), - perm.getAction()); - } - } - } - } - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListActivity.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListActivity.java deleted file mode 100644 index 780bb480..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListActivity.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.History; - -/** - * - */ -public class ListActivity extends Cmd { - private static final String HEADER = "List Activity of Role"; - - public ListActivity(List parent) { - super(parent,"activity", - new Param("name",true)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - final String role = args[idx++]; - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp = client.read( - "/authz/hist/role/"+role, - getDF(History.class) - ); - if(fp.get(AAFcli.timeout())) { - activity(fp.value,HEADER + " [ " + role + " ]"); - } else { - error(fp); - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/hist/role/",History.class,true); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByNS.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByNS.java deleted file mode 100644 index 35ef634c..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByNS.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Roles; - -/** - * Return Roles by NS - * - * - */ -public class ListByNS extends Cmd { - private static final String HEADER = "List Roles by NS "; - - public ListByNS(List parent) { - super(parent,"ns", - new Param("name",true)); - } - - @Override - public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException { - final String ns=args[idx]; - - return same(((List)parent).new ListRoles() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp = client.read( - "/authz/roles/ns/"+ns, - getDF(Roles.class) - ); - return list(fp,client, HEADER+"["+ns+"]"); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/roles/name/",Roles.class,true); - } - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByNameOnly.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByNameOnly.java deleted file mode 100644 index 5db02e4e..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByNameOnly.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Roles; - -/** - * Return Roles by NS - * - * - */ -public class ListByNameOnly extends Cmd { - private static final String HEADER = "List Roles by Name "; - - public ListByNameOnly(List parent) { - super(parent,"name", - new Param("name",true)); - } - - @Override - public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException { - final String name=args[idx]; - - return same(((List)parent).new ListRoles() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp = client.read( - "/authz/roles/name/"+name, - getDF(Roles.class) - ); - return list(fp,client, HEADER+"["+name+"]"); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/roles/name/",Roles.class,true); - } - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByPerm.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByPerm.java deleted file mode 100644 index 4fcdca9a..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByPerm.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Roles; - -/** - * Return Roles by NS - * - * - */ -public class ListByPerm extends Cmd { - private static final String HEADER = "List Roles by Perm "; - - public ListByPerm(List parent) { - super(parent,"perm", - new Param("type",true), - new Param("instance", true), - new Param("action", true)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - final String type=args[idx]; - final String instance=args[++idx]; - final String action=args[++idx]; - - return same(((List)parent).new ListRoles() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - - Future fp = client.read( - "/authz/roles/perm/"+type+'/'+instance+'/'+action, - getDF(Roles.class) - ); - return list(fp,client, HEADER+type+'|'+instance+'|'+action); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/roles/user/",Roles.class,true); - } - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByRole.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByRole.java deleted file mode 100644 index f4db5141..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByRole.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Roles; - -/** - * - * - */ -public class ListByRole extends Cmd { - private static final String HEADER="List Roles for Role"; - - public ListByRole(List parent) { - super(parent,"role", - new Param("role",true)); - } - - @Override - public int _exec(final int idx, final String ... args) throws CadiException, APIException, LocatorException { - return same(((List)parent).new ListRoles() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - String role=args[idx]; - Future fp = client.read( - "/authz/roles/"+role, - getDF(Roles.class) - ); - return list(fp,client,HEADER+"["+role+"]"); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/roles/",Roles.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByUser.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByUser.java deleted file mode 100644 index b333dec3..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByUser.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import java.util.ArrayList; -import java.util.HashMap; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.util.Chrono; - -import aaf.v2_0.Nss; -import aaf.v2_0.Pkey; -import aaf.v2_0.Roles; -import aaf.v2_0.Users; - -/** - * p - * - */ -public class ListByUser extends Cmd { - private static final String HEADER = "List Roles for User "; - - public ListByUser(List parent) { - super(parent,"user", - new Param("id",true)); - } - - @Override - public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException { - String user=args[idx]; - String realm = getOrgRealm(); - final String fullUser; - if (user.indexOf('@') < 0 && realm != null) { - fullUser = user + '@' + realm; - } else { - fullUser = user; - } - - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - - Future fp = client.read( - "/authz/roles/user/"+fullUser, - getDF(Roles.class) - ); - if(fp.get(AAFcli.timeout())) { - Future fn = null; - ArrayList roleNss = null; - ArrayList permNss = null; - HashMap expiredMap = new HashMap(); - if (aafcli.isDetailed()) { - roleNss = new ArrayList(); - permNss = new ArrayList(); - for(aaf.v2_0.Role p : fp.value.getRole()) { - String roleNs = p.getName(); - do { - roleNs = p.getName().substring(0,roleNs.lastIndexOf('.')); - fn = client.read("/authz/nss/"+roleNs,getDF(Nss.class)); - } while (!fn.get(AAFcli.timeout())); - roleNss.add(roleNs); - - for(Pkey perm : p.getPerms()) { - if (perm.getType().contains(roleNs)) { - permNss.add(roleNs); - } else { - Future fpn = null; - String permType = perm.getType(); - String permNs = permType; - do { - permNs = permType.substring(0,permNs.lastIndexOf('.')); - fpn = client.read("/authz/nss/"+permNs,getDF(Nss.class)); - } while (!fpn.get(AAFcli.timeout())); - permNss.add(permNs); - } - } - } - } - - if (fp.value != null) { - for(aaf.v2_0.Role p : fp.value.getRole()) { - Future fu = client.read( - "/authz/userRole/"+fullUser+"/"+p.getName(), - getDF(Users.class) - ); - if (fu.get(5000)) { - if(fu.value != null) { - for (Users.User u : fu.value.getUser()) { - if(u.getExpires().normalize().compare(Chrono.timeStamp().normalize()) > 0) { - expiredMap.put(p.getName(), new Boolean(false)); - } else { - expiredMap.put(p.getName(), new Boolean(true)); - } - } - } - } - } - } - - ((List)parent).report(fp,roleNss,permNss,expiredMap,HEADER,fullUser); - } else { - error(fp); - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/roles/user/",Roles.class,true); - } - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/Role.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/role/Role.java deleted file mode 100644 index 4b5c2256..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/Role.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.BaseCmd; - -import org.onap.aaf.inno.env.APIException; - -public class Role extends BaseCmd { - public List list; - - public Role(AAFcli aafcli) throws APIException { - super(aafcli, "role"); - cmds.add(new CreateDelete(this)); -// cmds.add(new Delete(this)); - cmds.add(new User(this)); - cmds.add(new Describe(this)); - cmds.add(list = new List(this)); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/User.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/role/User.java deleted file mode 100644 index 239ab844..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/role/User.java +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.UserRoleRequest; - -/** - * p - * - */ -public class User extends Cmd { - private final static String[] options = {"add","del","setTo","extend"}; - public User(Role parent) { - super(parent,"user", - new Param(optionsToString(options),true), - new Param("role",true), - new Param("id[,id]* (not required for setTo)",false)); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - String realm = getOrgRealm(); - String action = args[idx++]; - int option = whichOption(options, action); - UserRoleRequest urr = new UserRoleRequest(); - urr.setRole(args[idx++]); - // Set Start/End commands - setStartEnd(urr); - - Future fp = null; - - if (option != 2) { - String[] ids = args[idx++].split(","); - String verb=null,participle=null; - // You can request to be added or removed from role. - setQueryParamsOn(client); - - for(String id: ids) { - if (id.indexOf('@') < 0 && realm != null) id += '@' + realm; - urr.setUser(id); - switch(option) { - case 0: - fp = client.create( - "/authz/userRole", - getDF(UserRoleRequest.class), - urr); - verb = "Added"; - participle = "] to Role [" ; - break; - case 1: - fp = client.delete( - "/authz/userRole/"+urr.getUser()+'/'+urr.getRole(), - Void.class); - verb = "Removed"; - participle = "] from Role [" ; - break; - case 3: - fp = client.update("/authz/userRole/extend/" + urr.getUser() + '/' + urr.getRole()); - verb = "Extended"; - participle = "] in Role [" ; - break; - - default: // actually, should never get here... - throw new CadiException("Invalid action [" + action + ']'); - } - if(fp.get(AAFcli.timeout())) { - pw().print(verb); - pw().print(" User ["); - pw().print(urr.getUser()); - pw().print(participle); - pw().print(urr.getRole()); - pw().println(']'); - } else { - switch(fp.code()) { - case 202: - pw().print("User Role "); - pw().print(action); - pw().println(" is Accepted, but requires Approvals before actualizing"); - break; - case 404: - if(option==3) { - pw().println("Failed with code 404: UserRole is not found, or you do not have permission to view"); - break; - } - default: - error(fp); - } - } - } - } else { - String allUsers = ""; - if (idx < args.length) - allUsers = args[idx++]; - StringBuilder finalUsers = new StringBuilder(); - for (String u : allUsers.split(",")) { - if (u != "") { - if (u.indexOf('@') < 0 && realm != null) u += '@' + realm; - if (finalUsers.length() > 0) finalUsers.append(","); - finalUsers.append(u); - } - } - - urr.setUser(finalUsers.toString()); - fp = client.update( - "/authz/userRole/role", - getDF(UserRoleRequest.class), - urr); - if(fp.get(AAFcli.timeout())) { - pw().println("Set the Role to Users [" + allUsers + "]"); - } else { - error(fp); - } - } - return fp==null?0:fp.code(); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,"Add OR Delete a User to/from a Role OR"); - detailLine(sb,indent,"Set a User's Roles to the roles supplied"); - detailLine(sb,indent+2,"role - Name of Role to create"); - detailLine(sb,indent+2,"id(s) - ID or IDs to add to the Role"); - sb.append('\n'); - detailLine(sb,indent+2,"Note: this is the same as \"user role add...\" except allows"); - detailLine(sb,indent+2,"assignment of role to multiple userss"); - detailLine(sb,indent+2,"WARNING: Users supplied with setTo will be the ONLY users attached to this role"); - detailLine(sb,indent+2,"If no users are supplied, the users attached to this role are reset."); - api(sb,indent,HttpMethods.POST,"authz/userRole",UserRoleRequest.class,true); - api(sb,indent,HttpMethods.DELETE,"authz/userRole//",Void.class,false); - api(sb,indent,HttpMethods.PUT,"authz/userRole/",UserRoleRequest.class,false); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/Cred.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/user/Cred.java deleted file mode 100644 index b6fd83fe..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/Cred.java +++ /dev/null @@ -1,153 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.CredRequest; - -public class Cred extends Cmd { - private static final String CRED_PATH = "/authn/cred"; - private static final String[] options = {"add","del","reset","extend"/*,"clean"*/}; -// private Clean clean; - public Cred(User parent) { - super(parent,"cred", - new Param(optionsToString(options),true), - new Param("id",true), - new Param("password (! D|E)",false), - new Param("entry# (if multi)",false) - ); -// clean = new Clean(this); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - String key = args[idx++]; - final int option = whichOption(options,key); - - final CredRequest cr = new CredRequest(); - cr.setId(args[idx++]); - if(option!=1 && option!=3) { - if(idx>=args.length) throw new CadiException("Password Required"); - cr.setPassword(args[idx++]); - } - if(args.length>idx) - cr.setEntry(args[idx++]); - - // Set Start/End commands - setStartEnd(cr); -// final int cleanIDX = _idx+1; - Integer ret = same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp=null; - String verb =null; - switch(option) { - case 0: - fp = client.create( - CRED_PATH, - getDF(CredRequest.class), - cr - ); - verb = "Added Credential ["; - break; - case 1: -// if(aafcli.addForce())cr.setForce("TRUE"); - setQueryParamsOn(client); - fp = client.delete(CRED_PATH, - getDF(CredRequest.class), - cr - ); - verb = "Deleted Credential ["; - break; - case 2: - fp = client.update( - CRED_PATH, - getDF(CredRequest.class), - cr - ); - verb = "Reset Credential ["; - break; - case 3: - fp = client.update( - CRED_PATH+"/5", - getDF(CredRequest.class), - cr - ); - verb = "Extended Credential ["; - break; -// case 4: -// return clean.exec(cleanIDX, args); - } - if(fp.get(AAFcli.timeout())) { - pw().print(verb); - pw().print(cr.getId()); - pw().println(']'); - } else if(fp.code()==202) { - pw().println("Credential Action Accepted, but requires Approvals before actualizing"); - } else if(fp.code()==406 && option==1) { - pw().println("You cannot delete this Credential"); - } else { - error(fp); - } - return fp.code(); - } - }); - if(ret==null)ret = -1; - return ret; - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,"Add, Delete or Reset Credential"); - indent+=2; - detailLine(sb,indent,"id - the ID to create/delete/reset within AAF"); - detailLine(sb,indent,"password - Company Policy compliant Password (not required for Delete)"); - detailLine(sb,indent,"entry - selected option when deleting/resetting a cred with multiple entries"); - sb.append('\n'); - detailLine(sb,indent,"The Domain can be related to any Namespace you have access to *"); - detailLine(sb,indent,"The Domain is in reverse order of Namespace, i.e. "); - detailLine(sb,indent+2,"NS of com.att.myapp can create user of XY1234@myapp.att.com"); - sb.append('\n'); - detailLine(sb,indent,"NOTE: AAF does support multiple creds with the same ID. Check with your org if you"); - detailLine(sb,indent+2,"have this implemented. (For example, this is implemented for MechIDs at AT&T)"); - sb.append('\n'); - detailLine(sb,indent,"Delegates can be listed by the User or by the Delegate"); - indent-=2; - api(sb,indent,HttpMethods.POST,"authn/cred",CredRequest.class,true); - api(sb,indent,HttpMethods.DELETE,"authn/cred",CredRequest.class,false); - api(sb,indent,HttpMethods.PUT,"authn/cred",CredRequest.class,false); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/Delg.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/user/Delg.java deleted file mode 100644 index edb5c38d..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/Delg.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import java.text.ParseException; -import java.util.Date; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.BaseCmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.util.Chrono; -import org.onap.aaf.rosetta.env.RosettaDF; - -import aaf.v2_0.DelgRequest; - -public class Delg extends BaseCmd { - static final String AUTHZ_DELG = "/authz/delegate"; - private final static String[] options = {"add","upd","del"}; - - public Delg(User user) throws APIException { - super(user,"delegate", - new Param(optionsToString(options),true), - new Param("from",true), - new Param("to REQ A&U",false), - new Param("until (YYYY-MM-DD) REQ A", false) - ); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - String realm = getOrgRealm(); - DelgRequest dr = new DelgRequest(); - setStartEnd(dr); - - int option= whichOption(options, args[idx++]); - String user = args[idx++]; - if (user.indexOf('@') < 0 && realm != null) user += '@' + realm; - dr.setUser(user); - if(option<2) { - String delegate = args[idx++]; - if (delegate.indexOf('@') < 0 && realm != null) delegate += '@' + realm; - dr.setDelegate(delegate); - if(option<2 && args.length>idx) { - Date date; - try { - date = Chrono.dateOnlyFmt.parse(args[idx++]); - } catch (ParseException e) { - throw new CadiException(e); - } - dr.setEnd(Chrono.timeStamp(date)); - } - } - - Future fp; - RosettaDF df = getDF(DelgRequest.class); - String verb; - setQueryParamsOn(client); - - switch(option) { - case 0: - fp = client.create(AUTHZ_DELG, df, dr); - verb = "Added"; - break; - case 1: - fp = client.update(AUTHZ_DELG, df, dr); - verb = "Updated"; - break; - case 2: - fp = client.delete(AUTHZ_DELG, df, dr); - verb = "Deleted"; - break; - default: - throw new CadiException("Bad Argument"); - }; - - if(fp.get(AAFcli.timeout())) { - pw().append("Delegate "); - pw().println(verb); - } else { - error(fp); - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,"Add, Update or Delete Delegate"); - indent+=2; - detailLine(sb,indent,"A Delegate is a person who will temporarily cover the Approval and"); - detailLine(sb,indent,"Ownership questions on behalf of the person Responsible."); - sb.append('\n'); - detailLine(sb,indent,"fromID - the person who is the Responsible person of record"); - detailLine(sb,indent,"toID - the person who will be delegated (required for Add/Update)"); - detailLine(sb,indent,"until - the end date for this delegation"); - indent-=2; - api(sb,indent,HttpMethods.POST,AUTHZ_DELG,DelgRequest.class,true); - api(sb,indent,HttpMethods.DELETE,AUTHZ_DELG,DelgRequest.class,false); - api(sb,indent,HttpMethods.PUT,AUTHZ_DELG,DelgRequest.class,false); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/List.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/user/List.java deleted file mode 100644 index 61779be2..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/List.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import java.util.Collections; -import java.util.Comparator; - -import org.onap.aaf.cmd.BaseCmd; - -import org.onap.aaf.inno.env.util.Chrono; - -import aaf.v2_0.Approval; -import aaf.v2_0.Approvals; -import aaf.v2_0.Delg; -import aaf.v2_0.Delgs; -import aaf.v2_0.Users; - -public class List extends BaseCmd { - - public List(User parent) { - super(parent,"list"); - cmds.add(new ListForRoles(this)); - cmds.add(new ListForPermission(this)); - cmds.add(new ListForCreds(this)); - cmds.add(new ListDelegates(this)); - cmds.add(new ListApprovals(this)); - cmds.add(new ListActivity(this)); - } - - - void report(Users users, boolean count, String ... str) { - reportHead(str); - String format = reportColHead("%-50s %-30s\n","User","Expires"); - String date = "XXXX-XX-XX"; - int idx = 0; - java.util.List sorted = users.getUser(); - Collections.sort(sorted, new Comparator() { - @Override - public int compare(aaf.v2_0.Users.User u1, aaf.v2_0.Users.User u2) { - if(u2==null || u2 == null) { - return -1; - } - return u1.getId().compareTo(u2.getId()); - } - }); - for(aaf.v2_0.Users.User user : sorted) { - if(!aafcli.isTest()) - date = Chrono.dateOnlyStamp(user.getExpires()); - - pw().format(format, - count? (Integer.valueOf(++idx) + ") " + user.getId()): user.getId(), - date); - } - pw().println(); - } - - public void report(Approvals approvals, String title, String id) { - reportHead(title,id); - String format = reportColHead(" %-20s %-20s %-11s %-6s %12s\n","User","Approver","Type","Status","Updated"); - java.util.List lapp = approvals.getApprovals(); - Collections.sort(lapp, new Comparator() { - @Override - public int compare(Approval a1, Approval a2) { - return a1.getTicket().compareTo(a2.getTicket()); - } - } ); - String ticket = null, prev = null; - for(Approval app : lapp ) { - ticket = app.getTicket(); - if(!ticket.equals(prev)) { - pw().print("Ticket: "); - pw().println(ticket); - } - prev = ticket; - - pw().format(format, - app.getUser(), - app.getApprover(), - app.getType(), - app.getStatus(), - Chrono.niceDateStamp(app.getUpdated()) - ); - } - } - - public void report(Delgs delgs, String title, String id) { - reportHead(title,id); - String format = reportColHead(" %-25s %-25s %-10s\n","User","Delegate","Expires"); - String date = "XXXX-XX-XX"; - for(Delg delg : delgs.getDelgs()) { - if(!this.aafcli.isTest()) - date = Chrono.dateOnlyStamp(delg.getExpires()); - pw().printf(format, - delg.getUser(), - delg.getDelegate(), - date - ); - } - } - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListActivity.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListActivity.java deleted file mode 100644 index d8ce4743..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListActivity.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.History; - -/** - * - */ -public class ListActivity extends Cmd { - private static final String HEADER = "List Activity of User"; - - public ListActivity(List parent) { - super(parent,"activity", - new Param("user",true)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - String user = args[idx++]; - String realm = getOrgRealm(); - final String fullUser = (user.indexOf('@') < 0 && realm != null)?user + '@' + realm:user; - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - - Future fp = client.read( - "/authz/hist/user/"+fullUser, - getDF(History.class) - ); - if(fp.get(AAFcli.timeout())) { - activity(fp.value,HEADER + " [ " + fullUser + " ]"); - } else { - error(fp); - } - return fp.code(); - } - }); - } - - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb,indent,HEADER); - api(sb,indent,HttpMethods.GET,"authz/hist/user/",History.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListApprovals.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListApprovals.java deleted file mode 100644 index e478d202..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListApprovals.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Approvals; - -/** - * - * - */ -public class ListApprovals extends Cmd { - private static final String HEADER = "List Approvals"; - private final static String[] options = {"user","approver","ticket"}; - public ListApprovals(List parent) { - super(parent,"approvals", - new Param(optionsToString(options),true), - new Param("value",true)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - final String type = args[idx++]; - int option = whichOption(options,type); - String value = args[idx++]; - final String fullValue; - if (option != 2) { - String realm = getOrgRealm(); - fullValue = (value.indexOf('@')<0 && realm != null)?value +'@'+realm:value; - } else { - fullValue = value; - } - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp = client.read( - "/authz/approval/"+type+'/'+fullValue, - getDF(Approvals.class) - ); - if(fp.get(AAFcli.timeout())) { - ((List)parent).report(fp.value,HEADER + " by " + type,fullValue); - if(fp.code()==404) { - return 200; - } - } else { - error(fp); - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,HEADER); - indent+=2; - detailLine(sb,indent,"Approvals are used when the Requestor does not have the rights"); - detailLine(sb,indent,"to perform the action required. Approvers are those listed as"); - detailLine(sb,indent,"responsible for Namespace associated with the request, and those"); - detailLine(sb,indent,"required by the Company by Policy. This may be, for instance"); - detailLine(sb,indent,"the supervisor of the requestor"); - sb.append('\n'); - detailLine(sb,indent,"Delegates can be listed by User, Approver or Ticket."); - indent-=2; - api(sb,indent,HttpMethods.GET,"authz/approval/user/",Approvals.class,true); - api(sb,indent,HttpMethods.GET,"authz/approval/approver/",Approvals.class,false); - api(sb,indent,HttpMethods.GET,"authz/approval/ticket/",Approvals.class,false); - } - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListDelegates.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListDelegates.java deleted file mode 100644 index 723e302a..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListDelegates.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Delgs; - -/** - * - */ -public class ListDelegates extends Cmd { - private static final String HEADER = "List Delegates"; - private static final String[] options = {"user","delegate"}; - public ListDelegates(List parent) { - super(parent,"delegates", - new Param(optionsToString(options),true), - new Param("id",true)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - String realm = getOrgRealm(); - int idx = _idx; - final String key = args[idx++]; - //int option = whichOption(options,key); - String id = args[idx++]; - final String fullID = (id.indexOf('@') < 0 && realm != null)? id + '@' + realm:id; - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - - Future fp = client.read( - "/authz/delegates/" + key + '/' + fullID, - getDF(Delgs.class) - ); - if(fp.get(AAFcli.timeout())) { - ((List)parent).report(fp.value,HEADER + " by " + key, fullID); - if(fp.code()==404)return 200; - } else { - error(fp); - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,HEADER); - indent+=2; - detailLine(sb,indent,"Delegates are those people temporarily assigned to cover the"); - detailLine(sb,indent,"responsibility of Approving, etc, while the actual Responsible"); - detailLine(sb,indent,"Party is absent. Typically, this is for Vacation, or Business"); - detailLine(sb,indent,"Travel."); - sb.append('\n'); - detailLine(sb,indent,"Delegates can be listed by the User or by the Delegate"); - indent-=2; - api(sb,indent,HttpMethods.GET,"authz/delegates/user/",Delgs.class,true); - api(sb,indent,HttpMethods.GET,"authz/delegates/delegate/",Delgs.class,false); - } - - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForCreds.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForCreds.java deleted file mode 100644 index ec76e175..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForCreds.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import java.util.Collections; -import java.util.Comparator; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Users; -import aaf.v2_0.Users.User; - -/** - * List for Creds - * - */ -public class ListForCreds extends Cmd { - private final static String[] options = {"ns","id"}; - - private static final String HEADER = "List creds for "; - public ListForCreds(List parent) { - super(parent,"cred", - new Param(optionsToString(options),true), - new Param("value",true)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - final int option = whichOption(options, args[idx++]); - final String which = options[option]; - final String value = args[idx++]; - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp = client.read( - "/authn/creds/"+which+'/'+value, - getDF(Users.class) - ); - if(fp.get(AAFcli.timeout())) { - if (aafcli.isTest()) - Collections.sort(fp.value.getUser(), new Comparator() { - @Override - public int compare(User u1, User u2) { - return u1.getId().compareTo(u2.getId()); - } - }); - ((org.onap.aaf.cmd.user.List)parent).report(fp.value,option==1,HEADER+which,value); - if(fp.code()==404)return 200; - } else { - error(fp); - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,HEADER); - indent+=2; - detailLine(sb,indent,"This report lists the users associated to Roles."); - detailLine(sb,indent,"role - the Role name"); - indent-=2; - api(sb,indent,HttpMethods.GET,"authz/users/role/",Users.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForPermission.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForPermission.java deleted file mode 100644 index c433610b..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForPermission.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import java.util.Collections; -import java.util.Comparator; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Users; -import aaf.v2_0.Users.User; - -/** - * p - * - */ -public class ListForPermission extends Cmd { - private static final String HEADER = "List Users for Permission"; - public ListForPermission(List parent) { - super(parent,"perm", - new Param("type",true), - new Param("instance",true), - new Param("action",true)); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - String type = args[idx++]; - String instance = args[idx++]; - if("\\*".equals(instance))instance="*"; - String action = args[idx++]; - if("\\*".equals(action))action="*"; - Future fp = client.read( - "/authz/users/perm/"+type+'/'+instance+'/'+action, - getDF(Users.class) - ); - if(fp.get(AAFcli.timeout())) { - if (aafcli.isTest()) - Collections.sort(fp.value.getUser(), new Comparator() { - @Override - public int compare(User u1, User u2) { - return u1.getId().compareTo(u2.getId()); - } - }); - ((org.onap.aaf.cmd.user.List)parent).report(fp.value,false,HEADER,type+"|"+instance+"|"+action); - if(fp.code()==404)return 200; - } else { - error(fp); - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,HEADER); - indent+=2; - detailLine(sb,indent,"This report lists the users associated to Permissions. Since Users"); - detailLine(sb,indent,"are associated to Roles, and Roles have Permissions, this report"); - detailLine(sb,indent,"accomodates all these linkages."); - sb.append('\n'); - detailLine(sb,indent,"The URL must contain the Permission's type,instance and action, and "); - detailLine(sb,indent,"may include \"*\"s (type in as \\\\*)."); - detailLine(sb,indent,"See Perm Create Documentation for definitions."); - indent-=2; - api(sb,indent,HttpMethods.GET,"authz/users/perm///",Users.class,true); - } -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForRoles.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForRoles.java deleted file mode 100644 index 528a33ba..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForRoles.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import java.util.Collections; -import java.util.Comparator; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.Users; -import aaf.v2_0.Users.User; - -/** - * p - * - */ -public class ListForRoles extends Cmd { - private static final String HEADER = "List Users for Role"; - public ListForRoles(List parent) { - super(parent,"role", new Param("role",true)); - } - - @Override - public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { - int idx = _idx; - final String role = args[idx++]; - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - Future fp = client.read( - "/authz/users/role/"+role, - getDF(Users.class) - ); - if(fp.get(AAFcli.timeout())) { - if (aafcli.isTest()) - Collections.sort(fp.value.getUser(), new Comparator() { - @Override - public int compare(User u1, User u2) { - return u1.getId().compareTo(u2.getId()); - } - }); - ((org.onap.aaf.cmd.user.List)parent).report(fp.value,false, HEADER,role); - if(fp.code()==404)return 200; - } else { - error(fp); - } - return fp.code(); - } - }); - } - - @Override - public void detailedHelp(int _indent, StringBuilder sb) { - int indent = _indent; - detailLine(sb,indent,HEADER); - indent+=2; - detailLine(sb,indent,"This report lists the users associated to Roles."); - detailLine(sb,indent,"role - the Role name"); - indent-=2; - api(sb,indent,HttpMethods.GET,"authz/users/role/",Users.class,true); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/Role.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/user/Role.java deleted file mode 100644 index bf7baaf8..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/Role.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Param; -import org.onap.aaf.cssa.rserv.HttpMethods; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.UserRoleRequest; - -/** - * p - * - * - */ -public class Role extends Cmd { - private static final String[] options = {"add", "del", "setTo","extend"}; - public Role(User parent) { - super(parent, "role", new Param(optionsToString(options), true), new Param("user", true), new Param( - "role[,role]* (!REQ S)", false)); - } - - @Override - public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException { - return same(new Retryable() { - @Override - public Integer code(Rcli client) throws CadiException, APIException { - int idx = index; - String key = args[idx++]; - int option = whichOption(options, key); - String user = args[idx++]; - String realm = getOrgRealm(); - - UserRoleRequest urr = new UserRoleRequest(); - if (user.indexOf('@') < 0 && realm != null) user += '@' + realm; - urr.setUser(user); - // Set Start/End commands - setStartEnd(urr); - - Future fp = null; - - if (option != 2) { - if (args.length < 5) { - throw new CadiException(build(new StringBuilder("Too few args: "), null).toString()); - } - String[] roles = args[idx++].split(","); - for (String role : roles) { - String verb = null,participle=null; - urr.setRole(role); - // You can request to be added or removed from role. - setQueryParamsOn(client); - switch(option) { - case 0: - fp = client.create("/authz/userRole", getDF(UserRoleRequest.class), urr); - verb = "Added"; - participle = "] to User [" ; - break; - case 1: - fp = client.delete("/authz/userRole/" + urr.getUser() + '/' + urr.getRole(), Void.class); - verb = "Removed"; - participle = "] from User [" ; - break; - case 3: - fp = client.update("/authz/userRole/extend/" + urr.getUser() + '/' + urr.getRole()); - verb = "Extended"; - participle = "] to User [" ; - break; - default: - throw new CadiException("Invalid action [" + key + ']'); - } - if (fp.get(AAFcli.timeout())) { - pw().print(verb); - pw().print(" Role ["); - pw().print(urr.getRole()); - pw().print(participle); - pw().print(urr.getUser()); - pw().println(']'); - } else { - switch(fp.code()) { - case 202: - pw().print("UserRole "); - pw().print(option == 0 ? "Creation" : option==1?"Deletion":"Extension"); - pw().println(" Accepted, but requires Approvals before actualizing"); - break; - case 404: - if(option==3) { - pw().println("Failed with code 404: UserRole is not found, or you do not have permission to view"); - break; - } - default: - error(fp); - } - } - } - } else { - // option 2 is setTo command (an update call) - String allRoles = ""; - if (idx < args.length) - allRoles = args[idx++]; - - urr.setRole(allRoles); - fp = client.update("/authz/userRole/user", getDF(UserRoleRequest.class), urr); - if (fp.get(AAFcli.timeout())) { - pw().println("Set User's Roles to [" + allRoles + "]"); - } else { - error(fp); - } - } - return fp == null ? 0 : fp.code(); - } - }); - } - - @Override - public void detailedHelp(int indent, StringBuilder sb) { - detailLine(sb, indent, "Add OR Delete a User to/from a Role OR"); - detailLine(sb, indent, "Set a User's Roles to the roles supplied"); - detailLine(sb, indent + 2, "user - ID of User"); - detailLine(sb, indent + 2, "role(s) - Role or Roles to which to add the User"); - sb.append('\n'); - detailLine(sb, indent + 2, "Note: this is the same as \"role user add...\" except allows"); - detailLine(sb, indent + 2, "assignment of user to multiple roles"); - detailLine(sb, indent + 2, "WARNING: Roles supplied with setTo will be the ONLY roles attached to this user"); - detailLine(sb, indent + 2, "If no roles are supplied, user's roles are reset."); - api(sb, indent, HttpMethods.POST, "authz/userRole", UserRoleRequest.class, true); - api(sb, indent, HttpMethods.DELETE, "authz/userRole//", Void.class, false); - api(sb, indent, HttpMethods.PUT, "authz/userRole/", UserRoleRequest.class, false); - } - -} diff --git a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/User.java b/authz-cmd/src/main/java/org/onap/aaf/cmd/user/User.java deleted file mode 100644 index bfc29cf8..00000000 --- a/authz-cmd/src/main/java/org/onap/aaf/cmd/user/User.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.BaseCmd; - -import org.onap.aaf.inno.env.APIException; - -public class User extends BaseCmd { - public User(AAFcli aafcli) throws APIException { - super(aafcli,"user"); - cmds.add(new Role(this)); - cmds.add(new Cred(this)); - cmds.add(new Delg(this)); - cmds.add(new List(this)); - } -} diff --git a/authz-cmd/src/main/scripts/aaflogin b/authz-cmd/src/main/scripts/aaflogin deleted file mode 100644 index 1c15a432..00000000 --- a/authz-cmd/src/main/scripts/aaflogin +++ /dev/null @@ -1,199 +0,0 @@ -#!/bin/bash -JAVA_HOME=_JAVA_HOME_ -JAVA=${JAVA_HOME}/bin/java -DEFAULT_DOMAIN=XXX_DOMAIN -### -# Give some help hints if first run -# -if [ "`declare -f aaflogout`" = "" ] || [ "$1" = "-h" ]; then - echo - echo " COMMANDS:" - echo " aaflogin -f = Redo Local Login" - echo " aaflogout = Logout from Environment" - echo " aaflogin -r = Reset Password on AAF Service" - echo " aaflogin -h = Help" - echo " aafcli = AAF Management Tool" - echo -fi - -if [ "$1" != "-h" ]; then - - -### -# Load User/Password for aafcli, and create in function. -# -# To use, source aaflogin -# -# ex: . ./aaflogin -# -# -f = force relogin -# -r = reset password sequence -# -# see aaflogout to logout -### - -### -# Gather Classpath - warning, DME2 doesn't work with -Djava.ext.dirs -### -AAF_CP=_ROOT_DIR_/etc -for JAR in `find _ROOT_DIR_/lib -name "*.jar"` ; do - AAF_CP="$AAF_CP:$JAR" -done - -### -# Create Keyfile to use temporarily, if not exists -### -if [ ! -e $HOME/.aaf/keyfile ]; then - mkdir -p $HOME/.aaf - ${JAVA} -cp $AAF_CP org.onap.aaf.cadi.CmdLine keygen $HOME/.aaf/keyfile - chmod 400 $HOME/.aaf/keyfile -fi - -### -# Obtain User ID from AAF_ID, or SUDO_USER or USER, that order -### -if [ "$AAF_ID" == "" ] || [ "$1" == "-f" ] ; then - if [ "$AAF_ID" == "" ] ; then - if [ "$SUDO_USER" != "" ] ; then - AAF_ID=$SUDO_USER - else if [ "$USER" != "" ] ; then - AAF_ID=$USER - fi - fi - fi - - echo -n "Enter AAF ID [$AAF_ID]: " - read TEMP - if [ "$TEMP" != "" ] ; then - AAF_ID=$TEMP - fi - export AAF_ID -fi - -### -# Add Function to remove AAF Vars and Functions from the Shell -# -function aaflogout { - unset AAF_ID - unset AAF_PASS - unset AAF_CP - unset -f aafcli - unset -f cmcli - unset -f aaflogout - rm -f $HOME/.aaf/keyfile -} - - -### -# Load the Password -### -if [ "$AAF_PASS" == "" ] || [ "$1" == "-f" ] ; then - # Ask for User and Password. Assuming Unix and availability of "stty" - if [[ "$AAF_ID" == *"@$DEFAULT_DOMAIN" ]] || [[ "$AAF_ID" != *"@"* ]] ; then - PASS_PROMPT="AT&T Global Login" - AAF_DEFAULT_DOMAIN="-Daaf_default_domain=$DEFAULT_DOMAIN" - else - PASS_PROMPT="AAF" - AAF_DEFAULT_DOMAIN="" - fi - - - read -ers -p "Enter "$PASS_PROMPT" Password for $AAF_ID: " AAF_PASS - echo - AAF_PASS=enc:`$JAVA -cp $AAF_CP $AAF_DEFAULT_DOMAIN org.onap.aaf.cadi.CmdLine digest "$AAF_PASS" $HOME/.aaf/keyfile` - export AAF_PASS -fi - - - -### -# load aafcli function in the Shell -### - -function aafcli { - # for separating VM_ARGS in aafcli - AAF_SPACE=" " - THE_ID=$AAF_ID - if [ "${AAF_ID}" = "${AAF_ID/@/%}" ]; then - THE_ID+="@$DEFAULT_DOMAIN" - fi - _JAVA_HOME_/bin/java \ - -cp $AAF_CP \ - -Daaf_url=https://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=_MAJOR_VER_._MINOR_VER_/envContext=_ENV_CONTEXT_/routeOffer=_ROUTE_OFFER_ \ - -DAFT_LATITUDE=_AFT_LATITUDE_ \ - -DAFT_LONGITUDE=_AFT_LONGITUDE_ \ - -DAFT_ENVIRONMENT=_AFT_ENVIRONMENT_ \ - -Daaf_id=$THE_ID \ - -Daaf_password=$AAF_PASS \ - -Daaf_dme_timeout=60000 \ - -Dcadi_keyfile=$HOME/.aaf/keyfile \ - -Daaf_default_realm=$DEFAULT_DOMAIN \ - -DDEPLOYED_VERSION=_ARTIFACT_VERSION_ \ - _DME2_FS_ \ - com.att.cmd.AAFcli $* - unset THE_ID - unset AAF_SPACE -} - -### -# load cmcli function in the Shell -### - -function cmcli { - # for separating VM_ARGS in cmcli - AAF_SPACE=" " - THE_ID=$AAF_ID - if [ "${AAF_ID}" = "${AAF_ID/@/%}" ]; then - THE_ID+="@$DEFAULT_DOMAIN" - fi - CM_URL=_CM_URL_ - if [ "${CM_URL}" = "" ]; then - CM_URL=https://DME2RESOLVE/service=com.att.authz.Certman/version=_MAJOR_VER_._MINOR_VER_/envContext=_ENV_CONTEXT_/routeOffer=_ROUTE_OFFER_ - fi - - _JAVA_HOME_/bin/java \ - -cp $AAF_CP \ - -DAFT_LATITUDE=_AFT_LATITUDE_ \ - -DAFT_LONGITUDE=_AFT_LONGITUDE_ \ - -DAFT_ENVIRONMENT=_AFT_ENVIRONMENT_ \ - -Daaf_dme_timeout=60000 \ - -Daaf_default_realm=$DEFAULT_DOMAIN \ - -DDEPLOYED_VERSION=_ARTIFACT_VERSION_ \ - _DME2_FS_ \ - org.onap.aaf.cadi.cm.CmAgent cm_url=${CM_URL} aaf_id=$THE_ID aaf_password="$AAF_PASS" \ - cadi_keyfile=$HOME/.aaf/keyfile $* - unset THE_ID - unset AAF_SPACE - unset CM_URL -} - - -### -# if "-r" the do Remote Password Reset -### -if [ "$1" == "-r" ] ; then - # Ask for User and Password. Assuming Unix and availability of "stty" - read -ers -p "Enter New AAF Password for $AAF_ID: " AAF_NEWPASS - echo - read -ers -p "Reenter New AAF Password for $AAF_ID: " AAF_NEWPASS2 - echo - if [ "$AAF_NEWPASS" == "$AAF_NEWPASS2" ] ; then - RESP=`aafcli user resetCred "$AAF_ID@aaf.att.com" $AAF_NEWPASS` - echo $RESP - if [ "$RESP" == "Reset Credential [$AAF_ID@aaf.att.com]" ] ; then - export AAF_PASS=enc:`$JAVA -cp $AAF_CP org.onap.aaf.cadi.CmdLine digest $AAF_NEWPASS $HOME/.aaf/keyfile` - fi - else - echo "Passwords don't match!" - fi -fi - -### -# Export key variables for use in other Scripts -### -export AAF_ID -export AAF_PASS -export AAF_CP -export -f aafcli -export -f aaflogout -fi diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_AAFCli.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_AAFCli.java deleted file mode 100644 index f0057387..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_AAFCli.java +++ /dev/null @@ -1,193 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; - -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.net.HttpURLConnection; -import java.security.GeneralSecurityException; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.Locator; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.PropertyLocator; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.config.SecurityInfo; -import org.onap.aaf.cadi.http.HBasicAuthSS; -import org.onap.aaf.cadi.http.HMangr; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_AAFCli { - - private static AAFcli cli; - private static int TIMEOUT = Integer.parseInt(Config.AAF_CONN_TIMEOUT_DEF); - - @BeforeClass - public static void setUp() throws Exception, Exception { - cli = getAAfCli(); - } - - @Test - public void eval() throws Exception { - assertTrue(cli.eval("#startswith")); - } - - @Test - public void eval_empty() throws Exception { - assertTrue(cli.eval("")); - } - - @Test - public void eval1() throws Exception { - assertTrue(cli.eval("@[123")); - } - - @Test - public void eval2() throws Exception { - assertFalse(cli.eval("as @[ 123")); - } - - @Test - public void eval3() throws Exception { - try { - cli.eval("expect @[ 123"); - } catch (Exception e) { - // TODO Auto-generated catch block - assertTrue(e instanceof CadiException); - } - } - - public void eval31() throws Exception { - try { - cli.eval("expect 1 @[ 123"); - } catch (Exception e) { - // TODO Auto-generated catch block - assertTrue(e instanceof CadiException); - } - } - - @Test - public void eval4() throws Exception { - try { - cli.eval("sleep @[ 123"); - } catch (Exception e) { - assertTrue(e instanceof NumberFormatException); - } - } - - @Test - public void eval41() throws Exception { - assertTrue(cli.eval("sleep 1 @[ 123")); - } - - @Test - public void eval5() throws Exception { - try { - cli.eval("delay @[ 123"); - } catch (Exception e) { - assertTrue(e instanceof NumberFormatException); - } - } - - @Test - public void eval51() throws Exception { - assertTrue(cli.eval("delay 1 @[ 123")); - } - - @Test - public void eval7() throws Exception { - assertFalse(cli.eval("exit @[ 123")); - } - - @Test - public void eval8() throws Exception { - assertTrue(cli.eval("REQUEST @[ 123")); - } - - @Test - public void eval9() throws Exception { - assertTrue(cli.eval("FORCE @[ 123")); - } - - @Test - public void eval10() throws Exception { - assertTrue(cli.eval("set @[ 123")); - } - - @Test - public void keyboardHelp() throws Exception { - boolean noError=true; - try { - cli.keyboardHelp(); - } catch (Exception e) { - noError=false; - } - assertTrue(noError); - } - - - - @Test - public void setProp() throws Exception { - boolean noError=true; - try { - cli.keyboardHelp(); - } catch (Exception e) { - noError=false; - } - assertTrue(noError); - } - - @Test - public void eval_randomString() throws Exception { - assertTrue(cli.eval("Some random string @#&*& to check complete 100 coverage")); - } - - public static AAFcli getAAfCli() throws APIException, LocatorException, GeneralSecurityException, IOException { - final AuthzEnv env = new AuthzEnv(System.getProperties()); - String aafUrl = "https://DME2RESOLVE"; - SecurityInfo si = new SecurityInfo(env); - env.loadToSystemPropsStartsWith("AAF", "DME2"); - Locator loc; - loc = new PropertyLocator(aafUrl); - TIMEOUT = Integer.parseInt(env.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF)); - HMangr hman = new HMangr(env, loc).readTimeout(TIMEOUT).apiVersion("2.0"); - - // TODO: Consider requiring a default in properties - env.setProperty(Config.AAF_DEFAULT_REALM, - System.getProperty(Config.AAF_DEFAULT_REALM, Config.getDefaultRealm())); - HBasicAuthSS ss = mock(HBasicAuthSS.class); - return new AAFcli(env, new OutputStreamWriter(System.out), hman, si, ss); - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_BaseCmd.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_BaseCmd.java deleted file mode 100644 index 2b946512..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_BaseCmd.java +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.security.GeneralSecurityException; -import java.util.Date; -import java.util.GregorianCalendar; - -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.inno.env.APIException; - -import aaf.v2_0.History; - -@RunWith(MockitoJUnitRunner.class) -public class JU_BaseCmd { - - private static AAFcli cli; - private static BaseCmd bCmd; - - @BeforeClass - public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException { - cli = JU_AAFCli.getAAfCli(); - bCmd = new BaseCmd<>(cli, "testString"); - } - - @Test - public void exec() throws CadiException, APIException, LocatorException { - assertEquals(bCmd._exec(4, "add", "del", "reset", "extend"), 0); - - } - - @Test - public void exec1() throws CadiException, APIException, LocatorException { - assertEquals(bCmd._exec(0, "add", "del", "reset", "extend"), 0); - - } - - @Test - public void error() throws CadiException, APIException, LocatorException { - boolean noError = true; - Future future = new Future() { - - @Override - public boolean get(int timeout) throws CadiException { - // TODO Auto-generated method stub - return false; - } - - @Override - public int code() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public String body() { - // TODO Auto-generated method stub - return "{%}"; - } - - @Override - public String header(String tag) { - // TODO Auto-generated method stub - return null; - } - }; - try { - bCmd.error(future); - } catch (Exception e) { - noError = false; - } - assertEquals(noError, true); - - } - - - - @Test - public void activity() throws DatatypeConfigurationException { - boolean noError = true; - History history = new History(); - History.Item item = new History.Item(); - item.setTarget("target"); - item.setUser("user"); - item.setMemo("memo"); - - GregorianCalendar c = new GregorianCalendar(); - c.setTime(new Date()); - XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); - item.setTimestamp(date); - history.getItem().add(item); - try { - bCmd.activity(history, "history"); - } catch (Exception e) { - noError = false; - } - assertEquals(noError, true); - - } - - @Test - public void activity1() throws DatatypeConfigurationException { - boolean noError = true; - History history = new History(); - History.Item item = new History.Item(); - item.setTarget("target"); - item.setUser("user"); - item.setMemo("memo"); - - GregorianCalendar c = new GregorianCalendar(); - c.setTime(new Date()); - XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); - item.setTimestamp(date); - history.getItem().add(item); - try { - bCmd.activity(history, "1[]"); - } catch (Exception e) { - noError = false; - } - assertEquals(noError, true); - - } - - - - @Test - public void error1() { - boolean noError = true; - Future future = new Future() { - - @Override - public boolean get(int timeout) throws CadiException { - // TODO Auto-generated method stub - return false; - } - - @Override - public int code() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public String body() { - // TODO Auto-generated method stub - return "{1"; - } - - @Override - public String header(String tag) { - // TODO Auto-generated method stub - return null; - } - }; - try { - bCmd.error(future); - } catch (Exception e) { - noError = false; - } - assertEquals(noError, true); - - } - - @Test - public void error2() { - boolean noError = true; - Future future = new Future() { - - @Override - public boolean get(int timeout) throws CadiException { - // TODO Auto-generated method stub - return false; - } - - @Override - public int code() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public String body() { - // TODO Auto-generated method stub - return "other"; - } - - @Override - public String header(String tag) { - // TODO Auto-generated method stub - return null; - } - }; - try { - bCmd.error(future); - } catch (Exception e) { - noError = false; - } - assertEquals(noError, true); - - } - -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_BasicAuth.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_BasicAuth.java deleted file mode 100644 index 07f008b6..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_BasicAuth.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.BasicAuth; - -@RunWith(MockitoJUnitRunner.class) -public class JU_BasicAuth { - - @Test - public void getID () { - try { - BasicAuth bAuth = new BasicAuth("testUser", "nopass"); - assertEquals(bAuth.getID(), "testUser"); - System.out.println(bAuth.getID()); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_Help.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_Help.java deleted file mode 100644 index f48d71e0..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_Help.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.security.GeneralSecurityException; -import java.util.ArrayList; -import java.util.List; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.Help; - -import com.att.aft.dme2.internal.jetty.http.HttpStatus; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Help { - - private static AAFcli cli; - private static Help help; - - @Mock - private static List cmds; - - @BeforeClass - public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException { - cli = JU_AAFCli.getAAfCli(); - cmds = new ArrayList<>(); - help = new Help(cli, cmds); - } - - @Test - public void exec_HTTP_200() { - try { - assertEquals(help._exec(1, "helps"), HttpStatus.OK_200); - } catch (CadiException | APIException | LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void exec_HTTP_200_1() { - try { - assertEquals(help._exec(1, "helps","help"), HttpStatus.OK_200); - } catch (CadiException | APIException | LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void detailhelp() { - boolean hasError=false; - try { - help.detailedHelp(2, new StringBuilder("detail help test")); - } catch (Exception e) { - hasError=true; - } - assertEquals(hasError,false); - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_Version.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_Version.java deleted file mode 100644 index 3bff61b7..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/JU_Version.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.security.GeneralSecurityException; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Version; - -import com.att.aft.dme2.internal.jetty.http.HttpStatus; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Version { - - private static AAFcli cli; - private static Version version; - - @BeforeClass - public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException { - cli = JU_AAFCli.getAAfCli(); - version = new Version(cli); - } - - @Test - public void exec_HTTP_200() throws CadiException, APIException, LocatorException { - assertEquals(version._exec(0, "Version"), HttpStatus.OK_200); - - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_Clear.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_Clear.java deleted file mode 100644 index 99a2c317..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_Clear.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.mgmt; - -import static org.mockito.Mockito.mock; -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.mgmt.Clear; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Clear { - - private static Clear clr; - - @BeforeClass - public static void setUp() { - clr = mock(Clear.class); - } - - @Test - public void exec() { - try { - assertEquals(clr._exec(0, "clear"), 0); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_Log.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_Log.java deleted file mode 100644 index 04a06f0e..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_Log.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.mgmt; - -import static org.mockito.Mockito.mock; -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.mgmt.Log; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Log { - - private static Log log; - - @BeforeClass - public static void setUp() { - log = mock(Log.class); - } - - @Test - public void exec() { - try { - assertEquals(log._exec(0, "session clear"), 0); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_SessClear.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_SessClear.java deleted file mode 100644 index 7cda450e..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_SessClear.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.mgmt; - -import static org.mockito.Mockito.mock; -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.mgmt.SessClear; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_SessClear { - - private static SessClear sessclr; - - @BeforeClass - public static void setUp() { - sessclr = mock(SessClear.class); - } - - @Test - public void exec() { - try { - assertEquals(sessclr._exec(0, "session clear"), 0); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Admin.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Admin.java deleted file mode 100644 index 48cf0958..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Admin.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Admin { - - private static Admin admin; - - @BeforeClass - public static void setUp() throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - admin = new Admin(ns); - } - - @Test - public void exec() { - try { - assertEquals(admin._exec(0, "add", "del", "reset", "extend"), 500); - } catch (Exception e) { - assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE"); - } - } - - @Test - public void detailedHelp() { - boolean hasNoError = true; - try { - admin.detailedHelp(1, new StringBuilder("test")); - } catch (Exception e) { - hasNoError = false; - } - assertEquals(hasNoError, true); - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Attrib.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Attrib.java deleted file mode 100644 index 3a03ce65..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Attrib.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Attrib { - - private static Attrib attrib; - - @BeforeClass - public static void setUp() throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - attrib = new Attrib(ns); - } - - @Test - public void exec() { - try { - attrib._exec(0, "add", "del", "reset", "extend"); - } catch (Exception e) { - assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE"); - } - } - - @Test - public void detailedHelp() { - boolean hasNoError = true; - try { - attrib.detailedHelp(1, new StringBuilder("test")); - } catch (Exception e) { - hasNoError = false; - } - assertEquals(hasNoError, true); - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Create.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Create.java deleted file mode 100644 index 23034e32..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Create.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Create { - - private static Create create; - - @BeforeClass - public static void setUp() throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - create = new Create(ns); - } - - @Test - public void exec() { - try { - assertEquals(create._exec(0, "add", "del", "reset", "extend"), 500); - } catch (Exception e) { - assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE"); - } - } - - @Test - public void detailedHelp() { - boolean hasNoError = true; - try { - create.detailedHelp(1, new StringBuilder("test")); - } catch (Exception e) { - hasNoError = false; - } - assertEquals(hasNoError, true); - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Delete.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Delete.java deleted file mode 100644 index 0d59062d..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Delete.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.security.GeneralSecurityException; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.inno.env.APIException; - -public class JU_Delete { - - private static Delete delete; - - @BeforeClass - public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - delete = new Delete(ns); - - } - - @Test - public void exec() { - try { - delete._exec(0, "del", "del", "del"); - } catch (Exception e) { - assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE"); - } - } - - @Test - public void detailedHelp() { - boolean hasNoError = true; - try { - delete.detailedHelp(1, new StringBuilder("test")); - } catch (Exception e) { - hasNoError = false; - } - assertEquals(hasNoError, true); - } - -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Describe.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Describe.java deleted file mode 100644 index 1cd7b387..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Describe.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.CALLS_REAL_METHODS; -import static org.mockito.Mockito.mock; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.ns.Describe; -import org.onap.aaf.cmd.ns.NS; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Describe { - - private static Describe desc; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - desc = new Describe(ns); - } - - @Test - public void exec() { - try { - assertEquals(desc._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} - diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListActivity.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListActivity.java deleted file mode 100644 index 16062b8f..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListActivity.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.ns.List; -import org.onap.aaf.cmd.ns.ListActivity; -import org.onap.aaf.cmd.ns.NS; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListActivity { - - private static ListActivity lsActivity; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - List ls = new List(ns); - lsActivity = new ListActivity(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsActivity._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} - diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListAdminResponsible.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListAdminResponsible.java deleted file mode 100644 index ab28722b..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListAdminResponsible.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.ns.List; -import org.onap.aaf.cmd.ns.ListAdminResponsible; -import org.onap.aaf.cmd.ns.NS; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListAdminResponsible { - - private static ListAdminResponsible lsAdminRes; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - List ls = new List(ns); - lsAdminRes = new ListAdminResponsible(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsAdminRes._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} - diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListByName.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListByName.java deleted file mode 100644 index effa1d41..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListByName.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.ns.List; -import org.onap.aaf.cmd.ns.ListByName; -import org.onap.aaf.cmd.ns.NS; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListByName { - - private static ListByName lsByName; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - List ls = new List(ns); - lsByName = new ListByName(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsByName._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} - diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListChildren.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListChildren.java deleted file mode 100644 index f7a850f4..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListChildren.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.ns.List; -import org.onap.aaf.cmd.ns.ListChildren; -import org.onap.aaf.cmd.ns.NS; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListChildren { - - private static ListChildren lsChildren; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - List ls = new List(ns); - lsChildren = new ListChildren(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsChildren._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} - diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListNsKeysByAttrib.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListNsKeysByAttrib.java deleted file mode 100644 index 62935a11..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListNsKeysByAttrib.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.ns.List; -import org.onap.aaf.cmd.ns.ListNsKeysByAttrib; -import org.onap.aaf.cmd.ns.NS; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListNsKeysByAttrib { - - private static ListNsKeysByAttrib lsNsKeys; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - List ls = new List(ns); - lsNsKeys = new ListNsKeysByAttrib(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsNsKeys._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} - diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListUsersInRole.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListUsersInRole.java deleted file mode 100644 index 786adb54..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListUsersInRole.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListUsersInRole { - - private static ListUsersInRole lsUserinRole; - - @BeforeClass - public static void setUp() throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - List ls = new List(ns); - ListUsers lsU = new ListUsers(ls); - lsUserinRole = new ListUsersInRole(lsU); - } - - @Test - public void exec() { - try { - assertEquals(lsUserinRole._exec(0, "add", "del", "reset", "extend"), 500); - } catch (Exception e) { - assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE"); - } - } - - @Test - public void detailedHelp() { - boolean hasNoError = true; - try { - lsUserinRole.detailedHelp(1, new StringBuilder("test")); - } catch (Exception e) { - hasNoError = false; - } - assertEquals(hasNoError, true); - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListUsersWithPerm.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListUsersWithPerm.java deleted file mode 100644 index 5faa2b7d..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListUsersWithPerm.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListUsersWithPerm { - - private static ListUsersWithPerm lsUserWithPerm; - - @BeforeClass - public static void setUp() throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - List ls = new List(ns); - ListUsers lsU = new ListUsers(ls); - lsUserWithPerm = new ListUsersWithPerm(lsU); - } - - @Test - public void exec() { - try { - assertEquals(lsUserWithPerm._exec(0, "add", "del", "reset", "extend"), 500); - } catch (Exception e) { - assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE"); - } - } - - @Test - public void detailedHelp() { - boolean hasNoError = true; - try { - lsUserWithPerm.detailedHelp(1, new StringBuilder("test")); - } catch (Exception e) { - hasNoError = false; - } - assertEquals(hasNoError, true); - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Responsible.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Responsible.java deleted file mode 100644 index 89b13fc3..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Responsible.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.ns; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.security.GeneralSecurityException; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.inno.env.APIException; - -public class JU_Responsible { - - private static Responsible responsible; - - @BeforeClass - public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException { - AAFcli cli = JU_AAFCli.getAAfCli(); - NS ns = new NS(cli); - responsible = new Responsible(ns); - - } - - @Test - public void exec1() { - try { - responsible._exec(0, "del", "del", "del"); - } catch (Exception e) { - assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE"); - } - } - - @Test - public void detailedHelp() { - boolean hasNoError = true; - try { - responsible.detailedHelp(1, new StringBuilder("test")); - } catch (Exception e) { - hasNoError = false; - } - assertEquals(hasNoError, true); - } - -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Create.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Create.java deleted file mode 100644 index 82c083b5..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Create.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.perm.Create; -import org.onap.aaf.cmd.perm.Perm; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Create { - - private static Create create; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - Perm perm = new Perm(role); - create = new Create(perm); - } - - @Test - public void exec() { - try { - assertEquals(create._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Delete.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Delete.java deleted file mode 100644 index 21e7e35c..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Delete.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.perm.Delete; -import org.onap.aaf.cmd.perm.Perm; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Delete { - - private static Delete del; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - Perm perm = new Perm(role); - del = new Delete(perm); - } - - @Test - public void exec() { - try { - assertEquals(del._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Describe.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Describe.java deleted file mode 100644 index d05b44e4..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Describe.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.perm.Describe; -import org.onap.aaf.cmd.perm.Perm; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Describe { - - private static Describe desc; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - Perm perm = new Perm(role); - desc = new Describe(perm); - } - - @Test - public void exec() { - try { - assertEquals(desc._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Grant.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Grant.java deleted file mode 100644 index a233ca02..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Grant.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.perm.Grant; -import org.onap.aaf.cmd.perm.Perm; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Grant { - - private static Grant grant; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - Perm perm = new Perm(role); - grant = new Grant(perm); - } - - @Test - public void exec() { - try { - assertEquals(grant._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListActivity.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListActivity.java deleted file mode 100644 index c2712beb..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListActivity.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.perm.List; -import org.onap.aaf.cmd.perm.ListActivity; -import org.onap.aaf.cmd.perm.Perm; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListActivity { - - private static ListActivity lsActivity; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - Perm perm = new Perm(role); - List ls = new List(perm); - lsActivity = new ListActivity(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsActivity._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByNS.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByNS.java deleted file mode 100644 index 8935045e..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByNS.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.perm.List; -import org.onap.aaf.cmd.perm.ListByNS; -import org.onap.aaf.cmd.perm.Perm; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListByNS { - - private static ListByNS lsByNS; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - Perm perm = new Perm(role); - List ls = new List(perm); - lsByNS = new ListByNS(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsByNS._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByName.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByName.java deleted file mode 100644 index 3e59d4e6..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByName.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.perm.List; -import org.onap.aaf.cmd.perm.ListByName; -import org.onap.aaf.cmd.perm.Perm; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListByName { - - private static ListByName lsByName; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - Perm perm = new Perm(role); - List ls = new List(perm); - lsByName = new ListByName(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsByName._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByRole.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByRole.java deleted file mode 100644 index d55c0b94..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByRole.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.perm.List; -import org.onap.aaf.cmd.perm.ListByRole; -import org.onap.aaf.cmd.perm.Perm; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListByRole { - - private static ListByRole lsByRole; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - Perm perm = new Perm(role); - List ls = new List(perm); - lsByRole = new ListByRole(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsByRole._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByUser.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByUser.java deleted file mode 100644 index 88fef497..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByUser.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.perm.List; -import org.onap.aaf.cmd.perm.ListByUser; -import org.onap.aaf.cmd.perm.Perm; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListByUser { - - private static ListByUser lsByName; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - Perm perm = new Perm(role); - List ls = new List(perm); - lsByName = new ListByUser(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsByName._exec(0, "add","del","reset","extend"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Rename.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Rename.java deleted file mode 100644 index 6e53e301..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Rename.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.perm; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.perm.Perm; -import org.onap.aaf.cmd.perm.Rename; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Rename { - - private static Rename rename; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - Perm perm = new Perm(role); - rename = new Rename(perm); - } - - @Test - public void exec() { - try { - assertEquals(rename._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_CreateDelete.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_CreateDelete.java deleted file mode 100644 index 92794971..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_CreateDelete.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.role.CreateDelete; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_CreateDelete { - - private static CreateDelete createDel; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - createDel = new CreateDelete(role); - } - - @Test - public void exec() { - try { - assertEquals(createDel._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_Describe.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_Describe.java deleted file mode 100644 index 388b0463..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_Describe.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.role.Describe; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Describe { - - private static Describe desc; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - desc = new Describe(role); - } - - @Test - public void exec() { - try { - assertEquals(desc._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListActivity.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListActivity.java deleted file mode 100644 index 08dc1199..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListActivity.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.role.List; -import org.onap.aaf.cmd.role.ListActivity; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListActivity { - - private static ListActivity lsActivity; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - List ls = new List(role); - lsActivity = new ListActivity(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsActivity._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByNS.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByNS.java deleted file mode 100644 index 82133fab..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByNS.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.role.List; -import org.onap.aaf.cmd.role.ListByNS; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListByNS { - - private static ListByNS lsByNS; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - List ls = new List(role); - lsByNS = new ListByNS(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsByNS._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByNameOnly.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByNameOnly.java deleted file mode 100644 index 266039aa..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByNameOnly.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.role.List; -import org.onap.aaf.cmd.role.ListByNameOnly; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListByNameOnly { - - private static ListByNameOnly lsByName; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - List ls = new List(role); - lsByName = new ListByNameOnly(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsByName._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByPerm.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByPerm.java deleted file mode 100644 index f97a684c..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByPerm.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.role.List; -import org.onap.aaf.cmd.role.ListByPerm; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListByPerm { - - private static ListByPerm lsByPerm; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - List ls = new List(role); - lsByPerm = new ListByPerm(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsByPerm._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByRole.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByRole.java deleted file mode 100644 index 0848eb14..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByRole.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.role.List; -import org.onap.aaf.cmd.role.ListByRole; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListByRole { - - private static ListByRole lsByRole; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - List ls = new List(role); - lsByRole = new ListByRole(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsByRole._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByUser.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByUser.java deleted file mode 100644 index 17f99812..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByUser.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.role.List; -import org.onap.aaf.cmd.role.ListByUser; -import org.onap.aaf.cmd.role.Role; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListByUser { - - private static ListByUser lsByUser; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - List ls = new List(role); - lsByUser = new ListByUser(ls); - } - - @Test - public void exec() { - try { - assertEquals(lsByUser._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_User.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_User.java deleted file mode 100644 index cadfd941..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_User.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.role; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.perm.Perm; -import org.onap.aaf.cmd.role.Role; -import org.onap.aaf.cmd.role.User; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_User { - - private static User user; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - Role role = new Role(cli); - user = new User(role); - } - - @Test - public void exec() { - try { - assertEquals(user._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Cred.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Cred.java deleted file mode 100644 index aa975936..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Cred.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.FileNotFoundException; -import java.io.PrintWriter; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.Cmd; -import org.onap.aaf.cmd.user.Cred; -import org.onap.aaf.cmd.user.User; -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Cred { - - private static Cred testCred; - private static User testUser; - private static AuthzEnv env; - - - @BeforeClass - public static void setUp() throws FileNotFoundException, APIException { - - testCred = mock(Cred.class); - testUser = mock(User.class); - env = mock(AuthzEnv.class); - Mockito.when(env.getProperty(Cmd.STARTDATE,null)).thenReturn(null); - Mockito.when(env.getProperty(Cmd.ENDDATE,null)).thenReturn(null); - - } - - @Test - public void exec() throws CadiException, APIException, LocatorException, FileNotFoundException { - boolean isNullpointer=false; - AAFcli aaFcli= new AAFcli(env, new PrintWriter("temp"), null, null, null); - User user= new User(aaFcli); - Cred testCred= new Cred(user); - try { - testCred._exec(0, "add", "del", "reset", "extend"); - } catch (Exception e) { - isNullpointer=true; - } - assertEquals(isNullpointer, true); - } - - - @Test - public void exec_add() { - try { - assertNotNull(testCred._exec(0, "zeroed","add","del","reset","extend")); - } catch (CadiException | APIException | LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - @Test - public void exec_del() { - try { - assertNotNull(testCred._exec(1, "zeroed","add","del","reset","extend")); - } catch (CadiException | APIException | LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - @Test - public void exec_reset() { - try { - assertNotNull(testCred._exec(2, "zeroed","add","del","reset","extend")); - } catch (CadiException | APIException | LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - @Test - public void exec_extend() { - try { - assertNotNull(testCred._exec(3, "zeroed","add","del","reset","extend")); - } catch (CadiException | APIException | LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Delg.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Delg.java deleted file mode 100644 index 41708466..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Delg.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import static org.mockito.Mockito.mock; -import static org.junit.Assert.*; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.user.Delg; -import org.onap.aaf.cmd.user.User; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Delg { - - private static User testUser; - private static Delg delg; - - @BeforeClass - public static void setUp() throws APIException { - testUser = mock(User.class); - delg = mock(Delg.class); - } - - @Test - public void exec_add() { - try { - assertEquals(delg._exec(0, "zero","add","upd","del"), 0); - } catch (CadiException | APIException | LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void exec_upd() { - try { - assertEquals(delg._exec(1, "zero","add","upd","del"), 0); - } catch (CadiException | APIException | LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void exec_del() { - try { - assertEquals(delg._exec(2, "zero","add","upd","del"), 0); - } catch (CadiException | APIException | LocatorException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListActivity.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListActivity.java deleted file mode 100644 index 8edc633b..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListActivity.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.user.List; -import org.onap.aaf.cmd.user.ListActivity; -import org.onap.aaf.cmd.user.User; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListActivity { - - private static ListActivity lsActivity; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - User usr = new User(cli); - List parent = new List(usr); - lsActivity = new ListActivity(parent); - - } - - @Test - public void exec() { - try { - assertEquals(lsActivity._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - - e.printStackTrace(); - } catch (APIException e) { - - e.printStackTrace(); - } catch (LocatorException e) { - - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListApprovals.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListApprovals.java deleted file mode 100644 index fe3b91c3..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListApprovals.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.user.List; -import org.onap.aaf.cmd.user.ListApprovals; -import org.onap.aaf.cmd.user.User; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListApprovals { - - private static ListApprovals lsApprovals; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - User usr = new User(cli); - List parent = new List(usr); - lsApprovals = new ListApprovals(parent); - - } - - @Test - public void exec() { - try { - assertEquals(lsApprovals._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - - e.printStackTrace(); - } catch (APIException e) { - - e.printStackTrace(); - } catch (LocatorException e) { - - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListDelegates.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListDelegates.java deleted file mode 100644 index e25cedf9..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListDelegates.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.user.List; -import org.onap.aaf.cmd.user.ListDelegates; -import org.onap.aaf.cmd.user.User; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListDelegates { - - private static ListDelegates lsDelegates; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - User usr = new User(cli); - List parent = new List(usr); - lsDelegates = new ListDelegates(parent); - - } - - @Test - public void exec() { - try { - assertEquals(lsDelegates._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - - e.printStackTrace(); - } catch (APIException e) { - - e.printStackTrace(); - } catch (LocatorException e) { - - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForCreds.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForCreds.java deleted file mode 100644 index 95012bd0..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForCreds.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.user.List; -import org.onap.aaf.cmd.user.ListForCreds; -import org.onap.aaf.cmd.user.User; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListForCreds { - - private static ListForCreds lsForCreds; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - User usr = new User(cli); - List parent = new List(usr); - lsForCreds = new ListForCreds(parent); - - } - - @Test - public void exec() { - try { - assertEquals(lsForCreds._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - - e.printStackTrace(); - } catch (APIException e) { - - e.printStackTrace(); - } catch (LocatorException e) { - - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForPermission.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForPermission.java deleted file mode 100644 index bb1e3dba..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForPermission.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.user.List; -import org.onap.aaf.cmd.user.ListForPermission; -import org.onap.aaf.cmd.user.User; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListForPermission { - - private static ListForPermission lsForPermission; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - User usr = new User(cli); - List parent = new List(usr); - lsForPermission = new ListForPermission(parent); - - } - - @Test - public void exec() { - try { - assertEquals(lsForPermission._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - - e.printStackTrace(); - } catch (APIException e) { - - e.printStackTrace(); - } catch (LocatorException e) { - - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForRoles.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForRoles.java deleted file mode 100644 index e2b5cfe6..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForRoles.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.user.List; -import org.onap.aaf.cmd.user.ListForRoles; -import org.onap.aaf.cmd.user.User; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_ListForRoles { - - private static ListForRoles lsForRoles; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - User usr = new User(cli); - List parent = new List(usr); - lsForRoles = new ListForRoles(parent); - - } - - @Test - public void exec() { - try { - assertEquals(lsForRoles._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - - e.printStackTrace(); - } catch (APIException e) { - - e.printStackTrace(); - } catch (LocatorException e) { - - e.printStackTrace(); - } - } -} diff --git a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Role.java b/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Role.java deleted file mode 100644 index 133adf7b..00000000 --- a/authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Role.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cmd.user; - -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.cmd.AAFcli; -import org.onap.aaf.cmd.JU_AAFCli; -import org.onap.aaf.cmd.user.Role; -import org.onap.aaf.cmd.user.User; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -import org.onap.aaf.inno.env.APIException; - -@RunWith(MockitoJUnitRunner.class) -public class JU_Role { - - private static Role role; - - @BeforeClass - public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException { - AAFcli cli = JU_AAFCli.getAAfCli(); - User usr = new User(cli); - role = new Role(usr); - - } - - @Test - public void exec() { - try { - assertEquals(role._exec(0, "add","del","reset","extend","clear", "rename", "create"),500); - } catch (CadiException e) { - - e.printStackTrace(); - } catch (APIException e) { - - e.printStackTrace(); - } catch (LocatorException e) { - - e.printStackTrace(); - } - } -} diff --git a/authz-core/pom.xml b/authz-core/pom.xml deleted file mode 100644 index 14bdb039..00000000 --- a/authz-core/pom.xml +++ /dev/null @@ -1,238 +0,0 @@ - - - - 4.0.0 - - org.onap.aaf.authz - parent - 1.0.1-SNAPSHOT - ../pom.xml - - - authz-core - Authz Core - Core Libraries for Authz - jar - https://github.com/att/AAF - - - - Jonathan Gathman - - ATT - - - - - 1.0.0-SNAPSHOT - 1.0.0-SNAPSHOT - - 0.7.7.201606060606 - true - 3.2 - jacoco - - target/code-coverage/jacoco-ut.exec - target/code-coverage/jacoco-it.exec - - **/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/** - https://nexus.onap.org - /content/repositories/snapshots/ - /content/repositories/releases/ - /content/repositories/staging/ - /content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version} - - - - org.onap.aaf.inno - env - ${project.innoVersion} - - - org.onap.aaf.inno - log4j - ${project.innoVersion} - - - org.onap.aaf.inno - rosetta - ${project.innoVersion} - - - org.onap.aaf.cadi - cadi-aaf - ${project.cadiVersion} - - - javax.servlet - servlet-api - - - - - - javax.servlet - servlet-api - - - - - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.4 - - false - - - - attach-javadocs - - jar - - - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ${nexusproxy} - 176c31dfe190a - ecomp-staging - - - - org.jacoco - jacoco-maven-plugin - ${jacoco.version} - - - **/gen/** - **/generated-sources/** - **/yang-gen/** - **/pax/** - - - - - - pre-unit-test - - prepare-agent - - - ${project.build.directory}/code-coverage/jacoco-ut.exec - surefireArgLine - - - - - - post-unit-test - test - - report - - - ${project.build.directory}/code-coverage/jacoco-ut.exec - ${project.reporting.outputDirectory}/jacoco-ut - - - - pre-integration-test - pre-integration-test - - prepare-agent - - - ${project.build.directory}/code-coverage/jacoco-it.exec - - failsafeArgLine - - - - - - post-integration-test - post-integration-test - - report - - - ${project.build.directory}/code-coverage/jacoco-it.exec - ${project.reporting.outputDirectory}/jacoco-it - - - - - - - - - - - ecomp-releases - AAF Release Repository - ${nexusproxy}${releaseNexusPath} - - - ecomp-snapshots - AAF Snapshot Repository - ${nexusproxy}${snapshotNexusPath} - - - ecomp-site - dav:${nexusproxy}${sitePath} - - - - - - diff --git a/authz-core/src/main/java/org/onap/aaf/authz/common/Define.java b/authz-core/src/main/java/org/onap/aaf/authz/common/Define.java deleted file mode 100644 index 0a3ccdf1..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/common/Define.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.common; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.inno.env.Env; - -public class Define { - public static String ROOT_NS="org.openecomp"; - public static String ROOT_COMPANY=ROOT_NS; - - public static void set(Env env) throws CadiException { - ROOT_NS = env.getProperty(Config.AAF_ROOT_NS); - if(ROOT_NS==null) { - throw new CadiException(Config.AAF_ROOT_NS + " property is required."); - } - ROOT_COMPANY = env.getProperty(Config.AAF_ROOT_COMPANY); - if(ROOT_COMPANY==null) { - int last = ROOT_NS.lastIndexOf('.'); - if(last>=0) { - ROOT_COMPANY = ROOT_NS.substring(0, last); - } else { - throw new CadiException(Config.AAF_ROOT_COMPANY + " or " + Config.AAF_ROOT_NS + " property with 3 positions is required."); - } - } - env.init().log("AAF Root NS is " + ROOT_NS + ", and AAF Root Company is " +ROOT_COMPANY); - } - -} diff --git a/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzEnv.java b/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzEnv.java deleted file mode 100644 index 3025e5cd..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzEnv.java +++ /dev/null @@ -1,264 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.env; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map.Entry; -import java.util.Properties; - -import org.onap.aaf.cadi.Access; -import org.onap.aaf.cadi.Symm; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Decryptor; -import org.onap.aaf.inno.env.Encryptor; -import org.onap.aaf.inno.env.impl.Log4JLogTarget; -import org.onap.aaf.inno.env.log4j.LogFileNamer; -import org.onap.aaf.rosetta.env.RosettaEnv; - - -/** - * AuthzEnv is the Env tailored to Authz Service - * - * Most of it is derived from RosettaEnv, but it also implements Access, which - * is an Interface that Allows CADI to interact with Container Logging - * - * - */ -public class AuthzEnv extends RosettaEnv implements Access { - private long[] times = new long[20]; - private int idx = 0; - //private int mask = Level.AUDIT.maskOf(); - - public AuthzEnv() { - super(); - } - - public AuthzEnv(String ... args) { - super(args); - } - - public AuthzEnv(Properties props) { - super(Config.CADI_PROP_FILES,props); - } - - - @Override - public AuthzTransImpl newTrans() { - synchronized(this) { - times[idx]=System.currentTimeMillis(); - if(++idx>=times.length)idx=0; - } - return new AuthzTransImpl(this); - } - - /** - * Create a Trans, but do not include in Weighted Average - * @return - */ - public AuthzTrans newTransNoAvg() { - return new AuthzTransImpl(this); - } - - public long transRate() { - int count = 0; - long pot = 0; - long prev = 0; - for(int i=idx;i0) { - if(prev>0) { - ++count; - pot += times[i]-prev; - } - prev = times[i]; - } - } - for(int i=0;i0) { - if(prev>0) { - ++count; - pot += times[i]-prev; - } - prev = times[i]; - } - } - - return count==0?300000L:pot/count; // Return Weighted Avg, or 5 mins, if none avail. - } - - @Override - public ClassLoader classLoader() { - return getClass().getClassLoader(); - } - - @Override - public void load(InputStream is) throws IOException { - Properties props = new Properties(); - props.load(is); - for(Entry es : props.entrySet()) { - String key = es.getKey().toString(); - String value =es.getValue().toString(); - put(staticSlot(key==null?null:key.trim()),value==null?null:value.trim()); - } - } - - @Override - public void log(Level lvl, Object... msgs) { -// if(lvl.inMask(mask)) { -// switch(lvl) { -// case INIT: -// init().log(msgs); -// break; -// case AUDIT: -// audit().log(msgs); -// break; -// case DEBUG: -// debug().log(msgs); -// break; -// case ERROR: -// error().log(msgs); -// break; -// case INFO: -// info().log(msgs); -// break; -// case WARN: -// warn().log(msgs); -// break; -// case NONE: -// break; -// } -// } - } - - @Override - public void log(Exception e, Object... msgs) { - error().log(e,msgs); - } - - //@Override - public void printf(Level level, String fmt, Object... elements) { - if(willLog(level)) { - log(level,String.format(fmt, elements)); - } - } - - /* (non-Javadoc) - * @see org.onap.aaf.cadi.Access#willLog(org.onap.aaf.cadi.Access.Level) - */ - @Override - public boolean willLog(Level level) { - -// if(level.inMask(mask)) { -// switch(level) { -// case INIT: -// return init().isLoggable(); -// case AUDIT: -// return audit().isLoggable(); -// case DEBUG: -// return debug().isLoggable(); -// case ERROR: -// return error().isLoggable(); -// case INFO: -// return info().isLoggable(); -// case WARN: -// return warn().isLoggable(); -// case NONE: -// return false; -// } -// } - return false; - } - - @Override - public void setLogLevel(Level level) { - super.debug().isLoggable(); - //level.toggle(mask); - } - - public void setLog4JNames(String path, String root, String _service, String _audit, String _init, String _trace) throws APIException { - LogFileNamer lfn = new LogFileNamer(root); - if(_service==null) { - throw new APIException("AuthzEnv.setLog4JNames \"_service\" required (as default). Others can be null"); - } - String service=_service=lfn.setAppender(_service); // when name is split, i.e. authz|service, the Appender is "authz", and "service" - String audit=_audit==null?service:lfn.setAppender(_audit); // is part of the log-file name - String init=_init==null?service:lfn.setAppender(_init); - String trace=_trace==null?service:lfn.setAppender(_trace); - //TODO Validate path on Classpath - lfn.configure(path); - super.fatal = new Log4JLogTarget(service,org.apache.log4j.Level.FATAL); - super.error = new Log4JLogTarget(service,org.apache.log4j.Level.ERROR); - super.warn = new Log4JLogTarget(service,org.apache.log4j.Level.WARN); - super.audit = new Log4JLogTarget(audit,org.apache.log4j.Level.WARN); - super.init = new Log4JLogTarget(init,org.apache.log4j.Level.WARN); - super.info = new Log4JLogTarget(service,org.apache.log4j.Level.INFO); - super.debug = new Log4JLogTarget(service,org.apache.log4j.Level.DEBUG); - super.trace = new Log4JLogTarget(trace,org.apache.log4j.Level.TRACE); - } - - private static final byte[] ENC="enc:???".getBytes(); - public String decrypt(String encrypted, final boolean anytext) throws IOException { - if(encrypted==null) { - throw new IOException("Password to be decrypted is null"); - } - if(anytext || encrypted.startsWith("enc:")) { - if(decryptor.equals(Decryptor.NULL) && getProperty(Config.CADI_KEYFILE)!=null) { - final Symm s = Symm.obtain(this); - decryptor = new Decryptor() { - private Symm symm = s; - @Override - public String decrypt(String encrypted) { - try { - return (encrypted!=null && (anytext || encrypted.startsWith(Symm.ENC))) - ? symm.depass(encrypted) - : encrypted; - } catch (IOException e) { - return ""; - } - } - }; - encryptor = new Encryptor() { - @Override - public String encrypt(String data) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - baos.write(ENC); - return "enc:???"+s.enpass(data); - } catch (IOException e) { - return ""; - } - } - - }; - } - return decryptor.decrypt(encrypted); - } else { - return encrypted; - } - } - - - -} diff --git a/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTrans.java b/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTrans.java deleted file mode 100644 index cd4da45d..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTrans.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.env; - -import java.security.Principal; - -import javax.servlet.http.HttpServletRequest; - -import org.onap.aaf.authz.org.Organization; - -import org.onap.aaf.cadi.Lur; -import org.onap.aaf.cadi.Permission; -import org.onap.aaf.inno.env.LogTarget; -import org.onap.aaf.inno.env.TransStore; - -public interface AuthzTrans extends TransStore { - public abstract AuthzTrans set(HttpServletRequest req); - - public abstract void setUser(Principal p); - - public abstract String user(); - - public abstract Principal getUserPrincipal(); - - public abstract String ip(); - - public abstract int port(); - - public abstract String meth(); - - public abstract String path(); - - public abstract String agent(); - - public abstract AuthzEnv env(); - - public abstract void setLur(Lur lur); - - public abstract boolean fish(Permission p); - - public abstract boolean forceRequested(); - - public abstract Organization org(); - - public abstract boolean moveRequested(); - - public abstract boolean futureRequested(); - - public abstract void logAuditTrail(LogTarget lt); - -} diff --git a/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransFilter.java b/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransFilter.java deleted file mode 100644 index 31c13e69..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransFilter.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.env; - -import java.security.Principal; - -import javax.servlet.ServletRequest; -import javax.servlet.http.HttpServletRequest; - -import org.onap.aaf.cssa.rserv.TransFilter; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.Connector; -import org.onap.aaf.cadi.TrustChecker; -import org.onap.aaf.cadi.principal.BasicPrincipal; -import org.onap.aaf.cadi.principal.TrustPrincipal; -import org.onap.aaf.cadi.principal.X509Principal; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.Slot; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans.Metric; - -public class AuthzTransFilter extends TransFilter { - private AuthzEnv env; - public Metric serviceMetric; - public static Slot transIDslot; - - public static final String TRANS_ID_SLOT = "TRANS_ID_SLOT"; - public static final int BUCKETSIZE = 2; - - public AuthzTransFilter(AuthzEnv env, Connector con, TrustChecker tc, Object ... additionalTafLurs) throws CadiException { - super(env,con, tc, additionalTafLurs); - this.env = env; - serviceMetric = new Metric(); - serviceMetric.buckets = new float[BUCKETSIZE]; - if(transIDslot==null) { - transIDslot = env.slot(TRANS_ID_SLOT); - } - } - - @Override - protected AuthzTrans newTrans() { - AuthzTrans at = env.newTrans(); - at.setLur(getLur()); - return at; - } - - @Override - protected TimeTaken start(AuthzTrans trans, ServletRequest request) { - trans.set((HttpServletRequest)request); - return trans.start("Trans " + //(context==null?"n/a":context.toString()) + - " IP: " + trans.ip() + - " Port: " + trans.port() - , Env.SUB); - } - - @Override - protected void authenticated(AuthzTrans trans, Principal p) { - trans.setUser(p); - } - - @Override - protected void tallyHo(AuthzTrans trans) { - if(trans.info().isLoggable()) { - // Transaction is done, now post - StringBuilder sb = new StringBuilder("AuditTrail\n"); - // We'll grabAct sub-metrics for Remote Calls and JSON - // IMPORTANT!!! if you add more entries here, change "BUCKETSIZE"!!! - Metric m = trans.auditTrail(1, sb, Env.REMOTE,Env.JSON); - - // Add current Metrics to total metrics - serviceMetric.total+= m.total; - for(int i=0;i { - private AuthzEnv env; - public Metric serviceMetric; - - public static final int BUCKETSIZE = 2; - - public AuthzTransOnlyFilter(AuthzEnv env) { - this.env = env; - serviceMetric = new Metric(); - serviceMetric.buckets = new float[BUCKETSIZE]; - } - - @Override - protected AuthzTrans newTrans() { - return env.newTrans(); - } - - @Override - protected TimeTaken start(AuthzTrans trans, ServletRequest request) { - trans.set((HttpServletRequest)request); - return trans.start("Trans " + //(context==null?"n/a":context.toString()) + - " IP: " + trans.ip() + - " Port: " + trans.port() - , Env.SUB); - } - - @Override - protected void authenticated(AuthzTrans trans, Principal p) { - trans.setUser(p); - } - - @Override - protected void tallyHo(AuthzTrans trans) { - // Transaction is done, now post - StringBuilder sb = new StringBuilder("AuditTrail\n"); - // We'll grab sub-metrics for Remote Calls and JSON - // IMPORTANT!!! if you add more entries here, change "BUCKETSIZE"!!! - Metric m = trans.auditTrail(1, sb, Env.REMOTE,Env.JSON); - // Add current Metrics to total metrics - serviceMetric.total+= m.total; - for(int i=0;i T get(Slot slot, T deflt) { - return null; - } - @Override - public T get(StaticSlot slot, T dflt) { - return null; - } - @Override - public void setUser(Principal p) { - } - @Override - public Slot slot(String name) { - return null; - } - @Override - public AuthzEnv env() { - return null; - } - @Override - public String agent() { - return null; - } - - @Override - public void setLur(Lur lur) { - } - - @Override - public boolean fish(Permission p) { - return false; - } - - @Override - public boolean forceRequested() { - return false; - } - - @Override - public boolean futureRequested() { - return false; - } - - @Override - public boolean moveRequested() { - return false; - } - - @Override - public Organization org() { - return Organization.NULL; - } - - @Override - public void logAuditTrail(LogTarget lt) { - } - - @Override - public Metric auditTrail(LogTarget lt, int indent, StringBuilder sb, int... flag) { - // TODO Auto-generated method stub - return null; - } - -} - diff --git a/authz-core/src/main/java/org/onap/aaf/authz/layer/FacadeImpl.java b/authz-core/src/main/java/org/onap/aaf/authz/layer/FacadeImpl.java deleted file mode 100644 index 7f1fef8b..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/layer/FacadeImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.layer; - -import javax.servlet.http.HttpServletResponse; - -import org.onap.aaf.inno.env.Data; -import org.onap.aaf.inno.env.Data.TYPE; - - - -public abstract class FacadeImpl { - protected static final String IN = "in"; - - protected void setContentType(HttpServletResponse response, TYPE type) { - response.setContentType(type==Data.TYPE.JSON?"application/json":"text.xml"); - } -} diff --git a/authz-core/src/main/java/org/onap/aaf/authz/layer/Result.java b/authz-core/src/main/java/org/onap/aaf/authz/layer/Result.java deleted file mode 100644 index 7b7bcd08..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/layer/Result.java +++ /dev/null @@ -1,325 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.layer; - -import java.util.Collection; -import java.util.List; -import java.util.Set; - - -/** - * It would be nice if Java Enums were extensible, but they're not. - * - * - */ -public class Result { - private static final String SUCCESS = "Success"; - public static final String[] EMPTY_VARS = new String[0]; - - public final static int OK=0, - ERR_Security = 1, - ERR_Denied = 2, - ERR_Policy = 3, - ERR_BadData = 4, - ERR_NotImplemented = 5, - ERR_NotFound = 6, - ERR_ConflictAlreadyExists = 7, - ERR_ActionNotCompleted = 8, - ERR_Backend = 9, - ERR_General = 20; - - public final RV value; - public final int status; - public final String details; - public final String[] variables; - - protected Result(RV value, int status, String details, String[] variables) { - this.value = value; - if(value==null) { - specialCondition|=EMPTY_LIST; - } - this.status = status; - this.details = details; - if(variables==null) { - this.variables = EMPTY_VARS; - } else { - this.variables=variables; - } - } - - /** - * Create a Result class with "OK" status and "Success" for details - * - * This is the easiest to use - * - * @param value - * @param status - * @return - */ - public static Result ok(R value) { - return new Result(value,OK,SUCCESS,null); - } - - /** - * Accept Arrays and mark as empty or not - * @param value - * @return - */ - public static Result ok(R value[]) { - return new Result(value,OK,SUCCESS,null).emptyList(value.length==0); - } - - /** - * Accept Sets and mark as empty or not - * @param value - * @return - */ - public static Result> ok(Set value) { - return new Result>(value,OK,SUCCESS,null).emptyList(value.size()==0); - } - - /** - * Accept Lists and mark as empty or not - * @param value - * @return - */ - public static Result> ok(List value) { - return new Result>(value,OK,SUCCESS,null).emptyList(value.size()==0); - } - - /** - * Accept Collections and mark as empty or not - * @param value - * @return - */ - public static Result> ok(Collection value) { - return new Result>(value,OK,SUCCESS,null).emptyList(value.size()==0); - } - - - /** - * Special Case for Void Type - * @return - */ - public static Result ok() { - return new Result(null,OK,SUCCESS,null); - } - - /** - * Create a Status (usually non OK, with a details statement - * @param value - * @param status - * @param details - * @return - */ -// public static Result err(int status, String details) { -// return new Result(null,status,details,null); -// } - - /** - * Create a Status (usually non OK, with a details statement and variables supported - * @param status - * @param details - * @param variables - * @return - */ - public static Result err(int status, String details, String ... variables) { - return new Result(null,status,details,variables); - } - - /** - * Create Error from status and Details of previous Result (and not data) - * @param pdr - * @return - */ - public static Result err(Result pdr) { - return new Result(null,pdr.status,pdr.details,pdr.variables); - } - - /** - * Create General Error from Exception - * @param e - * @return - */ - public static Result err(Exception e) { - return new Result(null,ERR_General,e.getMessage(),EMPTY_VARS); - } - - /** - * Create a Status (usually non OK, with a details statement - * @param value - * @param status - * @param details - * @return - */ - public static Result create(R value, int status, String details, String ... vars) { - return new Result(value,status,details,vars); - } - - /** - * Create a Status from a previous status' result/details - * @param value - * @param status - * @param details - * @return - */ - public static Result create(R value, Result result) { - return new Result(value,result.status,result.details,result.variables); - } - - private static final int PARTIAL_CONTENT = 0x001; - private static final int EMPTY_LIST = 0x002; - - /** - * AAF Specific problems, etc - * - * - */ - - /** - * specialCondition is a bit field to enable multiple conditions, e.g. PARTIAL_CONTENT - */ - private int specialCondition = 0; - - - /** - * Is result set only partial results, i.e. the DAO clipped the real result set to a smaller number. - * @return true iff result returned PARTIAL_CONTENT - */ - public boolean partialContent() { - return (specialCondition & PARTIAL_CONTENT) == PARTIAL_CONTENT; - } - - /** - * Set fact that result set only returned partial results, i.e. the DAO clipped the real result set to a smaller number. - * @param hasPartialContent set true iff result returned PARTIAL_CONTENT - * @return this Result object, so you can chain calls, in builder style - */ - public Result partialContent(boolean hasPartialContent) { - if (hasPartialContent) { - specialCondition |= PARTIAL_CONTENT; - } else { - specialCondition &= (~PARTIAL_CONTENT); - } - return this; - } - - /** - * When Result is a List, you can check here to see if it's empty instead of looping - * - * @return - */ - public boolean isEmpty() { - return (specialCondition & EMPTY_LIST) == EMPTY_LIST; - } - - /** - * A common occurrence is that data comes back, but list is empty. If set, you can skip looking - * at list at the outset. - * - * @param emptyList - * @return - */ - public Result emptyList(boolean emptyList) { - if (emptyList) { - specialCondition |= EMPTY_LIST; - } else { - specialCondition &= (~EMPTY_LIST); - } - return this; - } - - - /** - * Convenience function. Checks OK, and also if List is not Empty - * Not valid if Data is not a List - * @return - */ - public boolean isOK() { - return status == OK; - } - - /** - * Convenience function. Checks OK, and also if List is not Empty - * Not valid if Data is not a List - * @return - */ - public boolean notOK() { - return status != OK; - } - - /** - * Convenience function. Checks OK, and also if List is not Empty - * Not valid if Data is not a List - * @return - */ - public boolean isOKhasData() { - return status == OK && (specialCondition & EMPTY_LIST) != EMPTY_LIST; - } - - - /** - * Convenience function. Checks OK, and also if List is not Empty - * Not valid if Data is not a List - * @return - */ - public boolean notOKorIsEmpty() { - return status != OK || (specialCondition & EMPTY_LIST) == EMPTY_LIST; - } - - @Override - public String toString() { - if(status==0) { - return details; - } else { - StringBuilder sb = new StringBuilder(); - sb.append(status); - sb.append(':'); - sb.append(String.format(details,((Object[])variables))); - if(isEmpty()) { - sb.append("{empty}"); - } - sb.append('-'); - sb.append(value.toString()); - return sb.toString(); - } - } - - public String errorString() { - StringBuilder sb = new StringBuilder(); - switch(status) { - case 1: sb.append("Security"); break; - case 2: sb.append("Denied"); break; - case 3: sb.append("Policy"); break; - case 4: sb.append("BadData"); break; - case 5: sb.append("NotImplemented"); break; - case 6: sb.append("NotFound"); break; - case 7: sb.append("AlreadyExists"); break; - case 8: sb.append("ActionNotComplete"); break; - default: sb.append("Error"); - } - sb.append(" - "); - sb.append(String.format(details, (Object[])variables)); - return sb.toString(); - } -} diff --git a/authz-core/src/main/java/org/onap/aaf/authz/local/AbsData.java b/authz-core/src/main/java/org/onap/aaf/authz/local/AbsData.java deleted file mode 100644 index 30231b89..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/local/AbsData.java +++ /dev/null @@ -1,215 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.local; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.util.Iterator; - -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.local.DataFile.Token; -import org.onap.aaf.authz.local.DataFile.Token.Field; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; - -public abstract class AbsData implements Iterable { - protected DataFile data; - protected TextIndex ti; - private File dataf,idxf,lockf; - private String name; - private char delim; - private int maxLineSize; - private int fieldOffset; - private int skipLines; - - public AbsData(File dataf,char sepChar, int maxLineSize, int fieldOffset) { - File dir = dataf.getParentFile(); - int dot = dataf.getName().lastIndexOf('.'); - if(dot>=0) { - name = dataf.getName().substring(0,dot); - } - - this.dataf=dataf; - this.delim = sepChar; - this.maxLineSize = maxLineSize; - this.fieldOffset = fieldOffset; - idxf = new File(dir,name.concat(".idx")); - lockf = new File(dir,name.concat(".lock")); - - - data = new DataFile(dataf,"r"); - ti = new TextIndex(idxf); - skipLines=0; - } - - public void skipLines(int lines) { - skipLines=lines; - } - - public String name() { - return name; - } - - public void open(AuthzTrans trans, long timeout) throws IOException { - TimeTaken tt = trans.start("Open Data File", Env.SUB); - boolean opened = false, first = true; - try { - if(!dataf.exists()) { - throw new FileNotFoundException("Data File Missing:" + dataf.getCanonicalPath()); - } - long begin = System.currentTimeMillis(); - long end = begin+timeout; - boolean exists; - while((exists=lockf.exists()) && beginidxf.lastModified()) { - trans.warn().log(idxf.getCanonicalPath(),"is missing, empty or out of date, creating"); - RandomAccessFile raf = new RandomAccessFile(lockf, "rw"); - try { - ti.create(trans, data, maxLineSize, delim, fieldOffset, skipLines); - if(!idxf.exists() || (idxf.length()==0 && dataf.length()!=0)) { - throw new IOException("Data Index File did not create correctly"); - } - } finally { - raf.close(); - lockf.delete(); - } - } - } - - public void close(AuthzTrans trans) throws IOException { - ti.close(); - data.close(); - } - - public class Reuse { - private Token tokenData; - private Field fieldData; - - private Reuse(int size,char delim) { - tokenData = data.new Token(size); - fieldData = getTokenData().new Field(delim); - } - - public void reset() { - getFieldData().reset(); - } - - public void pos(int rec) { - getFieldData().reset(); - getTokenData().pos(rec); - } - - public String next() { - return getFieldData().next(); - } - - public String at(int field) { - return getFieldData().at(field); - } - - public String atToEnd(int field) { - return getFieldData().atToEnd(field); - } - - public Field getFieldData() { - return fieldData; - } - - public Token getTokenData() { - return tokenData; - } - - } - - public Reuse reuse() { - return new Reuse(maxLineSize,delim); - } - - public Iter iterator() { - return new Iter(); - } - - public class Iter implements Iterator { - private Reuse reuse; - private org.onap.aaf.authz.local.TextIndex.Iter tii; - - public Iter() { - reuse = reuse(); - tii = ti.new Iter(); - } - - @Override - public boolean hasNext() { - return tii.hasNext(); - } - - @Override - public String next() { - reuse.reset(); - int rec = tii.next(); - reuse.pos(rec); - return reuse.at(0); - } - - @Override - public void remove() { - // read only - } - } -} diff --git a/authz-core/src/main/java/org/onap/aaf/authz/local/DataFile.java b/authz-core/src/main/java/org/onap/aaf/authz/local/DataFile.java deleted file mode 100644 index a0270395..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/local/DataFile.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.local; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; -import java.nio.MappedByteBuffer; -import java.nio.channels.FileChannel; -import java.nio.channels.FileChannel.MapMode; - -public class DataFile { - private RandomAccessFile rafile; - private FileChannel channel; - public MappedByteBuffer mapBuff; - private final File file; - private final String access; - - public DataFile(File file, String access) { - this.file = file; - this.access = access; - } - public void open() throws IOException { - if(!file.exists()) throw new FileNotFoundException(); - rafile = new RandomAccessFile(file,access); - channel = rafile.getChannel(); - mapBuff = channel.map("r".equals(access)?MapMode.READ_ONLY:MapMode.READ_WRITE,0,channel.size()); - } - public void close() throws IOException { - if(channel!=null){channel.close();} - if(rafile!=null) {rafile.close();} - mapBuff = null; - } - - public long size() throws IOException { - return channel.size(); - } - - private synchronized int load(Token t) { - int len = Math.min(mapBuff.limit()-t.next,t.buff.length); - if(len>0) { - mapBuff.position(t.next); - mapBuff.get(t.buff,0,len); - } - return len<0?0:len; - } - - public class Token { - private byte[] buff; - int pos, next, end; - - public Token(int size) { - buff = new byte[size]; - pos = next = end = 0; - } - - public boolean pos(int to) { - pos = next = to; - return (end=load(this))>0; - } - - public boolean nextLine() { - end = load(this); - pos = next; - for(int i=0;i=end)return null; - int start = idx; - byte c=0; - int endStr = -1; - while(idx=end)?1:0))); - } - - } - - public int pos() { - return pos; - } - } - - public File file() { - return file; - } - -} diff --git a/authz-core/src/main/java/org/onap/aaf/authz/local/TextIndex.java b/authz-core/src/main/java/org/onap/aaf/authz/local/TextIndex.java deleted file mode 100644 index cb339a47..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/local/TextIndex.java +++ /dev/null @@ -1,253 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.local; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; -import java.nio.channels.FileChannel; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -import org.onap.aaf.authz.local.DataFile.Token; -import org.onap.aaf.authz.local.DataFile.Token.Field; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; - -public class TextIndex { - private static final int REC_SIZE=8; - - private File file; - private DataFile dataFile=null; - - public TextIndex(File theFile) { - file = theFile; - } - - public void open() throws IOException { - dataFile = new DataFile(file,"r"); - dataFile.open(); - } - - public void close() throws IOException { - if(dataFile!=null) {dataFile.close();} - } - - public int find(Object key, AbsData.Reuse reuse, int offset) throws IOException { - return find(key,reuse.getTokenData(),reuse.getFieldData(),offset); - } - - public int find(Object key, DataFile.Token dtok, Field df, int offset) throws IOException { - if(dataFile==null) {throw new IOException("File not opened");} - long hash = hashToLong(key.hashCode()); - int min=0, max = (int)(dataFile.size()/REC_SIZE); - Token ttok = dataFile.new Token(REC_SIZE); - IntBuffer tib = ttok.getIntBuffer(); - long lhash; - int curr; - while((max-min)>100) { - ttok.pos((curr=(min+(max-min)/2))*REC_SIZE); - tib.rewind(); - lhash = hashToLong(tib.get()); - if(lhashhash) { - max=curr-1; - } else { - min=curr-40; - max=curr+40; - break; - } - } - - List entries = new ArrayList(); - for(int i=min;i<=max;++i) { - ttok.pos(i*REC_SIZE); - tib.rewind(); - lhash = hashToLong(tib.get()); - if(lhash==hash) { - entries.add(tib.get()); - } else if(lhash>hash) { - break; - } - } - - for(Integer i : entries) { - dtok.pos(i); - if(df.at(offset).equals(key)) { - return i; - } - } - return -1; - } - - - /* - * Have to change Bytes into a Long, to avoid the inevitable signs in the Hash - */ - private static long hashToLong(int hash) { - long rv; - if(hash<0) { - rv = 0xFFFFFFFFL & hash; - } else { - rv = hash; - } - return rv; - } - - public void create(final Trans trans,final DataFile data, int maxLine, char delim, int fieldOffset, int skipLines) throws IOException { - RandomAccessFile raf; - FileChannel fos; - - List list = new LinkedList(); // Some hashcodes will double... DO NOT make a set - TimeTaken tt2 = trans.start("Open Files", Env.SUB); - try { - raf = new RandomAccessFile(file,"rw"); - raf.setLength(0L); - fos = raf.getChannel(); - } finally { - tt2.done(); - } - - try { - - Token t = data.new Token(maxLine); - Field f = t.new Field(delim); - - int count = 0; - if(skipLines>0) { - trans.info().log("Skipping",skipLines,"line"+(skipLines==1?" in":"s in"),data.file().getName()); - } - for(int i=0;i { - public int hash, pos; - public Idx(Object obj, int pos) { - hash = obj.hashCode(); - this.pos = pos; - } - - @Override - public int compareTo(Idx ib) { - long a = hashToLong(hash); - long b = hashToLong(ib.hash); - return a>b?1:a 1, remove User from Owner - // if # of Owners = 1, changeOwner to X Remove Owner???? - boolean hasPermission(String user, String ns, String type, String instance, String action); - boolean inRole(String name); - - public String namespace() throws Exception; - public String id(); -} diff --git a/authz-core/src/main/java/org/onap/aaf/authz/org/Organization.java b/authz-core/src/main/java/org/onap/aaf/authz/org/Organization.java deleted file mode 100644 index 2ed4d37f..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/org/Organization.java +++ /dev/null @@ -1,490 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.org; - -import java.util.ArrayList; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.onap.aaf.authz.env.AuthzTrans; - -/** - * Organization - * - * There is Organizational specific information required which we have extracted to a plugin - * - * It supports using Company Specific User Directory lookups, as well as supporting an - * Approval/Validation Process to simplify control of Roles and Permissions for large organizations - * in lieu of direct manipulation by a set of Admins. - * - * - */ -public interface Organization { - public static final String N_A = "n/a"; - - public interface Identity { - public String id(); - public String fullID(); // Fully Qualified ID (includes Domain of Organization) - public String type(); // Must be one of "IdentityTypes", see below - public String responsibleTo(); // Chain of Command, Comma Separated if required - public List delegate(); // Someone who has authority to act on behalf of Identity - public String email(); - public String fullName(); - public boolean isResponsible(); // Is id passed belong to a person suitable to be Responsible for content Management - public boolean isFound(); // Is Identity found in Identity stores - public Identity owner() throws OrganizationException; // Identity is directly responsible for App ID - public Organization org(); // Organization of Identity - } - - - /** - * Name of Organization, suitable for Logging - * @return - */ - public String getName(); - - /** - * Realm, for use in distinguishing IDs from different systems/Companies - * @return - */ - public String getRealm(); - - String getDomain(); - - /** - * Get Identity information based on userID - * - * @param id - * @return - */ - public Identity getIdentity(AuthzTrans trans, String id) throws OrganizationException; - - - /** - * Does the ID pass Organization Standards - * - * Return a Blank (empty) String if empty, otherwise, return a "\n" separated list of - * reasons why it fails - * - * @param id - * @return - */ - public String isValidID(String id); - - /** - * Return a Blank (empty) String if empty, otherwise, return a "\n" separated list of - * reasons why it fails - * - * Identity is passed in to allow policies regarding passwords that are the same as user ID - * - * any entries for "prev" imply a reset - * - * @param id - * @param password - * @return - */ - public String isValidPassword(String user, String password, String ... prev); - - - /** - * Does your Company distinguish essential permission structures by kind of Identity? - * i.e. Employee, Contractor, Vendor - * @return - */ - public Set getIdentityTypes(); - - public enum Notify { - Approval(1), - PasswordExpiration(2), - RoleExpiration(3); - - final int id; - Notify(int id) {this.id = id;} - public int getValue() {return id;} - public static Notify from(int type) { - for(Notify t : Notify.values()) { - if(t.id==type) { - return t; - } - } - return null; - } - } - - public enum Response{ - OK, - ERR_NotImplemented, - ERR_UserNotExist, - ERR_NotificationFailure, - }; - - public enum Expiration { - Password, - TempPassword, - Future, - UserInRole, - UserDelegate, - ExtendPassword - } - - public enum Policy { - CHANGE_JOB, - LEFT_COMPANY, - CREATE_MECHID, - CREATE_MECHID_BY_PERM_ONLY, - OWNS_MECHID, - AS_EMPLOYEE, - MAY_EXTEND_CRED_EXPIRES - } - - /** - * Notify a User of Action or Info - * - * @param type - * @param url - * @param users (separated by commas) - * @param ccs (separated by commas) - * @param summary - */ - - public Response notify(AuthzTrans trans, Notify type, String url, String ids[], String ccs[], String summary, Boolean urgent); - - /** - * (more) generic way to send an email - * - * @param toList - * @param ccList - * @param subject - * @param body - * @param urgent - */ - - public int sendEmail(AuthzTrans trans, List toList, List ccList, String subject, String body, Boolean urgent) throws OrganizationException; - - /** - * whenToValidate - * - * Authz support services will ask the Organization Object at startup when it should - * kickoff Validation processes given particular types. - * - * This allows the Organization to express Policy - * - * Turn off Validation behavior by returning "null" - * - */ - public Date whenToValidate(Notify type, Date lastValidated); - - - /** - * Expiration - * - * Given a Calendar item of Start (or now), set the Expiration Date based on the Policy - * based on type. - * - * For instance, "Passwords expire in 3 months" - * - * The Extra Parameter is used by certain Orgs. - * - * For Password, the extra is UserID, so it can check the Identity Type - * - * @param gc - * @param exp - * @return - */ - public GregorianCalendar expiration(GregorianCalendar gc, Expiration exp, String ... extra); - - /** - * Get Email Warning timing policies - * @return - */ - public EmailWarnings emailWarningPolicy(); - - /** - * - * @param trans - * @param user - * @return - */ - public List getApprovers(AuthzTrans trans, String user) throws OrganizationException ; - - /* - * - * @param user - * @param type - * @param users - * @return - public Response notifyRequest(AuthzTrans trans, String user, Approval type, List approvers); - */ - - /** - * - * @return - */ - public String getApproverType(); - - /* - * startOfDay - define for company what hour of day business starts (specifically for password and other expiration which - * were set by Date only.) - * - * @return - */ - public int startOfDay(); - - /** - * implement this method to support any IDs that can have multiple entries in the cred table - * NOTE: the combination of ID/expiration date/(encryption type when implemented) must be unique. - * Since expiration date is based on startOfDay for your company, you cannot create many - * creds for the same ID in the same day. - * @param id - * @return - */ - public boolean canHaveMultipleCreds(String id); - - /** - * - * @param id - * @return - */ - public boolean isValidCred(String id); - - /** - * If response is Null, then it is valid. Otherwise, the Organization specific reason is returned. - * - * @param trans - * @param policy - * @param executor - * @param vars - * @return - * @throws OrganizationException - */ - public String validate(AuthzTrans trans, Policy policy, Executor executor, String ... vars) throws OrganizationException; - - boolean isTestEnv(); - - public void setTestMode(boolean dryRun); - - public static final Organization NULL = new Organization() - { - private final GregorianCalendar gc = new GregorianCalendar(1900, 1, 1); - private final List nullList = new ArrayList(); - private final Set nullStringSet = new HashSet(); - private final Identity nullIdentity = new Identity() { - List nullIdentity = new ArrayList(); - @Override - public String type() { - return N_A; - } - @Override - public String responsibleTo() { - return N_A; - } - @Override - public boolean isResponsible() { - return false; - } - - @Override - public boolean isFound() { - return false; - } - - @Override - public String id() { - return N_A; - } - - @Override - public String fullID() { - return N_A; - } - - @Override - public String email() { - return N_A; - } - - @Override - public List delegate() { - return nullIdentity; - } - @Override - public String fullName() { - return N_A; - } - @Override - public Identity owner() { - return null; - } - @Override - public Organization org() { - return NULL; - } - }; - - @Override - public String getName() { - return N_A; - } - - @Override - public String getRealm() { - return N_A; - } - - @Override - public String getDomain() { - return N_A; - } - - @Override - public Identity getIdentity(AuthzTrans trans, String id) { - return nullIdentity; - } - - @Override - public String isValidID(String id) { - return N_A; - } - - @Override - public String isValidPassword(String user, String password,String... prev) { - return N_A; - } - - @Override - public Set getIdentityTypes() { - return nullStringSet; - } - - @Override - public Response notify(AuthzTrans trans, Notify type, String url, - String[] users, String[] ccs, String summary, Boolean urgent) { - return Response.ERR_NotImplemented; - } - - @Override - public int sendEmail(AuthzTrans trans, List toList, List ccList, - String subject, String body, Boolean urgent) throws OrganizationException { - return 0; - } - - @Override - public Date whenToValidate(Notify type, Date lastValidated) { - return gc.getTime(); - } - - @Override - public GregorianCalendar expiration(GregorianCalendar gc, - Expiration exp, String... extra) { - return gc==null?new GregorianCalendar():gc; - } - - @Override - public List getApprovers(AuthzTrans trans, String user) - throws OrganizationException { - return nullList; - } - - @Override - public String getApproverType() { - return ""; - } - - @Override - public int startOfDay() { - return 0; - } - - @Override - public boolean canHaveMultipleCreds(String id) { - return false; - } - - @Override - public boolean isValidCred(String id) { - return false; - } - - @Override - public String validate(AuthzTrans trans, Policy policy, Executor executor, String ... vars) - throws OrganizationException { - return "Null Organization rejects all Policies"; - } - - @Override - public boolean isTestEnv() { - return false; - } - - @Override - public void setTestMode(boolean dryRun) { - } - - @Override - public EmailWarnings emailWarningPolicy() { - return new EmailWarnings() { - - @Override - public long credEmailInterval() - { - return 604800000L; // 7 days in millis 1000 * 86400 * 7 - } - - @Override - public long roleEmailInterval() - { - return 604800000L; // 7 days in millis 1000 * 86400 * 7 - } - - @Override - public long apprEmailInterval() { - return 259200000L; // 3 days in millis 1000 * 86400 * 3 - } - - @Override - public long credExpirationWarning() - { - return( 2592000000L ); // One month, in milliseconds 1000 * 86400 * 30 in milliseconds - } - - @Override - public long roleExpirationWarning() - { - return( 2592000000L ); // One month, in milliseconds 1000 * 86400 * 30 in milliseconds - } - - @Override - public long emailUrgentWarning() - { - return( 1209600000L ); // Two weeks, in milliseconds 1000 * 86400 * 14 in milliseconds - } - - }; - } - }; -} - - diff --git a/authz-core/src/main/java/org/onap/aaf/authz/org/OrganizationException.java b/authz-core/src/main/java/org/onap/aaf/authz/org/OrganizationException.java deleted file mode 100644 index fa23a4ce..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/org/OrganizationException.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.org; - -public class OrganizationException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public OrganizationException() { - super(); - } - - public OrganizationException(String message) { - super(message); - } - - public OrganizationException(Throwable cause) { - super(cause); - } - - public OrganizationException(String message, Throwable cause) { - super(message, cause); - } - - public OrganizationException(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } - -} diff --git a/authz-core/src/main/java/org/onap/aaf/authz/org/OrganizationFactory.java b/authz-core/src/main/java/org/onap/aaf/authz/org/OrganizationFactory.java deleted file mode 100644 index 653e9270..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/org/OrganizationFactory.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.org; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.authz.env.AuthzTrans; - -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Slot; - -/** - * Organization Plugin Mechanism - * - * Define a NameSpace for the company (i.e. com.att), and put in Properties as - * "Organization.[your NS" and assign the supporting Class. - * - * Example: - * Organization.com.att=org.onap.aaf.authz.org.att.ATT - * - * - */ -public class OrganizationFactory { - public static final String ORG_SLOT = "ORG_SLOT"; - private static Organization defaultOrg = null; - private static Map orgs = new ConcurrentHashMap(); - private static Slot orgSlot; - - public static void setDefaultOrg(AuthzEnv env, String orgClass) throws APIException { - orgSlot = env.slot(ORG_SLOT); - try { - @SuppressWarnings("unchecked") - Class cls = (Class) Class.forName(orgClass); - Constructor cnst = cls.getConstructor(AuthzEnv.class); - defaultOrg = cnst.newInstance(env); - } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | - InstantiationException | IllegalAccessException | IllegalArgumentException | - InvocationTargetException e) { - throw new APIException(e); - } - } - - public static Organization obtain(AuthzEnv env,String orgNS) throws OrganizationException { - int at = orgNS.indexOf('@'); - if(at<0) { - if(!orgNS.startsWith("com.")) { - int dot1; - if((dot1 = orgNS.lastIndexOf('.'))>-1) { - int dot2; - StringBuilder sb = new StringBuilder(); - if((dot2 = orgNS.lastIndexOf('.',dot1-1))>-1) { - sb.append(orgNS,dot1+1,orgNS.length()); - sb.append('.'); - sb.append(orgNS,dot2+1,dot1); - } else { - sb.append(orgNS,dot1+1,orgNS.length()); - sb.append('.'); - sb.append(orgNS,at+1,dot1); - } - orgNS=sb.toString(); - } - } - } else { - // Only use two places (Enterprise) of domain - int dot; - if((dot= orgNS.lastIndexOf('.'))>-1) { - StringBuilder sb = new StringBuilder(); - int dot2; - if((dot2 = orgNS.lastIndexOf('.',dot-1))>-1) { - sb.append(orgNS.substring(dot+1)); - sb.append(orgNS.subSequence(dot2, dot)); - orgNS = sb.toString(); - } else { - sb.append(orgNS.substring(dot+1)); - sb.append('.'); - sb.append(orgNS.subSequence(at+1, dot)); - orgNS = sb.toString(); - } - } - } - Organization org = orgs.get(orgNS); - if(org == null) { - String orgClass = env.getProperty("Organization."+orgNS); - if(orgClass == null) { - env.warn().log("There is no Organization." + orgNS + " property"); - } else { - for(Organization o : orgs.values()) { - if(orgClass.equals(o.getClass().getName())) { - org = o; - } - } - if(org==null) { - try { - @SuppressWarnings("unchecked") - Class cls = (Class) Class.forName(orgClass); - Constructor cnst = cls.getConstructor(AuthzEnv.class); - org = cnst.newInstance(env); - } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | - InstantiationException | IllegalAccessException | IllegalArgumentException | - InvocationTargetException e) { - throw new OrganizationException(e); - } - } - orgs.put(orgNS, org); - } - if(org==null && defaultOrg!=null) { - org=defaultOrg; - orgs.put(orgNS, org); - } - } - - return org; - } - - public static void set(AuthzTrans trans, String orgNS) throws OrganizationException { - Organization org = obtain(trans.env(),orgNS); - trans.put(orgSlot, org); - } - - public static Organization get(AuthzTrans trans) { - return trans.get(orgSlot,defaultOrg); - } - -} diff --git a/authz-core/src/main/java/org/onap/aaf/authz/server/AbsServer.java b/authz-core/src/main/java/org/onap/aaf/authz/server/AbsServer.java deleted file mode 100644 index 3ad45f55..00000000 --- a/authz-core/src/main/java/org/onap/aaf/authz/server/AbsServer.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.server; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Constructor; -import java.net.URL; -import java.security.GeneralSecurityException; -import java.security.Principal; -import java.util.Properties; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocketFactory; - -import org.onap.aaf.authz.common.Define; -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.cssa.rserv.RServlet; - -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.LocatorException; -//import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.http.HTransferSS; -import org.onap.aaf.inno.env.APIException; - -public abstract class AbsServer extends RServlet { - private static final String AAF_API_VERSION = "2.0"; - public final String app; - public final AuthzEnv env; - public AAFConHttp aafCon; - - public AbsServer(final AuthzEnv env, final String app) throws CadiException, GeneralSecurityException, IOException { - this.env = env; - this.app = app; - if(env.getProperty(Config.AAF_URL)!=null) { - //aafCon = new AAFConHttp(env); - } - } - - // This is a method, so we can overload for AAFAPI - public String aaf_url() { - return env.getProperty(Config.AAF_URL); - } - - public abstract void startDME2(Properties props) throws Exception; - public static void setup(Class abss, String propFile) { - - try { - // Load Properties from authFramework.properties. Needed for DME2 and AuthzEnv - Properties props = new Properties(); - URL rsrc = ClassLoader.getSystemResource(propFile); - if(rsrc==null) { - System.err.println("Folder containing " + propFile + " must be on Classpath"); - System.exit(1); - } - - InputStream is = rsrc.openStream(); - try { - props.load(is); - } finally { - is.close(); - is=null; - } - - // Load Properties into AuthzEnv - AuthzEnv env = new AuthzEnv(props); - // Log where Config found - env.init().log("Configuring from",rsrc.getPath()); - rsrc = null; - - // Print Cipher Suites Available - if(env.debug().isLoggable()) { - SSLContext context = SSLContext.getDefault(); - SSLSocketFactory sf = context.getSocketFactory(); - StringBuilder sb = new StringBuilder("Available Cipher Suites: "); - boolean first = true; - int count=0; - for( String cs : sf.getSupportedCipherSuites()) { - if(first)first = false; - else sb.append(','); - sb.append(cs); - if(++count%4==0){sb.append('\n');} - } - env.debug().log(sb); - } - - // Set ROOT NS, etc - Define.set(env); - - // Convert CADI properties and Encrypted Passwords for these two properties (if exist) - // to DME2 Readable. Further, Discovery Props are loaded to System if missing. - // May be causing client errors - //Config.cadiToDME2(env,props); - env.init().log("DME2 ServiceName: " + env.getProperty("DMEServiceName","unknown")); - - // Construct with Env - Constructor cons = abss.getConstructor(new Class[] {AuthzEnv.class}); - // Start DME2 (DME2 needs Properties form of props) - AbsServer s = (AbsServer)cons.newInstance(env); - - // Schedule removal of Clear Text Passwords from System Props (DME2 Requirement) -// new Timer("PassRemove").schedule(tt, 120000); -// tt=null; - - s.startDME2(props); - } catch (Exception e) { - e.printStackTrace(System.err); - System.exit(1); - } - } - - public Rcli client() throws CadiException { - return aafCon.client(AAF_API_VERSION); - } - - public Rcli clientAsUser(Principal p) throws CadiException { - return aafCon.client(AAF_API_VERSION).forUser( - new HTransferSS(p,app, aafCon.securityInfo())); - } - - public RET clientAsUser(Principal p,Retryable retryable) throws APIException, LocatorException, CadiException { - return aafCon.hman().best(new HTransferSS(p,app, aafCon.securityInfo()), retryable); - } - -} diff --git a/authz-core/src/main/java/org/onap/aaf/cache/Cache.java b/authz-core/src/main/java/org/onap/aaf/cache/Cache.java deleted file mode 100644 index 3434ca70..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cache/Cache.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cache; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Level; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.Trans; - -/** - * Create and maintain a Map of Maps used for Caching - * - * - * @param - * @param - */ -public class Cache { - private static Clean clean; - private static Timer cleanseTimer; - - public static final String CACHE_HIGH_COUNT = "CACHE_HIGH_COUNT"; - public static final String CACHE_CLEAN_INTERVAL = "CACHE_CLEAN_INTERVAL"; -// public static final String CACHE_MIN_REFRESH_INTERVAL = "CACHE_MIN_REFRESH_INTERVAL"; - - private static final Map> cacheMap; - - static { - cacheMap = new HashMap>(); - } - - /** - * Dated Class - store any Data with timestamp - * - * - */ - public final static class Dated { - public Date timestamp; - public List data; - - public Dated(List data) { - timestamp = new Date(); - this.data = data; - } - - public Dated(T t) { - timestamp = new Date(); - ArrayList al = new ArrayList(1); - al.add(t); - data = al; - } - - public void touch() { - timestamp = new Date(); - } - } - - public static Map obtain(String key) { - Map m = cacheMap.get(key); - if(m==null) { - m = new ConcurrentHashMap(); - synchronized(cacheMap) { - cacheMap.put(key, m); - } - } - return m; - } - - /** - * Clean will examine resources, and remove those that have expired. - * - * If "highs" have been exceeded, then we'll expire 10% more the next time. This will adjust after each run - * without checking contents more than once, making a good average "high" in the minimum speed. - * - * - */ - private final static class Clean extends TimerTask { - private final Env env; - private Set set; - - // The idea here is to not be too restrictive on a high, but to Expire more items by - // shortening the time to expire. This is done by judiciously incrementing "advance" - // when the "highs" are exceeded. This effectively reduces numbers of cached items quickly. - private final int high; - private long advance; - private final long timeInterval; - - public Clean(Env env, long cleanInterval, int highCount) { - this.env = env; - high = highCount; - timeInterval = cleanInterval; - advance = 0; - set = new HashSet(); - } - - public synchronized void add(String key) { - set.add(key); - } - - public void run() { - int count = 0; - int total = 0; - // look at now. If we need to expire more by increasing "now" by "advance" - Date now = new Date(System.currentTimeMillis() + advance); - - - for(String name : set) { - Map map = cacheMap.get(name); - if(map!=null) for(Map.Entry me : map.entrySet()) { - ++total; - if(me.getValue().timestamp.before(now)) { - map.remove(me.getKey()); - ++count; - } - } -// if(count>0) { -// env.info().log(Level.INFO, "Cache removed",count,"expired",name,"Elements"); -// } - } - - if(count>0) { - env.info().log(Level.INFO, "Cache removed",count,"expired Cached Elements out of", total); - } - - // If High (total) is reached during this period, increase the number of expired services removed for next time. - // There's no point doing it again here, as there should have been cleaned items. - if(total>high) { - // advance cleanup by 10%, without getting greater than timeInterval. - advance = Math.min(timeInterval, advance+(timeInterval/10)); - } else { - // reduce advance by 10%, without getting lower than 0. - advance = Math.max(0, advance-(timeInterval/10)); - } - } - } - - public static synchronized void startCleansing(Env env, String ... keys) { - if(cleanseTimer==null) { - cleanseTimer = new Timer("Cache Cleanup Timer"); - int cleanInterval = Integer.parseInt(env.getProperty(CACHE_CLEAN_INTERVAL,"60000")); // 1 minute clean cycles - int highCount = Integer.parseInt(env.getProperty(CACHE_HIGH_COUNT,"5000")); - cleanseTimer.schedule(clean = new Clean(env, cleanInterval, highCount), cleanInterval, cleanInterval); - } - - for(String key : keys) { - clean.add(key); - } - } - - public static void stopTimer() { - if(cleanseTimer!=null) { - cleanseTimer.cancel(); - cleanseTimer = null; - } - } - - public static void addShutdownHook() { - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - Cache.stopTimer(); - } - }); - } - -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Acceptor.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Acceptor.java deleted file mode 100644 index bfc2d372..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Acceptor.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.onap.aaf.inno.env.Trans; - -/** - * Find Acceptable Paths and place them where TypeCode can evaluate. - * - * If there are more than one, TypeCode will choose based on "q" value - * - * @param - */ -class Acceptor { - private List, List>>>> types; - List, List>>>> acceptable; - - public Acceptor(List, List>>>> types) { - this.types = types; - acceptable = new ArrayList, List>>>>(); - } - - private boolean eval(HttpCode code, String str, List props) { -// int plus = str.indexOf('+'); -// if(plus<0) { - boolean ok = false; - boolean any = false; - for(Pair, List>>> type : types) { - ok = true; - if(type.x.equals(str)) { - for(Iterator iter = props.iterator();ok && iter.hasNext();) { - ok = props(type,iter.next(),iter.next()); - } - if(ok) { - any = true; - acceptable.add(type); - } - } - } -// } else { // Handle Accepts with "+" as in application/xaml+xml -// int prev = str.indexOf('/')+1; -// String first = str.substring(0,prev); -// String nstr; -// while(prev!=0) { -// nstr = first + (plus<0?str.substring(prev):str.substring(prev,plus)); -// -// for(Pair, List>>> type : types) { -// if(type.x.equals(nstr)) { -// acceptable.add(type); -// return type; -// } -// } -// prev = plus+1; -// plus=str.indexOf('+', prev); -// }; -// } - return any; - } - - /** - * Evaluate Properties - * @param type - * @param tag - * @param value - * @return - */ - private boolean props(Pair, List>>> type, String tag, String value) { - boolean rv = false; - if(type.y!=null) { - for(Pair prop : type.y.y){ - if(tag.equals(prop.x)) { - if(tag.equals("charset")) { - return prop.x==null?false:prop.y.equals(value.toLowerCase()); // return True if Matched - } else if(tag.equals("version")) { - return prop.y.equals(new Version(value)); // Note: Version Class knows Minor Version encoding - } else if(tag.equals(Content.Q)) { // replace Q value - try { - type.y.y.get(0).y=Float.parseFloat(value); - } catch (NumberFormatException e) { - rv=false; // need to do something to make Sonar happy. But nothing to do. - } - return true; - } else { - return value.equals(prop.y); - } - } - } - } - return rv; - } - - /** - * parse - * - * Note: I'm processing by index to avoid lots of memory creation, which speeds things - * up for this time critical section of code. - * @param code - * @param cntnt - * @return - */ - protected boolean parse(HttpCode code, String cntnt) { - byte bytes[] = cntnt.getBytes(); - - int cis,cie=-1,cend; - int sis,sie,send; - String name; - ArrayList props = new ArrayList(); - do { - // Clear these in case more than one Semi - props.clear(); // on loop, do not want mixed properties - name=null; - - cis = cie+1; // find comma start - while(ciscis && Character.isSpaceChar(bytes[cend-1]))--cend; - // Start SEMIS - sie=cis-1; - do { - sis = sie+1; // semi start is one after previous end - while(siscend || sie<0?cend:sie; // if the Semicolon is after the comma, or non-existent, use comma end, else keep - while(send>sis && Character.isSpaceChar(bytes[send-1]))--send; - if(name==null) { // first entry in Comma set is the name, not a property - name = new String(bytes,sis,send-sis); - } else { // We've looped past the first Semi, now process as properties - // If there are additional elements (more entities within Semi Colons) - // apply Properties - int eq = cntnt.indexOf('=',sis); - if(eq>sis && eq=cis); // End SEMI processing - // Now evaluate Comma set and return if true - if(eval(code,name,props))return true; // else loop again to check next comma - } while(cie>=0); // loop to next comma - return false; // didn't get even one match - } - -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/CachingFileAccess.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/CachingFileAccess.java deleted file mode 100644 index 019257af..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/CachingFileAccess.java +++ /dev/null @@ -1,476 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.OutputStream; -import java.io.Writer; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.NavigableMap; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; -import java.util.TreeMap; -import java.util.concurrent.ConcurrentSkipListMap; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.att.aft.dme2.internal.jetty.http.HttpStatus; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.EnvJAXB; -import org.onap.aaf.inno.env.LogTarget; -import org.onap.aaf.inno.env.Store; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; -/* - * CachingFileAccess - * - * - */ -public class CachingFileAccess extends HttpCode { - public static void setEnv(Store store, String[] args) { - for(int i=0;i typeMap; - private final NavigableMap content; - private final Set attachOnly; - private final static String WEB_DIR_DEFAULT = "theme"; - public final static String CFA_WEB_DIR = "CFA_WebPath"; - // when to re-validate from file - // Re validating means comparing the Timestamp on the disk, and seeing it has changed. Cache is not marked - // dirty unless file has changed, but it still makes File IO, which for some kinds of cached data, i.e. - // deployed GUI elements is unnecessary, and wastes time. - // This parameter exists to cover the cases where data can be more volatile, so the user can choose how often the - // File IO will be accessed, based on probability of change. "0", of course, means, check every time. - private final static String CFA_CACHE_CHECK_INTERVAL = "CFA_CheckIntervalMS"; - private final static String CFA_MAX_SIZE = "CFA_MaxSize"; // Cache size limit - private final static String CFA_CLEAR_COMMAND = "CFA_ClearCommand"; - - // Note: can be null without a problem, but included - // to tie in with existing Logging. - public LogTarget logT = null; - public long checkInterval; // = 600000L; // only check if not hit in 10 mins by default - public int maxItemSize; // = 512000; // max file 500k - private Timer timer; - private String web_path; - // A command key is set in the Properties, preferably changed on deployment. - // it is compared at the beginning of the path, and if so, it is assumed to issue certain commands - // It's purpose is to protect, to some degree the command, even though it is HTTP, allowing - // local batch files to, for instance, clear caches on resetting of files. - private String clear_command; - - public CachingFileAccess(EnvJAXB env, String ... args) { - super(null,"Caching File Access"); - setEnv(env,args); - content = new ConcurrentSkipListMap(); // multi-thread changes possible - - attachOnly = new HashSet(); // short, unchanged - - typeMap = new TreeMap(); // Structure unchanged after Construction - typeMap.put("ico","image/icon"); - typeMap.put("html","text/html"); - typeMap.put("css","text/css"); - typeMap.put("js","text/javascript"); - typeMap.put("txt","text/plain"); - typeMap.put("xml","text/xml"); - typeMap.put("xsd","text/xml"); - attachOnly.add("xsd"); - typeMap.put("crl", "application/x-pkcs7-crl"); - typeMap.put("appcache","text/cache-manifest"); - - typeMap.put("json","text/json"); - typeMap.put("ogg", "audio/ogg"); - typeMap.put("jpg","image/jpeg"); - typeMap.put("gif","image/gif"); - typeMap.put("png","image/png"); - typeMap.put("svg","image/svg+xml"); - typeMap.put("jar","application/x-java-applet"); - typeMap.put("jnlp", "application/x-java-jnlp-file"); - typeMap.put("class", "application/java"); - - timer = new Timer("Caching Cleanup",true); - timer.schedule(new Cleanup(content,500),60000,60000); - - // Property params - web_path = env.getProperty(CFA_WEB_DIR,WEB_DIR_DEFAULT); - Object obj; - obj = env.get(env.staticSlot(CFA_CACHE_CHECK_INTERVAL),600000L); // Default is 10 mins - if(obj instanceof Long) {checkInterval=(Long)obj; - } else {checkInterval=Long.parseLong((String)obj);} - - obj = env.get(env.staticSlot(CFA_MAX_SIZE), 512000); // Default is max file 500k - if(obj instanceof Integer) {maxItemSize=(Integer)obj; - } else {maxItemSize =Integer.parseInt((String)obj);} - - clear_command = env.getProperty(CFA_CLEAR_COMMAND,null); - } - - - - @Override - public void handle(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws IOException { - String key = pathParam(req, ":key"); - if(key.equals(clear_command)) { - String cmd = pathParam(req,":cmd"); - resp.setHeader("Content-type",typeMap.get("txt")); - if("clear".equals(cmd)) { - content.clear(); - resp.setStatus(HttpStatus.OK_200); - } else { - resp.setStatus(HttpStatus.BAD_REQUEST_400); - } - return; - } - Content c = load(logT , web_path,key, null, checkInterval); - if(c.attachmentOnly) { - resp.setHeader("Content-disposition", "attachment"); - } - c.write(resp.getOutputStream()); - c.setHeader(resp); - trans.checkpoint(req.getPathInfo()); - } - - - public String webPath() { - return web_path; - } - - /** - * Reset the Cleanup size and interval - * - * The size and interval when started are 500 items (memory size unknown) checked every minute in a background thread. - * - * @param size - * @param interval - */ - public void cleanupParams(int size, long interval) { - timer.cancel(); - timer.schedule(new Cleanup(content,size), interval, interval); - } - - - - /** - * Load a file, first checking cache - * - * - * @param logTarget - logTarget can be null (won't log) - * @param dataRoot - data root storage directory - * @param key - relative File Path - * @param mediaType - what kind of file is it. If null, will check via file extension - * @param timeCheck - "-1" will take system default - Otherwise, will compare "now" + timeCheck(Millis) before looking at File mod - * @return - * @throws IOException - */ - public Content load(LogTarget logTarget, String dataRoot, String key, String mediaType, long _timeCheck) throws IOException { - long timeCheck = _timeCheck; - if(timeCheck<0) { - timeCheck=checkInterval; // if time < 0, then use default - } - String fileName = dataRoot + '/' + key; - Content c = content.get(key); - long systime = System.currentTimeMillis(); - File f=null; - if(c!=null) { - // Don't check every hit... only after certain time value - if(c.date < systime + timeCheck) { - f = new File(fileName); - if(f.lastModified()>c.date) { - c=null; - } - } - } - if(c==null) { - if(logTarget!=null) { - logTarget.log("File Read: ",key); - } - - if(f==null){ - f = new File(fileName); - } - - boolean cacheMe; - if(f.exists()) { - if(f.length() > maxItemSize) { - c = new DirectFileContent(f); - cacheMe = false; - } else { - c = new CachedContent(f); - cacheMe = checkInterval>0; - } - - if(mediaType==null) { // determine from file Ending - int idx = key.lastIndexOf('.'); - String subkey = key.substring(++idx); - if((c.contentType = idx<0?null:typeMap.get(subkey))==null) { - // if nothing else, just set to default type... - c.contentType = "application/octet-stream"; - } - c.attachmentOnly = attachOnly.contains(subkey); - } else { - c.contentType=mediaType; - c.attachmentOnly = false; - } - - c.date = f.lastModified(); - - if(cacheMe) { - content.put(key, c); - } - } else { - c=NULL; - } - } else { - if(logTarget!=null)logTarget.log("Cache Read: ",key); - } - - // refresh hit time - c.access = systime; - return c; - } - - public Content loadOrDefault(Trans trans, String targetDir, String targetFileName, String sourcePath, String mediaType) throws IOException { - try { - return load(trans.info(),targetDir,targetFileName,mediaType,0); - } catch(FileNotFoundException e) { - String targetPath = targetDir + '/' + targetFileName; - TimeTaken tt = trans.start("File doesn't exist; copy " + sourcePath + " to " + targetPath, Env.SUB); - try { - FileInputStream sourceFIS = new FileInputStream(sourcePath); - FileChannel sourceFC = sourceFIS.getChannel(); - File targetFile = new File(targetPath); - targetFile.getParentFile().mkdirs(); // ensure directory exists - FileOutputStream targetFOS = new FileOutputStream(targetFile); - try { - ByteBuffer bb = ByteBuffer.allocate((int)sourceFC.size()); - sourceFC.read(bb); - bb.flip(); // ready for reading - targetFOS.getChannel().write(bb); - } finally { - sourceFIS.close(); - targetFOS.close(); - } - } finally { - tt.done(); - } - return load(trans.info(),targetDir,targetFileName,mediaType,0); - } - } - - public void invalidate(String key) { - content.remove(key); - } - - private static final Content NULL=new Content() { - - @Override - public void setHeader(HttpServletResponse resp) { - resp.setStatus(HttpStatus.NOT_FOUND_404); - resp.setHeader("Content-type","text/plain"); - } - - @Override - public void write(Writer writer) throws IOException { - } - - @Override - public void write(OutputStream os) throws IOException { - } - - }; - - private static abstract class Content { - private long date; // date of the actual artifact (i.e. File modified date) - private long access; // last accessed - - protected String contentType; - protected boolean attachmentOnly; - - public void setHeader(HttpServletResponse resp) { - resp.setStatus(HttpStatus.OK_200); - resp.setHeader("Content-type",contentType); - resp.setHeader("Cache-Control", MAX_AGE); - } - - public abstract void write(Writer writer) throws IOException; - public abstract void write(OutputStream os) throws IOException; - - } - - private static class DirectFileContent extends Content { - private File file; - public DirectFileContent(File f) { - file = f; - } - - public String toString() { - return file.getName(); - } - - public void write(Writer writer) throws IOException { - FileReader fr = new FileReader(file); - char[] buff = new char[1024]; - try { - int read; - while((read = fr.read(buff,0,1024))>=0) { - writer.write(buff,0,read); - } - } finally { - fr.close(); - } - } - - public void write(OutputStream os) throws IOException { - FileInputStream fis = new FileInputStream(file); - byte[] buff = new byte[1024]; - try { - int read; - while((read = fis.read(buff,0,1024))>=0) { - os.write(buff,0,read); - } - } finally { - fis.close(); - } - } - - } - private static class CachedContent extends Content { - private byte[] data; - private int end; - private char[] cdata; - - public CachedContent(File f) throws IOException { - // Read and Cache - ByteBuffer bb = ByteBuffer.allocate((int)f.length()); - FileInputStream fis = new FileInputStream(f); - try { - fis.getChannel().read(bb); - } finally { - fis.close(); - } - - data = bb.array(); - end = bb.position(); - cdata=null; - } - - public String toString() { - return data.toString(); - } - - public void write(Writer writer) throws IOException { - synchronized(this) { - // do the String Transformation once, and only if actually used - if(cdata==null) { - cdata = new char[end]; - new String(data).getChars(0, end, cdata, 0); - } - } - writer.write(cdata,0,end); - } - public void write(OutputStream os) throws IOException { - os.write(data,0,end); - } - - } - - public void setEnv(LogTarget env) { - logT = env; - } - - /** - * Cleanup thread to remove older items if max Cache is reached. - * - */ - private static class Cleanup extends TimerTask { - private int maxSize; - private NavigableMap content; - - public Cleanup(NavigableMap content, int size) { - maxSize = size; - this.content = content; - } - - private class Comp implements Comparable { - public Map.Entry entry; - - public Comp(Map.Entry en) { - entry = en; - } - - @Override - public int compareTo(Comp o) { - return (int)(entry.getValue().access-o.entry.getValue().access); - } - - } - @SuppressWarnings("unchecked") - @Override - public void run() { - int size = content.size(); - if(size>maxSize) { - ArrayList scont = new ArrayList(size); - Object[] entries = content.entrySet().toArray(); - for(int i=0;i)entries[i])); - } - Collections.sort(scont); - int end = size - ((maxSize/4)*3); // reduce to 3/4 of max size - System.out.println("------ Cleanup Cycle ------ " + new Date().toString() + " -------"); - for(int i=0;i entry = scont.get(i).entry; - content.remove(entry.getKey()); - System.out.println("removed Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString()); - } - for(int i=end;i entry = scont.get(i).entry; - System.out.println("remaining Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString()); - } - } - } - } -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/CodeSetter.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/CodeSetter.java deleted file mode 100644 index b11c18ea..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/CodeSetter.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aaf.inno.env.Trans; - -// Package on purpose. only want between RServlet and Routes -class CodeSetter { - private HttpCode code; - private TRANS trans; - private HttpServletRequest req; - private HttpServletResponse resp; - public CodeSetter(TRANS trans, HttpServletRequest req, HttpServletResponse resp) { - this.trans = trans; - this.req = req; - this.resp = resp; - - } - public boolean matches(Route route) throws IOException, ServletException { - // Find best Code in Route based on "Accepts (Get) or Content-Type" (if exists) - return (code = route.getCode(trans, req, resp))!=null; - } - - public HttpCode code() { - return code; - } -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Content.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Content.java deleted file mode 100644 index 031e8bbe..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Content.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import java.util.List; - -import org.onap.aaf.inno.env.Trans; - - - -/** - * A Class to hold Service "ContentTypes", and to match incoming "Accept" types from HTTP. - * - * This is a multi-use class built to use the same Parser for ContentTypes and Accept. - * - * Thus, you would create and use "Content.Type" within your service, and use it to match - * Accept Strings. What is returned is an Integer (for faster processing), which can be - * used in a switch statement to act on match different Actions. The server should - * know which behaviors match. - * - * "bestMatch" returns an integer for the best match, or -1 if no matches. - * - * - */ -public abstract class Content { - public static final String Q = "q"; - protected abstract Pair,List>>> types(HttpCode code, String str); - protected abstract boolean props(Pair,List>>> type, String tag, String value); - - /** - * Parse a Content-Type/Accept. As found, call "types" and "props", which do different - * things depending on if it's a Content-Type or Accepts. - * - * For Content-Type, it builds a tree suitable for Comparison - * For Accepts, it compares against the tree, and builds an acceptable type list - * - * Since this parse code is used for every incoming HTTP transaction, I have removed the implementation - * that uses String.split, and replaced with integers evaluating the Byte array. This results - * in only the necessary strings created, resulting in 1/3 better speed, and less - * Garbage collection. - * - * @param trans - * @param code - * @param cntnt - * @return - */ - protected boolean parse(HttpCode code, String cntnt) { - byte bytes[] = cntnt.getBytes(); - boolean contType=false,contProp=true; - int cis,cie=-1,cend; - int sis,sie,send; - do { - cis = cie+1; - cie = cntnt.indexOf(',',cis); - cend = cie<0?bytes.length:cie; - // Start SEMIS - sie=cis-1; - Pair, List>>> me = null; - do { - sis = sie+1; - sie = cntnt.indexOf(';',sis); - send = sie>cend || sie<0?cend:sie; - if(me==null) { - String semi = new String(bytes,sis,send-sis); - // trans.checkpoint(semi); - // Look at first entity within comma group - // Is this an acceptable Type? - me=types(code, semi); - if(me==null) { - sie=-1; // skip the rest of the processing... not a type - } else { - contType=true; - } - } else { // We've looped past the first Semi, now process as properties - // If there are additional elements (more entities within Semi Colons) - // apply Propertys - int eq = cntnt.indexOf('=',sis); - if(eq>sis && eq - * @param - */ -public abstract class HttpCode { - protected CONTEXT context; - private String desc; - protected String [] roles; - private boolean all; - - // Package by design... Set by Route when linked - Match match; - - public HttpCode(CONTEXT context, String description, String ... roles) { - this.context = context; - desc = description; - - // Evaluate for "*" once... - all = false; - for(String srole : roles) { - if("*".equals(srole)) { - all = true; - break; - } - } - this.roles = all?null:roles; - } - - public abstract void handle(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws Exception; - - public String desc() { - return desc; - } - - /** - * Get the variable element out of the Path Parameter, as set by initial Code - * - * @param req - * @param key - * @return - */ - public String pathParam(HttpServletRequest req, String key) { - return match.param(req.getPathInfo(), key); - } - - // Note: get Query Params from Request - - /** - * Check for Authorization when set. - * - * If no Roles set, then accepts all users - * - * @param req - * @return - */ - public boolean isAuthorized(HttpServletRequest req) { - if(all)return true; - if(roles!=null) { - for(String srole : roles) { - if(req.isUserInRole(srole)) return true; - } - } - return false; - } - - public boolean no_cache() { - return false; - } - - public String toString() { - return desc; - } -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/HttpMethods.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/HttpMethods.java deleted file mode 100644 index 78461859..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/HttpMethods.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -public enum HttpMethods { - POST, - GET, - PUT, - DELETE -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Match.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Match.java deleted file mode 100644 index 8211024b..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Match.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * This path matching algorithm avoids using split strings during the critical transactional run-time. By pre-analyzing the - * content at "set Param" time, and storing data in an array-index model which presumably is done once and at the beginning, - * we can match in much less time when it actually counts. - * - * - */ -public class Match { - private Map params; - private byte[] values[]; - private Integer vars[]; - private boolean wildcard; - - - /* - * These two methods are pairs of searching performance for variables Spark Style. - * setParams evaluates the target path, and sets a HashMap that will return an Integer. - * the Keys are both :key and key so that there will be no string operations during - * a transaction - * - * For the Integer, if the High Order is 0, then it is just one value. If High Order >0, then it is - * a multi-field option, i.e. ending with a wild-card. - */ - public Match(String path) { - // IF DEBUG: System.out.print("\n[" + path + "]"); - params = new HashMap(); - if(path!=null) { - String[] pa = path.split("/"); - values = new byte[pa.length][]; - vars = new Integer[pa.length]; - - int val = 0; - String key; - for(int i=0;i1) { - /* remove * from value */ - int newlength = values[i].length-1; - byte[] real = new byte[newlength]; - System.arraycopy(values[i],0,real,0,newlength); - values[i]=real; - } else { - vars[i]=0; // this is actually a variable, if it only contains a "*" - } - } - // vars[i]=null; - } - } - } - } - - /* - * This is the second of the param evaluation functions. First, we look up to see if there is - * any reference by key in the params Map created by the above. - * - * The resulting Integer, if not null, is split high/low order into start and end. - * We evaluate the string for '/', rather than splitting into String[] to avoid the time/mem needed - * We traverse to the proper field number for slash, evaluate the end (whether wild card or no), - * and return the substring. - * - * The result is something less than .003 milliseconds per evaluation - * - */ - public String param(String path,String key) { - Integer val = params.get(key); // :key or key - if(val!=null) { - int start = val & 0xFFFF; - int end = (val >> 16) & 0xFFFF; - int idx = -1; - int i; - for(i=0;i0?(pabytes[0]=='/'):false; - // IF DEBUG: System.out.println("\n -- " + path + " --"); - for(int i=0;rv && i=lastField) { // checking here allows there to be a non-functional ending / - rv = false; - break; - } - if(values[field]==null) { // it's a variable, just look for /s - if(wildcard && field==lastField-1) return true;// we've made it this far. We accept all remaining characters - Integer val = vars[field]; - int start = val & 0xFFFF; - int end = (val >> 16) & 0xFFFF; - if(end==0)end=start+1; - int k = i; - for(int j=start; ji)i=k-1; // if we've incremented, have to accommodate the outer for loop incrementing as well - fieldMatched = false; // reset - fieldIdx = 0; - } else { - // IF DEBUG: System.out.print((char)pabytes[i]); - if(pabytes[i]=='/') { // end of field, eval if Field is matched - // if double slash, check if supposed to be empty - if(fieldIdx==0 && values[field].length==0) { - fieldMatched = true; - } - rv = fieldMatched && ++field getParamNames() { - return params.keySet(); - } -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Pair.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Pair.java deleted file mode 100644 index e6ed58b5..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Pair.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -/** - * A pair of generic Objects. - * - * @param - * @param - */ -public class Pair { - public X x; - public Y y; - - public Pair(X x, Y y) { - this.x = x; - this.y = y; - } - - public String toString() { - return "X: " + x.toString() + "-->" + y.toString(); - } -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/RServlet.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/RServlet.java deleted file mode 100644 index cf225394..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/RServlet.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import java.io.IOException; -import java.util.List; - -import javax.servlet.Servlet; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; - -public abstract class RServlet implements Servlet { - private Routes routes = new Routes(); - - private ServletConfig config; - - @Override - public void init(ServletConfig config) throws ServletException { - this.config = config; - } - - @Override - public ServletConfig getServletConfig() { - return config; - } - - public void route(Env env, HttpMethods meth, String path, HttpCode code, String ... moreTypes) { - Route r = routes.findOrCreate(meth,path); - r.add(code,moreTypes); - env.init().log(r.report(code),code); - } - - @Override - public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { - HttpServletRequest request = (HttpServletRequest)req; - HttpServletResponse response = (HttpServletResponse)res; - - @SuppressWarnings("unchecked") - TRANS trans = (TRANS)req.getAttribute(TransFilter.TRANS_TAG); - if(trans==null) { - response.setStatus(404); // Not Found, because it didn't go through TransFilter - return; - } - - Route route; - HttpCode code=null; - String ct = req.getContentType(); - TimeTaken tt = trans.start("Resolve to Code", Env.SUB); - try { - // routes have multiple code sets. This object picks the best code set - // based on Accept or Content-Type - CodeSetter codesetter = new CodeSetter(trans,request,response); - // Find declared route - route = routes.derive(request, codesetter); - if(route==null) { - String method = request.getMethod(); - trans.checkpoint("No Route matches "+ method + ' ' + request.getPathInfo()); - response.setStatus(404); // Not Found - } else { - // Find best Code in Route based on "Accepts (Get) or Content-Type" (if exists) - code = codesetter.code();// route.getCode(trans, request, response); - } - } finally { - tt.done(); - } - - if(route!=null && code!=null) { - StringBuilder sb = new StringBuilder(72); - sb.append(route.auditText); - sb.append(','); - sb.append(code.desc()); - if(ct!=null) { - sb.append(", ContentType: "); - sb.append(ct); - } - tt = trans.start(sb.toString(),Env.SUB); - try { - /*obj = */ - code.handle(trans, request, response); - response.flushBuffer(); - } catch (ServletException e) { - trans.error().log(e); - throw e; - } catch (Exception e) { - trans.error().log(e,request.getMethod(),request.getPathInfo()); - throw new ServletException(e); - } finally { - tt.done(); - } - } - } - - @Override - public String getServletInfo() { - return "RServlet for Jetty"; - } - - @Override - public void destroy() { - } - - public String applicationJSON(Class cls, String version) { - StringBuilder sb = new StringBuilder(); - sb.append("application/"); - sb.append(cls.getSimpleName()); - sb.append("+json"); - sb.append(";charset=utf-8"); - sb.append(";version="); - sb.append(version); - return sb.toString(); - } - - public String applicationXML(Class cls, String version) { - StringBuilder sb = new StringBuilder(); - sb.append("application/"); - sb.append(cls.getSimpleName()); - sb.append("+xml"); - sb.append(";charset=utf-8"); - sb.append(";version="); - sb.append(version); - return sb.toString(); - } - - public List routeReport() { - return routes.routeReport(); - } -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Route.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Route.java deleted file mode 100644 index 9d9253d9..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Route.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import java.io.IOException; -import java.util.List; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; - -public class Route { - public final String auditText; - public final HttpMethods meth; - public final String path; - - private Match match; - // package on purpose - private final TypedCode content; - private final boolean isGet; - - public Route(HttpMethods meth, String path) { - this.path = path; - auditText = meth.name() + ' ' + path; - this.meth = meth; // Note: Using Spark def for now. - isGet = meth.compareTo(HttpMethods.GET) == 0; - match = new Match(path); - content = new TypedCode(); - } - - public void add(HttpCode code, String ... others) { - code.match = match; - content.add(code, others); - } - -// public void add(HttpCode code, Class cls, String version, String ... others) { -// code.match = match; -// content.add(code, cls, version, others); -// } -// - public HttpCode getCode(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { - // Type is associated with Accept for GET (since it is what is being returned - // We associate the rest with ContentType. - // FYI, thought about this a long time before implementing this way. - String compare; -// String special[]; // todo, expose Charset (in special) to outside - if(isGet) { - compare = req.getHeader("Accept"); // Accept is used for read, as we want to agree on what caller is ready to handle - } else { - compare = req.getContentType(); // Content type used to declare what data is being created, updated or deleted (might be used for key) - } - - Pair, List>>> hl = content.prep(trans, compare); - if(hl==null) { - resp.setStatus(406); // NOT_ACCEPTABLE - } else { - if(isGet) { // Set Content Type to expected content - if("*".equals(hl.x) || "*/*".equals(hl.x)) {// if wild-card, then choose first kind of type - resp.setContentType(content.first()); - } else { - resp.setContentType(hl.x); - } - } - return hl.y.x; - } - return null; - } - - public Route matches(String method, String path) { - return meth.name().equalsIgnoreCase(method) && match.match(path)?this:null; - } - - public TimeTaken start(Trans trans, String auditText, HttpCode code, String type) { - StringBuilder sb = new StringBuilder(auditText); - sb.append(", "); - sb.append(code.desc()); - sb.append(", Content: "); - sb.append(type); - return trans.start(sb.toString(), Env.SUB); - } - - // Package on purpose.. for "find/Create" routes only - boolean resolvesTo(HttpMethods hm, String p) { - return(path.equals(p) && hm.equals(meth)); - } - - public String toString() { - return auditText + ' ' + content; - } - - public String report(HttpCode code) { - StringBuilder sb = new StringBuilder(); - sb.append(auditText); - sb.append(' '); - content.relatedTo(code, sb); - return sb.toString(); - } - - public RouteReport api() { - RouteReport tr = new RouteReport(); - tr.meth = meth; - tr.path = path; - content.api(tr); - return tr; - } - - - /** - * contentRelatedTo (For reporting) list routes that will end up at a specific Code - * @return - */ - public String contentRelatedTo(HttpCode code) { - StringBuilder sb = new StringBuilder(path); - sb.append(' '); - content.relatedTo(code, sb); - return sb.toString(); - } -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/RouteReport.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/RouteReport.java deleted file mode 100644 index 8e134f11..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/RouteReport.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import java.util.ArrayList; -import java.util.List; - -public class RouteReport { - public HttpMethods meth; - public String path; - public String desc; - public final List contextTypes = new ArrayList(); - -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Routes.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Routes.java deleted file mode 100644 index 60f00395..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Routes.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; - -import org.onap.aaf.inno.env.Trans; - - -public class Routes { - // Since this must be very, very fast, and only needs one creation, we'll use just an array. - private Route[] routes; - private int end; - - - @SuppressWarnings("unchecked") - public Routes() { - routes = new Route[10]; - end = 0; - } - - // This method for setup of Routes only... - // Package on purpose - synchronized Route findOrCreate(HttpMethods meth, String path) { - Route rv = null; - for(int i=0;i=routes.length) { - @SuppressWarnings("unchecked") - Route[] temp = new Route[end+10]; - System.arraycopy(routes, 0, temp, 0, routes.length); - routes = temp; - } - - routes[end++]=rv=new Route(meth,path); - } - return rv; - } - - public Route derive(HttpServletRequest req, CodeSetter codeSetter) throws IOException, ServletException { - Route rv = null; - String path = req.getPathInfo(); - String meth = req.getMethod(); - //TODO a TREE would be better - for(int i=0;rv==null && i routeReport() { - ArrayList ltr = new ArrayList(); - for(int i=0;i implements Filter { - public static final String TRANS_TAG = "__TRANS__"; - - private CadiHTTPManip cadi; - - public TransFilter(Access access, Connector con, TrustChecker tc, Object ... additionalTafLurs) throws CadiException { - cadi = new CadiHTTPManip(access, con, tc, additionalTafLurs); - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } - - protected Lur getLur() { - return cadi.getLur(); - } - - protected abstract TRANS newTrans(); - protected abstract TimeTaken start(TRANS trans, ServletRequest request); - protected abstract void authenticated(TRANS trans, Principal p); - protected abstract void tallyHo(TRANS trans); - - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - TRANS trans = newTrans(); - - TimeTaken overall = start(trans,request); - try { - request.setAttribute(TRANS_TAG, trans); - - HttpServletRequest req = (HttpServletRequest)request; - HttpServletResponse res = (HttpServletResponse)response; - - TimeTaken security = trans.start("CADI Security", Env.SUB); -// TimeTaken ttvalid; - TafResp resp; - RESP r; - CadiWrap cw = null; - try { - resp = cadi.validate(req,res); - switch(r=resp.isAuthenticated()) { - case IS_AUTHENTICATED: - cw = new CadiWrap(req,resp,cadi.getLur()); - authenticated(trans, cw.getUserPrincipal()); - break; - default: - break; - } - } finally { - security.done(); - } - - if(r==RESP.IS_AUTHENTICATED) { - trans.checkpoint(resp.desc()); - chain.doFilter(cw, response); - } else { - //TODO this is a good place to check if too many checks recently - // Would need Cached Counter objects that are cleaned up on - // use - trans.checkpoint(resp.desc(),Env.ALWAYS); - if(resp.isFailedAttempt()) - trans.audit().log(resp.desc()); - } - } catch(Exception e) { - trans.error().log(e); - trans.checkpoint("Error: " + e.getClass().getSimpleName() + ": " + e.getMessage()); - throw new ServletException(e); - } finally { - overall.done(); - tallyHo(trans); - } - } - - @Override - public void destroy() { - }; -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/TransOnlyFilter.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/TransOnlyFilter.java deleted file mode 100644 index 93599b2e..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/TransOnlyFilter.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import java.io.IOException; -import java.security.Principal; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; - -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.TransStore; - -/** - * Create a new Transaction Object for each and every incoming Transaction - * - * Attach to Request. User "FilterHolder" mechanism to retain single instance. - * - * TransFilter includes CADIFilter as part of the package, so that it can - * set User Data, etc, as necessary. - * - * - */ -public abstract class TransOnlyFilter implements Filter { - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } - - - - protected abstract TRANS newTrans(); - protected abstract TimeTaken start(TRANS trans, ServletRequest request); - protected abstract void authenticated(TRANS trans, Principal p); - protected abstract void tallyHo(TRANS trans); - - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - TRANS trans = newTrans(); - - TimeTaken overall = start(trans,request); - try { - request.setAttribute(TransFilter.TRANS_TAG, trans); - chain.doFilter(request, response); - } finally { - overall.done(); - } - tallyHo(trans); - } - - @Override - public void destroy() { - }; -} diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/TypedCode.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/TypedCode.java deleted file mode 100644 index e1aaf1d6..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/TypedCode.java +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import javax.servlet.ServletException; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; - - -/** - * TypedCode organizes implementation code based on the Type and Version of code it works with so that it can - * be located quickly at runtime based on the "Accept" HTTP Header. - * - * FYI: For those in the future wondering why I would create a specialized set of "Pair" for the data content: - * 1) TypeCode is used in Route, and this code is used for every transaction... it needs to be blazingly fast - * 2) The actual number of objects accessed is quite small and built at startup. Arrays are best - * 3) I needed a small, well defined tree where each level is a different Type. Using a "Pair" Generic definitions, - * I created type-safety at each level, which you can't get from a TreeSet, etc. - * 4) Chaining through the Network is simply object dereferencing, which is as fast as Java can go. - * 5) The drawback is that in your code is that all the variables are named "x" and "y", which can be a bit hard to - * read both in code, and in the debugger. However, TypeSafety allows your IDE (Eclipse) to help you make the - * choices. Also, make sure you have a good "toString()" method on each object so you can see what's happening - * in the IDE Debugger. - * - * Empirically, this method of obtaining routes proved to be much faster than the HashSet implementations available in otherwise - * competent Open Source. - * - * @param - */ -public class TypedCode extends Content { - private List,List>>>> types; - - public TypedCode() { - types = new ArrayList,List>>>>(); - } - - /** - * Construct Typed Code based on ContentType parameters passed in - * - * @param code - * @param others - * @return - */ - public TypedCode add(HttpCode code, String ... others) { - StringBuilder sb = new StringBuilder(); - boolean first = true; - for(String str : others) { - if(first) { - first = false; - } else { - sb.append(','); - } - sb.append(str); - } - parse(code, sb.toString()); - - return this; - } - - @Override - protected Pair, List>>> types(HttpCode code, String str) { - Pair,List>>> type = null; - ArrayList> props = new ArrayList>(); - // Want Q percentage is to be first in the array everytime. If not listed, 1.0 is default - props.add(new Pair(Q,1f)); - Pair, List>> cl = new Pair, List>>(code, props); -// // breakup "plus" stuff, i.e. application/xaml+xml -// int plus = str.indexOf('+'); -// if(plus<0) { - type = new Pair,List>>>(str, cl); - types.add(type); - return type; -// } else { -// int prev = str.indexOf('/')+1; -// String first = str.substring(0,prev); -// String nstr; -// while(prev!=0) { -// nstr = first + (plus>-1?str.substring(prev,plus):str.substring(prev)); -// type = new Pair,List>>>(nstr, cl); -// types.add(type); -// prev = plus+1; -// plus = str.indexOf('+',prev); -// } -// return type; -// } - } - - @Override - protected boolean props(Pair, List>>> type, String tag, String value) { - if(tag.equals(Q)) { // reset the Q value (first in array) - boolean rv = true; - try { - type.y.y.get(0).y=Float.parseFloat(value); - return rv; - } catch (NumberFormatException e) { - rv=false; // Note: this awkward syntax forced by Sonar, which doesn't like doing nothing with Exception - // which is what should happen - } - } - return type.y.y.add(new Pair(tag,"version".equals(tag)?new Version(value):value)); - } - - public Pair, List>>> prep(TRANS trans, String compare) throws IOException, ServletException { - Pair, List>>> c,rv=null; - if(types.size()==1 && "".equals((c=types.get(0)).x)) { // if there are no checks for type, skip - rv = c; - } else { - if(compare==null || compare.length()==0) { - rv = types.get(0); // first code is used - } else { - Acceptor acc = new Acceptor(types); - boolean accepted; - TimeTaken tt = trans.start(compare, Env.SUB); - try { - accepted = acc.parse(null, compare); - } finally { - tt.done(); - } - if(accepted) { - switch(acc.acceptable.size()) { - case 0: -// // TODO best Status Code? -// resp.setStatus(HttpStatus.NOT_ACCEPTABLE_406); - break; - case 1: - rv = acc.acceptable.get(0); - break; - default: // compare Q values to get Best Match - float bestQ = -1.0f; - Pair, List>>> bestT = null; - for(Pair, List>>> type : acc.acceptable) { - Float f = (Float)type.y.y.get(0).y; // first property is always Q - if(f>bestQ) { - bestQ=f; - bestT = type; - } - } - if(bestT!=null) { - // When it is a GET, the matched type is what is returned, so set ContentType -// if(isGet)resp.setContentType(bestT.x); // set ContentType of Code -// rv = bestT.y.x; - rv = bestT; - } - } - } else { - trans.checkpoint("No Match found for Accept"); - } - } - } - return rv; - } - - /** - * Print on String Builder content related to specific Code - * - * This is for Reporting and Debugging purposes, so the content is not cached. - * - * If code is "null", then all content is matched - * - * @param code - * @return - */ - public StringBuilder relatedTo(HttpCode code, StringBuilder sb) { - boolean first = true; - for(Pair, List>>> pair : types) { - if(code==null || pair.y.x == code) { - if(first) { - first = false; - } else { - sb.append(','); - } - sb.append(pair.x); - for(Pair prop : pair.y.y) { - // Don't print "Q". it's there for internal use, but it is only meaningful for "Accepts" - if(!prop.x.equals(Q) || !prop.y.equals(1f) ) { - sb.append(';'); - sb.append(prop.x); - sb.append('='); - sb.append(prop.y); - } - } - } - } - return sb; - } - - public List> getContent(HttpCode code) { - for(Pair, List>>> pair : types) { - if(pair.y.x == code) { - return pair.y.y; - } - } - return null; - } - - public String toString() { - return relatedTo(null,new StringBuilder()).toString(); - } - - public void api(RouteReport tr) { - // Need to build up a map, because Prop entries can be in several places. - HashMap,StringBuilder> psb = new HashMap,StringBuilder>(); - StringBuilder temp; - tr.desc = null; - - // Read through Code/TypeCode trees for all accepted Typecodes - for(Pair, List>>> tc : types) { - // If new, then it's new Code set, create prefix content - if((temp=psb.get(tc.y.x))==null) { - psb.put(tc.y.x,temp=new StringBuilder()); - if(tr.desc==null) { - tr.desc = tc.y.x.desc(); - } - } else { - temp.append(','); - } - temp.append(tc.x); - - // add all properties - for(Pair props : tc.y.y) { - temp.append(';'); - temp.append(props.x); - temp.append('='); - temp.append(props.y); - } - } - // Gather all ContentType possibilities for the same code together - - for(StringBuilder sb : psb.values()) { - tr.contextTypes.add(sb.toString()); - } - } - - public String first() { - if(types.size()>0) { - return types.get(0).x; - } - return null; - } - - } diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Version.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Version.java deleted file mode 100644 index ff02cef9..00000000 --- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/Version.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - - -/** - * Analyze and hold Version information for Code - * - * - */ -public class Version { - private Object[] parts; - - public Version(String v) { - String sparts[] = v.split("\\."); - parts = new Object[sparts.length]; - System.arraycopy(sparts, 0, parts, 0, sparts.length); - if(parts.length>1) { // has at least a minor - try { - parts[1]=Integer.decode(sparts[1]); // minor elements need to be converted to Integer for comparison - } catch (NumberFormatException e) { - // it's ok, leave it as a string - parts[1]=sparts[1]; // This useless piece of code forced by Sonar which calls empty Exceptions "Blockers". - } - } - } - - public boolean equals(Object obj) { - if(obj instanceof Version) { - Version ver = (Version)obj; - int length = Math.min(parts.length, ver.parts.length); - for(int i=0;i list = new ArrayList(); - try { - df.open(); - Token tok = df.new Token(1024000); - Field fld = tok.new Field('|'); - - while(tok.nextLine()) { - ++count; - fld.reset(); - list.add(fld.at(0)); - } -// Collections.sort(list); - for(String s: list) { - System.out.println(s); - - } - } finally { - System.out.printf("%15s:%12d\n","Total",count); - } - } - -} diff --git a/authz-core/src/test/java/org/onap/aaf/authz/local/JU_TextIndex.java b/authz-core/src/test/java/org/onap/aaf/authz/local/JU_TextIndex.java deleted file mode 100644 index d8e5c62d..00000000 --- a/authz-core/src/test/java/org/onap/aaf/authz/local/JU_TextIndex.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.local; - -import static org.junit.Assert.*; - -import java.io.File; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aaf.authz.local.TextIndex; - -@RunWith(MockitoJUnitRunner.class) -public class JU_TextIndex { - TextIndex textIndex; - @Mock - File file; - - @Before - public void setUp(){ - textIndex = new TextIndex(file); - } - - @Test - public void test() { - assertTrue(true); - } - -} diff --git a/authz-core/src/test/java/org/onap/aaf/authz/org/JU_OrganizationException.java b/authz-core/src/test/java/org/onap/aaf/authz/org/JU_OrganizationException.java deleted file mode 100644 index 17a76d11..00000000 --- a/authz-core/src/test/java/org/onap/aaf/authz/org/JU_OrganizationException.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.org; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.aaf.authz.org.OrganizationException; -import org.powermock.modules.junit4.PowerMockRunner; - -@RunWith(PowerMockRunner.class) -public class JU_OrganizationException { - - OrganizationException organizationException; - - @Before - public void setUp(){ - organizationException = new OrganizationException(); - } - - - @Test - public void test() { - assertTrue(true); - } - -} diff --git a/authz-core/src/test/java/org/onap/aaf/authz/org/JU_OrganizationFactory.java b/authz-core/src/test/java/org/onap/aaf/authz/org/JU_OrganizationFactory.java deleted file mode 100644 index ecdc35b1..00000000 --- a/authz-core/src/test/java/org/onap/aaf/authz/org/JU_OrganizationFactory.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.authz.org; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.authz.org.OrganizationException; -import org.onap.aaf.authz.org.OrganizationFactory; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.modules.junit4.PowerMockRunner; - -import org.onap.aaf.inno.env.APIException; - -@RunWith(PowerMockRunner.class) -public class JU_OrganizationFactory { - private static final String ORG_SLOT = null; - OrganizationFactory organizationFactory; - @Mock - AuthzEnv authzEnvMock; - String orgClass="orgclass"; - String orgNS="orgns"; - @Before - public void setUp(){ - organizationFactory = new OrganizationFactory(); - } - - @SuppressWarnings("static-access") - @Test(expected = APIException.class) - public void testSetDefaultOrg() throws APIException { - //PowerMockito.when(authzEnvMock.slot(ORG_SLOT)).thenReturn("ORG_SLOT"); - organizationFactory.setDefaultOrg(authzEnvMock, orgClass); - } - - @SuppressWarnings("static-access") - @Test(expected = OrganizationException.class) - public void testObtain() throws OrganizationException{ - PowerMockito.when(authzEnvMock.getProperty("Organization."+orgNS)).thenReturn("notnull"); - organizationFactory.obtain(authzEnvMock, orgNS); - } -} diff --git a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_CachingFileAccess.java b/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_CachingFileAccess.java deleted file mode 100644 index 4248b7cc..00000000 --- a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_CachingFileAccess.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.aaf.cssa.rserv.CachingFileAccess; -import org.powermock.modules.junit4.PowerMockRunner; - - -@RunWith(PowerMockRunner.class) -public class JU_CachingFileAccess { - CachingFileAccess cachingFileAccess; - - - @Before - public void setUp(){ - cachingFileAccess = new CachingFileAccess(null, null); - - } - - @Test - public void test() { - assertTrue(true); - } - -} diff --git a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_CodeSetter.java b/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_CodeSetter.java deleted file mode 100644 index 04fdbd04..00000000 --- a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_CodeSetter.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import static org.junit.Assert.*; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.onap.aaf.cssa.rserv.CodeSetter; -import org.onap.aaf.cssa.rserv.Route; -import org.powermock.modules.junit4.PowerMockRunner; - -import org.onap.aaf.inno.env.Trans; - -@RunWith(PowerMockRunner.class) -public class JU_CodeSetter { - CodeSetter codeSetter; - @Mock - Trans transMock; - @Mock - HttpServletRequest reqMock; - @Mock - HttpServletResponse respMock; - - @Before - public void setUp(){ - codeSetter = new CodeSetter(transMock, reqMock, respMock); - } - - @SuppressWarnings("rawtypes") - @Mock - Route routeMock; - - @Test - public void testMatches() throws IOException, ServletException{ - boolean result = codeSetter.matches(routeMock); - System.out.println("value of res " + codeSetter.matches(routeMock)); - assertFalse(result); - } - -} diff --git a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Pair.java b/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Pair.java deleted file mode 100644 index 1723401e..00000000 --- a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Pair.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; -import org.onap.aaf.cssa.rserv.Pair; - -public class JU_Pair { - Pair pair; - Object x; - Object y; - - @Before - public void setUp(){ - pair = new Pair(x, y); - } - - @Test - public void test() { - assertTrue(true); - } - -} diff --git a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Routes.java b/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Routes.java deleted file mode 100644 index 2942e55e..00000000 --- a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Routes.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import static org.junit.Assert.*; - -import java.io.IOException; -import java.util.List; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.onap.aaf.cssa.rserv.CodeSetter; -import org.onap.aaf.cssa.rserv.Route; -import org.onap.aaf.cssa.rserv.Routes; -import org.powermock.modules.junit4.PowerMockRunner; - -import org.onap.aaf.inno.env.Trans; - -@RunWith(PowerMockRunner.class) -public class JU_Routes { - Routes routes; - @Mock - HttpServletRequest reqMock; - CodeSetter codeSetterMock; - Route routeObj; - - @Before - public void setUp(){ - routes = new Routes(); - } - - @Test - public void testRouteReport(){ - List listVal = routes.routeReport(); - System.out.println("value of Listval " +listVal); - assertNotNull(listVal); - - } - - @Test - public void testDerive() throws IOException, ServletException{ - routeObj = routes.derive(reqMock, codeSetterMock); - System.out.println("value of routeObj" +routeObj); - } - - -} diff --git a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_TypedCode.java b/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_TypedCode.java deleted file mode 100644 index b7e1ae82..00000000 --- a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_TypedCode.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.onap.aaf.cssa.rserv.RouteReport; -import org.onap.aaf.cssa.rserv.TypedCode; -import org.powermock.modules.junit4.PowerMockRunner; - -@RunWith(PowerMockRunner.class) -public class JU_TypedCode { - TypedCode typedCode; - @Mock - RouteReport routeReportMock; - - @Before - public void setUp(){ - typedCode = new TypedCode(); - } - - @Test - public void testFirst(){ - String returnVal = typedCode.first(); - assertNull(returnVal); - } - - -} diff --git a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Version.java b/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Version.java deleted file mode 100644 index c97c5a70..00000000 --- a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Version.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.onap.aaf.cssa.rserv.Version; -import org.powermock.modules.junit4.PowerMockRunner; - -@RunWith(PowerMockRunner.class) -public class JU_Version { - Version version; - - - @Before - public void setUp(){ - version = new Version("String"); - } - - @Test - public void testEquals(){ - boolean val = version.equals(version); - System.out.println("value of val " +val); - assertTrue(val); - } - - @Test - public void testToString(){ - String strVal = version.toString(); - System.out.println("value of strVal " +strVal); - assertNotNull(strVal); - } -} diff --git a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/test/JU_BetterMatch.java b/authz-core/src/test/java/org/onap/aaf/cssa/rserv/test/JU_BetterMatch.java deleted file mode 100644 index 0e2e834b..00000000 --- a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/test/JU_BetterMatch.java +++ /dev/null @@ -1,166 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv.test; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; - -import org.junit.Test; -import org.onap.aaf.cssa.rserv.Match; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; -import org.onap.aaf.inno.env.impl.EnvFactory; - - -public class JU_BetterMatch { - - @Test - public void test() { - Trans trans = EnvFactory.newTrans(); - // Bad Match - Match bm = new Match("/req/1.0.0/:var"); - - assertTrue(bm.match("/req/1.0.0/fred")); - assertTrue(bm.match("/req/1.0.0/wilma")); - assertTrue(bm.match("/req/1.0.0/wilma/")); - assertFalse(bm.match("/req/1.0.0/wilma/bambam")); - assertFalse(bm.match("/not/valid/234")); - assertFalse(bm.match("")); - - TimeTaken tt = trans.start("A", Env.SUB); - TimeTaken tt2; - int i = 0; - try { - bm = new Match(null); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertTrue(bm.match("")); - tt2.done(); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertTrue(bm.match(null)); - tt2.done(); - } finally { - tt.done(); - } - - - tt = trans.start("B", Env.SUB); - i = 0; - try { - bm = new Match("/req/1.0.0/:urn/:ref"); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345")); - tt2.done(); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertFalse(bm.match("/req/1.0.0/urn")); - tt2.done(); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/")); - tt2.done(); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/x")); - tt2.done(); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/xyx")); - } finally { - tt2.done(); - tt.done(); - } - - tt = trans.start("C", Env.SUB); - i = 0; - try { - String url = "/req/1.0.0/"; - bm = new Match(url+":urn*"); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - String value = "urn:fsdb,1.0,req,newreq/0x12345"; - - assertTrue(bm.match(url+value)); - assertEquals("urn:fsdb,1.0,req,newreq/0x12345",bm.param(url+value, ":urn")); - } finally { - tt2.done(); - tt.done(); - } - - tt = trans.start("D", Env.SUB); - i = 0; - try { - bm = new Match("/req/1.0.0/:urn/:ref*"); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345")); - tt2.done(); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/")); - } finally { - tt2.done(); - tt.done(); - } - - tt = trans.start("E", Env.SUB); - i = 0; - try { - bm = new Match("this*"); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertTrue(bm.match("this")); - tt2.done(); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertTrue(bm.match("thisandthat")); - tt2.done(); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertTrue(bm.match("this/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/")); - } finally { - tt2.done(); - tt.done(); - } - - tt = trans.start("F", Env.SUB); - i = 0; - try { - bm = new Match("*"); - tt2 = trans.start(Integer.toString(++i), Env.SUB); - assertTrue(bm.match("/this")); - } finally { - tt2.done(); - tt.done(); - } - - StringBuilder sb = new StringBuilder(); - trans.auditTrail(0, sb); - System.out.println(sb); - - } - - @Test - public void specialTest() { - Match match = new Match("/sample"); - assertTrue(match.match("/sample")); - - match = new Match("/lpeer//lpeer/:key/:item*"); - assertTrue(match.match("/lpeer//lpeer/x/y")); - assertFalse(match.match("/lpeer/x/lpeer/x/y")); - - } - -} diff --git a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/test/JU_Content.java b/authz-core/src/test/java/org/onap/aaf/cssa/rserv/test/JU_Content.java deleted file mode 100644 index 4fba0a33..00000000 --- a/authz-core/src/test/java/org/onap/aaf/cssa/rserv/test/JU_Content.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cssa.rserv.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.io.IOException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.junit.Test; -import org.onap.aaf.cssa.rserv.HttpCode; -import org.onap.aaf.cssa.rserv.TypedCode; - -import org.onap.aaf.inno.env.TransJAXB; -import org.onap.aaf.inno.env.impl.EnvFactory; - - -/** - * Test the functioning of the "Content" class, which holds, and routes to the right code based on Accept values - */ -public class JU_Content { - - - @Test - public void test() throws Exception { - final String BOOL = "Boolean"; - final String XML = "XML"; - TransJAXB trans = EnvFactory.newTrans(); - try { - HttpCode cBool = new HttpCode(BOOL,"Standard String") { - @Override - public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) { - try { - resp.getOutputStream().write(context.getBytes()); - } catch (IOException e) { - } - } - }; - - HttpCode cXML = new HttpCode(XML, "Standard String") { - @Override - public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) { - try { - resp.getOutputStream().write(context.getBytes()); - } catch (IOException e) { - } - } - }; - - TypedCode ct = new TypedCode() - .add(cBool,"application/" + Boolean.class.getName()+"+xml;charset=utf8;version=1.1") - .add(cXML,"application/xml;q=.9"); - String expected = "application/java.lang.Boolean+xml;charset=utf8;version=1.1,application/xml;q=0.9"; - assertEquals(expected,ct.toString()); - - //BogusReq req = new BogusReq(); - //expected = (expected); - //HttpServletResponse resp = new BogusResp(); - - assertNotNull("Same Content String and Accept String",ct.prep(trans,expected)); - - //expects Null (not run) - // A Boolean xml that must have charset utf8 and match version 1.2 or greater - expected = ("application/java.lang.Boolean+xml;charset=utf8;version=1.2"); - assertNull("Accept Minor Version greater than Content Minor Version",ct.prep(trans,expected)); - - // Same with (too many) spaces - expected = (" application/java.lang.Boolean+xml ; charset = utf8 ; version = 1.2 "); - assertNull("Accept Minor Version greater than Content Minor Version",ct.prep(trans,expected)); - - //expects Null (not run) - expected = ("application/java.lang.Boolean+xml;charset=utf8;version=2.1"); - assertNull("Major Versions not the same",ct.prep(trans,expected)); - - expected = ("application/java.lang.Boolean+xml;charset=utf8;version=1.0"); - assertNotNull("Content Minor Version is greater than Accept Minor Version",ct.prep(trans,expected)); - - expected = "application/java.lang.Squid+xml;charset=utf8;version=1.0,application/xml;q=.9"; - assertNotNull("2nd one will have to do...",ct.prep(trans,expected)); - - expected = "application/java.lang.Boolean+xml;charset=UTF8;version=1.0"; - assertNotNull("Minor Charset in Caps acceptable",ct.prep(trans,expected)); - - // expects no run - expected="application/java.lang.Boolean+xml;charset=MyType;version=1.0"; - assertNull("Unknown Minor Charset",ct.prep(trans,expected)); - - expected=""; - assertNotNull("Blank Acceptance",ct.prep(trans,expected)); - - expected=null; - assertNotNull("Null Acceptance",ct.prep(trans,expected)); - - expected = ("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); - assertNotNull("Matches application/xml, and other content not known",ct.prep(trans,expected)); - - // No SemiColon - expected = ("i/am/bogus,application/xml"); - assertNotNull("Match second entry, with no Semis",ct.prep(trans,expected)); - - } finally { - StringBuilder sb = new StringBuilder(); - trans.auditTrail(0, sb); - System.out.println(sb); - } - } - -} diff --git a/authz-defOrg/pom.xml b/authz-defOrg/pom.xml deleted file mode 100644 index 3153db85..00000000 --- a/authz-defOrg/pom.xml +++ /dev/null @@ -1,207 +0,0 @@ - - - - 4.0.0 - - org.onap.aaf.authz - parent - 1.0.1-SNAPSHOT - ../pom.xml - - - authz-defOrg - Default Organization - Example Organization Module - jar - https://github.com/att/AAF - - - - Jonathan Gathman - - ATT - - - - - - false - 0 - 1.0.0-SNAPSHOT - 1.0.0-SNAPSHOT - - 0.7.7.201606060606 - true - 3.2 - jacoco - - target/code-coverage/jacoco-ut.exec - target/code-coverage/jacoco-it.exec - - **/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/** - https://nexus.onap.org - /content/repositories/snapshots/ - /content/repositories/releases/ - /content/repositories/staging/ - /content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version} - - - - - - org.onap.aaf.cadi - cadi-core - ${project.cadiVersion} - - - - org.onap.aaf.authz - authz-core - ${project.version} - - - - javax.mail - mail - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.4 - - false - - - - attach-javadocs - - jar - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ${nexusproxy} - 176c31dfe190a - ecomp-staging - - - - org.jacoco - jacoco-maven-plugin - ${jacoco.version} - - - **/gen/** - **/generated-sources/** - **/yang-gen/** - **/pax/** - - - - - - pre-unit-test - - prepare-agent - - - ${project.build.directory}/code-coverage/jacoco-ut.exec - surefireArgLine - - - - - - post-unit-test - test - - report - - - ${project.build.directory}/code-coverage/jacoco-ut.exec - ${project.reporting.outputDirectory}/jacoco-ut - - - - pre-integration-test - pre-integration-test - - prepare-agent - - - ${project.build.directory}/code-coverage/jacoco-it.exec - - failsafeArgLine - - - - - - post-integration-test - post-integration-test - - report - - - ${project.build.directory}/code-coverage/jacoco-it.exec - ${project.reporting.outputDirectory}/jacoco-it - - - - - - - - - - - ecomp-releases - AAF Release Repository - ${nexusproxy}${releaseNexusPath} - - - ecomp-snapshots - AAF Snapshot Repository - ${nexusproxy}${snapshotNexusPath} - - - ecomp-site - dav:${nexusproxy}${sitePath} - - - - - diff --git a/authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrg.java b/authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrg.java deleted file mode 100644 index 0352a1ac..00000000 --- a/authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrg.java +++ /dev/null @@ -1,596 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.osaaf.defOrg; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.mail.Address; -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; - -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.org.EmailWarnings; -import org.onap.aaf.authz.org.Executor; -import org.onap.aaf.authz.org.Organization; -import org.onap.aaf.authz.org.OrganizationException; -import org.onap.aaf.osaaf.defOrg.Identities.Data; - -public class DefaultOrg implements Organization { - private static final String PROPERTY_IS_REQUIRED = " property is Required"; - private static final String DOMAIN = "osaaf.com"; - private static final String REALM = "com.osaaf"; - private static final String NAME = "Default Organization"; - private static final String NO_PASS = NAME + " does not support Passwords. Use AAF"; - private final String mailHost,mailFromUserId,supportAddress; - private String SUFFIX; - // Possible ID Pattern - private static final String ID_PATTERN = "a-z[a-z0-9]{5-8}@.*"; - - public DefaultOrg(AuthzEnv env) throws OrganizationException { - String s; - mailHost = env.getProperty(s=(REALM + ".mailHost"), null); - if(mailHost==null) { - throw new OrganizationException(s + PROPERTY_IS_REQUIRED); - } - supportAddress = env.getProperty(s=(REALM + ".supportEmail"), null); - if(supportAddress==null) { - throw new OrganizationException(s + PROPERTY_IS_REQUIRED); - } - - String temp = env.getProperty(s=(REALM + ".mailFromUserId"), null); - mailFromUserId = temp==null?supportAddress:temp; - - System.getProperties().setProperty("mail.smtp.host",mailHost); - System.getProperties().setProperty("mail.user", mailFromUserId); - // Get the default Session object. - session = Session.getDefaultInstance(System.getProperties()); - - SUFFIX='.'+getDomain(); - - try { - String defFile; - temp=env.getProperty(defFile = (getClass().getName()+".file")); - File fIdentities=null; - if(temp==null) { - temp = env.getProperty("aaf_data_dir"); - if(temp!=null) { - env.warn().log(defFile, "is not defined. Using default: ",temp+"/identities.dat"); - File dir = new File(temp); - fIdentities=new File(dir,"identities.dat"); - if(!fIdentities.exists()) { - env.warn().log("No",fIdentities.getCanonicalPath(),"exists. Creating."); - if(!dir.exists()) { - dir.mkdirs(); - } - fIdentities.createNewFile(); - } - } - } else { - fIdentities = new File(temp); - if(!fIdentities.exists()) { - String dataDir = env.getProperty("aaf_data_dir"); - if(dataDir!=null) { - fIdentities = new File(dataDir,temp); - } - } - } - - if(fIdentities!=null && fIdentities.exists()) { - identities = new Identities(fIdentities); - } else { - throw new OrganizationException(fIdentities.getCanonicalPath() + " does not exist."); - } - } catch (IOException e) { - throw new OrganizationException(e); - } - } - - // Implement your own Delegation System - static final List NULL_DELEGATES = new ArrayList(); - - public Identities identities; - private boolean dryRun; - private Session session; - public enum Types {Employee, Contractor, Application, NotActive}; - private final static Set typeSet; - - static { - typeSet = new HashSet(); - for(Types t : Types.values()) { - typeSet.add(t.name()); - } - } - - private static final EmailWarnings emailWarnings = new DefaultOrgWarnings(); - - @Override - public String getName() { - return NAME; - } - - @Override - public String getRealm() { - return REALM; - } - - @Override - public String getDomain() { - return DOMAIN; - } - - @Override - public DefaultOrgIdentity getIdentity(AuthzTrans trans, String id) throws OrganizationException { - return new DefaultOrgIdentity(trans,id,this); - } - - // Note: Return a null if found; return a String Message explaining why not found. - @Override - public String isValidID(String id) { - Data data; - try { - data = identities.find(id, identities.reuse()); - } catch (IOException e) { - return getName() + " could not lookup " + id + ": " + e.getLocalizedMessage(); - } - return data==null?id + "is not an Identity in " + getName():null; - } - - @Override - public String isValidPassword(String user, String password, String... prev) { - // If you have an Organization user/Password scheme, use here, otherwise, just use AAF - return NO_PASS; - } - - @Override - public Set getIdentityTypes() { - return typeSet; - } - - @Override - public Response notify(AuthzTrans trans, Notify type, String url, String[] identities, String[] ccs, String summary, Boolean urgent) { - String system = trans.getProperty("CASS_ENV", ""); - - ArrayList toList = new ArrayList(); - Identity identity; - if (identities != null) { - for (String user : identities) { - try { - identity = getIdentity(trans, user); - if (identity == null) { - trans.error().log( - "Failure to obtain User " + user + " for " - + getName()); - } else { - toList.add(identity.email()); - } - } catch (Exception e) { - trans.error().log( - e, - "Failure to obtain User " + user + " for " - + getName()); - } - } - } - - if (toList.isEmpty()) { - trans.error().log("No Users listed to email"); - return Response.ERR_NotificationFailure; - } - - ArrayList ccList = new ArrayList(); - - // If we're sending an urgent email, CC the user's supervisor - // - if (urgent) { - trans.info().log("urgent msg for: " + identities[0]); - try { - List supervisors = getApprovers(trans, identities[0]); - for (Identity us : supervisors) { - trans.info().log("supervisor: " + us.email()); - ccList.add(us.email()); - } - } catch (Exception e) { - trans.error().log(e, - "Failed to find supervisor for " + identities[0]); - } - } - - if (ccs != null) { - for (String user : ccs) { - try { - identity = getIdentity(trans, user); - ccList.add(identity.email()); - } catch (Exception e) { - trans.error().log( - e, - "Failure to obtain User " + user + " for " - + getName()); - } - } - } - - if (summary == null) { - summary = ""; - } - - switch (type) { - case Approval: - try { - sendEmail(trans, toList, ccList, - "AAF Approval Notification " - + (system.length() == 0 ? "" : "(ENV: " - + system + ")"), - "AAF is the " - + NAME - + "System for Fine-Grained Authorizations. You are being asked to Approve" - + (system.length() == 0 ? "" : " in the " - + system + " environment") - + " before AAF Actions can be taken.\n\n" - + "Please follow this link: \n\n\t" + url - + "\n\n" + summary, urgent); - } catch (Exception e) { - trans.error().log(e, "Failure to send Email"); - return Response.ERR_NotificationFailure; - } - break; - case PasswordExpiration: - try { - sendEmail(trans, - toList, - ccList, - "AAF Password Expiration Warning " - + (system.length() == 0 ? "" : "(ENV: " - + system + ")"), - "AAF is the " - + NAME - + " System for Authorizations.\n\nOne or more passwords will expire soon or have expired" - + (system.length() == 0 ? "" : " in the " - + system + " environment") - + ".\n\nPasswords expired for more than 30 days without action are subject to deletion.\n\n" - + "Please follow each link to add a New Password with Expiration Date. Either are valid until expiration. " - + "Use this time to change the passwords on your system. If issues, reply to this email.\n\n" - + summary, urgent); - } catch (Exception e) { - trans.error().log(e, "Failure to send Email"); - return Response.ERR_NotificationFailure; - } - break; - - case RoleExpiration: - try { - sendEmail( - trans, - toList, - ccList, - "AAF Role Expiration Warning " - + (system.length() == 0 ? "" : "(ENV: " - + system + ")"), - "AAF is the " - + NAME - + " System for Authorizations. One or more roles will expire soon" - + (system.length() == 0 ? "" : " in the " - + system + " environment") - + ".\n\nRoles expired for more than 30 days are subject to deletion." - + "Please follow this link the GUI Command line, and either 'extend' or 'del' the user in the role.\n" - + "If issues, reply to this email.\n\n\t" + url - + "\n\n" + summary, urgent); - } catch (Exception e) { - trans.error().log(e, "Failure to send Email"); - return Response.ERR_NotificationFailure; - } - break; - default: - return Response.ERR_NotImplemented; - } - return Response.OK; - } - - @Override - public int sendEmail(AuthzTrans trans, List toList, List ccList, String subject, String body, - Boolean urgent) throws OrganizationException { - int status = 1; - - List to = new ArrayList(); - for(String em : toList) { - if(em.indexOf('@')<0) { - to.add(new DefaultOrgIdentity(trans, em, this).email()); - } else { - to.add(em); - } - } - - List cc = new ArrayList(); - if(ccList!=null && !ccList.isEmpty()) { - for(String em : ccList) { - if(em.indexOf('@')<0) { - cc.add(new DefaultOrgIdentity(trans, em, this).email()); - } else { - cc.add(em); - } - } - } - - - // for now, I want all emails so we can see what goes out. Remove later - if (!ccList.contains(supportAddress)) { - ccList.add(supportAddress); - } - - try { - // Create a default MimeMessage object. - MimeMessage message = new MimeMessage(session); - - // Set From: header field of the header. - message.setFrom(new InternetAddress(mailFromUserId)); - - if (!dryRun) { - // Set To: header field of the header. This is a required field - // and calling module should make sure that it is not null or - // blank - message.addRecipients(Message.RecipientType.TO, - getAddresses(to)); - - // Set CC: header field of the header. - if ((ccList != null) && (ccList.size() > 0)) { - message.addRecipients(Message.RecipientType.CC, - getAddresses(cc)); - } - - // Set Subject: header field - message.setSubject(subject); - - if (urgent) { - message.addHeader("X-Priority", "1"); - } - - // Now set the actual message - message.setText(body); - } else { - // override recipients - message.addRecipients(Message.RecipientType.TO, - InternetAddress.parse(supportAddress)); - - // Set Subject: header field - message.setSubject("[TESTMODE] " + subject); - - if (urgent) { - message.addHeader("X-Priority", "1"); - } - - ArrayList newBody = new ArrayList(); - - Address temp[] = getAddresses(to); - String headerString = "TO:\t" + InternetAddress.toString(temp) - + "\n"; - - temp = getAddresses(cc); - headerString += "CC:\t" + InternetAddress.toString(temp) + "\n"; - - newBody.add(headerString); - - newBody.add("Text: \n"); - - newBody.add(body); - String outString = ""; - for (String s : newBody) { - outString += s + "\n"; - } - - message.setText(outString); - } - // Send message - Transport.send(message); - status = 0; - - } catch (MessagingException mex) { - throw new OrganizationException("Exception send email message " - + mex.getMessage()); - } - - return status; - } - - /** - * Default Policy is to set to 6 Months for Notification Types. - * add others/change as required - */ - @Override - public Date whenToValidate(Notify type, Date lastValidated) { - switch(type) { - case Approval: - case PasswordExpiration: - return null; - default: - GregorianCalendar gc = new GregorianCalendar(); - gc.setTime(lastValidated); - gc.add(GregorianCalendar.MONTH, 6); // 6 month policy - return gc.getTime(); - } - } - - @Override - public GregorianCalendar expiration(GregorianCalendar gc, Expiration exp, String... extra) { - GregorianCalendar rv = gc==null?new GregorianCalendar():(GregorianCalendar)gc.clone(); - switch (exp) { - case ExtendPassword: - // Extending Password give 5 extra days - rv.add(GregorianCalendar.DATE, 5); - break; - case Future: - // Future Requests last 15 days before subject to deletion. - rv.add(GregorianCalendar.DATE, 15); - break; - case Password: - // Passwords expire in 90 days - rv.add(GregorianCalendar.DATE, 90); - break; - case TempPassword: - // Temporary Passwords last for 12 hours. - rv.add(GregorianCalendar.HOUR, 12); - break; - case UserDelegate: - // Delegations expire max in 2 months - rv.add(GregorianCalendar.MONTH, 2); - break; - case UserInRole: - // Roles expire in 6 months - rv.add(GregorianCalendar.MONTH, 6); - break; - default: - // Unless other wise set, 6 months is default - rv.add(GregorianCalendar.MONTH, 6); - break; - } - return rv; - } - - @Override - public EmailWarnings emailWarningPolicy() { - return emailWarnings; - } - - /** - * Assume the Supervisor is the Approver. - */ - @Override - public List getApprovers(AuthzTrans trans, String user) throws OrganizationException { - Identity orgIdentity = getIdentity(trans, user); - List orgIdentitys = new ArrayList(); - if(orgIdentity!=null) { - String supervisorID = orgIdentity.responsibleTo(); - if (supervisorID.indexOf('@') < 0) { - supervisorID += getDomain(); - } - Identity supervisor = getIdentity(trans, supervisorID); - orgIdentitys.add(supervisor); - } - return orgIdentitys; - } - - @Override - public String getApproverType() { - return "supervisor"; - } - - @Override - public int startOfDay() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public boolean canHaveMultipleCreds(String id) { - // External entities are likely mono-password... if you change it, it is a global change. - // This is great for people, but horrible for Applications. - // - // AAF's Password can have multiple Passwords, each with their own Expiration Date. - // For Default Org, we'll assume true for all, but when you add your external - // Identity stores, you need to return "false" if they cannot support multiple Passwords like AAF - return true; - } - - @Override - public boolean isValidCred(String id) { - if(id.endsWith(SUFFIX)) { - return true; - } - return id.matches(ID_PATTERN); - } - - @Override - public String validate(AuthzTrans trans, Policy policy, Executor executor, String... vars) throws OrganizationException { - switch(policy) { - case OWNS_MECHID: - case CREATE_MECHID: - if(vars.length>0) { - Identity requestor = getIdentity(trans, trans.user()); - if(requestor!=null) { - Identity mechid = getIdentity(trans, vars[0]); - if(requestor.equals(mechid.owner())) { - return null; - } - } - } - return trans.user() + " is not the Sponsor of MechID " + vars[0]; - - case CREATE_MECHID_BY_PERM_ONLY: - return getName() + " only allows sponsors to create MechIDs"; - - default: - return policy.name() + " is unsupported at " + getName(); - } - } - - @Override - public boolean isTestEnv() { - return false; - } - - @Override - public void setTestMode(boolean dryRun) { - this.dryRun = dryRun; - } - - /** - * Convert the delimiter String into Internet addresses with the default - * delimiter of ";" - * @param strAddress - * @return - */ - private Address[] getAddresses(List strAddress) throws OrganizationException { - return this.getAddresses(strAddress,";"); - } - /** - * Convert the delimiter String into Internet addresses with the - * delimiter of provided - * @param strAddress - * @param delimiter - * @return - */ - private Address[] getAddresses(List strAddresses, String delimiter) throws OrganizationException { - Address[] addressArray = new Address[strAddresses.size()]; - int count = 0; - for (String addr : strAddresses) - { - try{ - addressArray[count] = new InternetAddress(addr); - count++; - }catch(Exception e){ - throw new OrganizationException("Failed to parse the email address "+ addr +": "+e.getMessage()); - } - } - return addressArray; - } -} diff --git a/authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrgIdentity.java b/authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrgIdentity.java deleted file mode 100644 index d9641bec..00000000 --- a/authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrgIdentity.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.osaaf.defOrg; - -import java.io.IOException; -import java.util.List; - -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.local.AbsData.Reuse; -import org.onap.aaf.authz.org.Organization; -import org.onap.aaf.authz.org.OrganizationException; -import org.onap.aaf.authz.org.Organization.Identity; -import org.onap.aaf.osaaf.defOrg.Identities.Data; - -import org.onap.aaf.cadi.config.Config; - -/** - * Org Users are essential representations of Identities within the Org. Since this is a highly individual - * thing for most Orgs, i.e. some use LDAP, some need feed, some use something else, this object will allow - * the Organization to connect to their own Identity systems... - * - * - */ -public class DefaultOrgIdentity implements Identity { - private final static int TIMEOUT = Integer.parseInt(Config.AAF_CONN_TIMEOUT_DEF); - - private DefaultOrg org; - private Data identity; - private Identity owner; - - public DefaultOrgIdentity(AuthzTrans trans, String key, DefaultOrg dorg) throws OrganizationException { - org = dorg; - identity=null; - try { - org.identities.open(trans, TIMEOUT); - try { - Reuse r = org.identities.reuse(); - identity = org.identities.find(key, r); - if(identity==null) { - identity = Identities.NO_DATA; - } else { - if("a".equals(identity.status)) { - owner = new DefaultOrgIdentity(trans,identity.responsibleTo,org); - } else { - owner = null; - } - } - } finally { - org.identities.close(trans); - } - } catch (IOException e) { - throw new OrganizationException(e); - } - } - - @Override - public boolean equals(Object b) { - if(b instanceof DefaultOrgIdentity) { - return identity.id.equals(((DefaultOrgIdentity)b).identity.id); - } - return false; - } - - @Override - public String id() { - return identity.id; - } - - @Override - public String fullID() { - return identity.id+'@'+org.getDomain(); - } - - @Override - public String type() { - switch(identity.status) { - case "e": return DefaultOrg.Types.Employee.name(); - case "c": return DefaultOrg.Types.Contractor.name(); - case "a": return DefaultOrg.Types.Application.name(); - case "n": return DefaultOrg.Types.NotActive.name(); - default: - return "Unknown"; - } - } - - @Override - public String responsibleTo() { - return identity.responsibleTo; - } - - @Override - public List delegate() { - //NOTE: implement Delegate system, if desired - return DefaultOrg.NULL_DELEGATES; - } - - @Override - public String email() { - return identity.email; - } - - @Override - public String fullName() { - return identity.name; - } - - @Override - public boolean isResponsible() { - return "e".equals(identity.status); // Assume only Employees are responsible for Resources. - } - - @Override - public boolean isFound() { - return identity!=null; - } - - @Override - public Identity owner() throws OrganizationException { - return owner; - } - - @Override - public Organization org() { - return org; - } - -} diff --git a/authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrgWarnings.java b/authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrgWarnings.java deleted file mode 100644 index 3618379d..00000000 --- a/authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrgWarnings.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.osaaf.defOrg; - -import org.onap.aaf.authz.org.EmailWarnings; - -public class DefaultOrgWarnings implements EmailWarnings { - - @Override - public long credEmailInterval() - { - return 604800000L; // 7 days in millis 1000 * 86400 * 7 - } - - @Override - public long roleEmailInterval() - { - return 604800000L; // 7 days in millis 1000 * 86400 * 7 - } - - @Override - public long apprEmailInterval() { - return 259200000L; // 3 days in millis 1000 * 86400 * 3 - } - - @Override - public long credExpirationWarning() - { - return( 2592000000L ); // One month, in milliseconds 1000 * 86400 * 30 in milliseconds - } - - @Override - public long roleExpirationWarning() - { - return( 2592000000L ); // One month, in milliseconds 1000 * 86400 * 30 in milliseconds - } - - @Override - public long emailUrgentWarning() - { - return( 1209600000L ); // Two weeks, in milliseconds 1000 * 86400 * 14 in milliseconds - } - -} diff --git a/authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/Identities.java b/authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/Identities.java deleted file mode 100644 index f7f1319d..00000000 --- a/authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/Identities.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.osaaf.defOrg; - -import java.io.File; -import java.io.IOException; - -import org.onap.aaf.authz.local.AbsData; -import org.onap.aaf.authz.local.DataFile.Token.Field; - -/* - * Example User Data file, which can be modified for many different kinds of Data Feeds. - * - * Note: This has shown to be extremely effective in AT&T, an acknowledged very large organizations, - * because there is no need to synchronize records. AAF simply receives a Data Feed in Organization - * defined intervals. (You might want to check for validity, such as size, etc), then is copied into - * Data Directory. You will want to do so first creating a "lock" file. Assuming the File name is "users.dat", - * the Lock File is "users.lock". - * - * After the movement of the Datafile into place, it is best to remove the Index File, then remove the lock file. - * - * Note, Any AAF Programs needing this data WILL wait on the Lock file, so you should get fresh Data files - * in a "stage" directory, from WEB, or wherever, and then, after it is correct, do the following as fast as feasible. - * - * a) lock - * b) copy from stage - * c) remove idx - * d) unlock - * - * If the Index File is either non-existent or out of date from the Data File, it will be reindexed, which - * has proven to be a very quick function, even with large numbers of entries. - * - * This Sample Feed is set for a file with delimiter of "|". 512 is maximum expected line length. The "0" is the - * field offset for the "key" to the record, which, for user, should be the unique Organization Identity. - * - */ -public class Identities extends AbsData { - public final static Data NO_DATA = new Data(); - - public Identities(File users) { - super(users,'|',512,0); - } - - /* - * Example Field Layout. note, in this example, Application IDs and People IDs are mixed. You may want to split - * out AppIDs, choose your own status indicators, or whatever you use. - * 0 - unique ID - * 1 - full name - * 2 - first name - * 3 - last name - * 4 - phone - * 5 - official email - * 6 - employment status e=employee, c=contractor, a=application, n=no longer with company - * 7 - responsible to (i.e Supervisor for People, or AppOwner, if it's an App ID) - */ - public static class Data { - public final String id; - public final String name; - public final String fname; - public final String lname; - public final String phone; - public final String email; - public final String status; - public final String responsibleTo; - - private Data(Field f) { - f.reset(); - id=f.next(); - name=f.next(); - fname=f.next(); - lname=f.next(); - phone=f.next(); - email=f.next(); - status=f.next(); - responsibleTo =f.next(); - } - - private Data() { - id = name = fname = lname = - phone = email = status = responsibleTo - = ""; - } - - public String toString() { - return id + '|' + - name + '|' + - lname + '|' + - fname + '|' + - phone + '|' + - email + '|' + - status + '|' + - responsibleTo; - } - - // Here, make up your own Methods which help you easily determine your Organization's structure - // in your Organization Object - public boolean hasStatus(String possible) { - return possible.contains(status); - } - - public boolean isEmployee() { - return "e".equals(status); - } - - public boolean isContractor() { - return "c".equals(status); - } - - public boolean isApplication() { - return "a".equals(status); - } - } - - public Data find(Object key,Reuse r) throws IOException { - r.getFieldData().reset(); - // These are new, to allow for Thread Safety - int rec = ti.find(key,r.getTokenData(),r.getFieldData(),0); - if(rec<0) { - return null; - } - r.getTokenData().pos(rec); - return new Data(r.getFieldData()); - } -} diff --git a/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrd/test/JU_Identities.java b/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrd/test/JU_Identities.java deleted file mode 100644 index 064d0953..00000000 --- a/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrd/test/JU_Identities.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -/** - * - */ -package org.onap.aaf.osaaf.defOrd.test; - -import java.io.File; -import java.io.IOException; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.local.AbsData.Reuse; -import org.onap.aaf.osaaf.defOrg.Identities; -import org.onap.aaf.osaaf.defOrg.Identities.Data; - -/** - * - */ -public class JU_Identities { - - private static final String DATA_IDENTITIES = "../opt/app/aaf/data/identities.dat"; - private static File fids; - private static Identities ids; - private static AuthzEnv env; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - env = new AuthzEnv(); - AuthzTrans trans = env.newTransNoAvg(); - // Note: utilize TimeTaken, from trans.start if you want to time. - fids = new File(DATA_IDENTITIES); - if(fids.exists()) { - ids = new Identities(fids); - ids.open(trans, 5000); - } else { - - throw new Exception("Data File for Tests, \"" + DATA_IDENTITIES - + "\" must exist before test can run. (Current dir is " + System.getProperty("user.dir") + ")"); - } - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - AuthzTrans trans = env.newTransNoAvg(); - if(ids!=null) { - ids.close(trans); - } - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception { - } - - @Test - public void test() throws IOException { - Reuse reuse = ids.reuse(); // this object can be reused within the same thread. - Data id = ids.find("osaaf",reuse); - Assert.assertNotNull(id); - System.out.println(id); - - id = ids.find("mmanager",reuse); - Assert.assertNotNull(id); - System.out.println(id); - - //TODO Fill out JUnit with Tests of all Methods in "Data id" - } - -} diff --git a/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrg.java b/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrg.java deleted file mode 100644 index 43a593c6..00000000 --- a/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrg.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.osaaf.defOrg; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.util.Set; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.org.OrganizationException; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.modules.junit4.PowerMockRunner; - -@RunWith(PowerMockRunner.class) -public class JU_DefaultOrg { - -DefaultOrg defaultOrg; -//private DefaultOrg defaultOrgMock; -@Mock -AuthzEnv authzEnvMock; - -private static final String PROPERTY_IS_REQUIRED = " property is Required"; -private static final String DOMAIN = "osaaf.com"; -private static final String REALM = "com.osaaf"; -private static final String NAME = "Default Organization"; -private static final String NO_PASS = NAME + " does not support Passwords. Use AAF"; -String mailHost,mailFromUserId,supportAddress; -private String SUFFIX; -String s; -String defFile; -@Mock -File fIdentitiesMock; - - -@Before -public void setUp() throws OrganizationException{ - MockitoAnnotations.initMocks(this); - PowerMockito.when(authzEnvMock.getProperty(s=(REALM + ".mailHost"), null)).thenReturn("hello"); - PowerMockito.when(authzEnvMock.getProperty(s=(REALM + ".supportEmail"), null)).thenReturn("notnull"); - PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn("src" + File.separator + "test" + File.separator + "resources" + File.separator + "test.txt"); - PowerMockito.when(fIdentitiesMock.exists()).thenReturn(true); - //PowerMockito.when((fIdentitiesMock!=null && fIdentitiesMock.exists())).thenReturn(true); - defaultOrg = new DefaultOrg(authzEnvMock); -} - -@Test //(expected=OrganizationException.class) -public void test() throws OrganizationException{ - //PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn(" "); - //defaultOrg = new DefaultOrg(authzEnvMock); - assertTrue(defaultOrg != null); -} - - -@Test //(expected=OrganizationException.class) -public void testMultipleCreds() throws OrganizationException{ - String id = "test"; - //PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn(" "); - //defaultOrg = new DefaultOrg(authzEnvMock); - boolean canHaveMultipleCreds; - canHaveMultipleCreds = defaultOrg.canHaveMultipleCreds(id ); - System.out.println("value of canHaveMultipleCreds: " + canHaveMultipleCreds); - assertTrue(canHaveMultipleCreds); -} - - -@Test -public void testGetIdentityTypes() throws OrganizationException{ - Set identityTypes = defaultOrg.getIdentityTypes(); - System.out.println("value of IdentityTypes: " + identityTypes); - assertTrue(identityTypes.size() == 4); -} - - -@Test -public void testGetRealm() throws OrganizationException{ - String realmTest = defaultOrg.getRealm(); - System.out.println("value of realm: " + realmTest); - assertTrue(realmTest == REALM); -} - -@Test -public void testGetName() throws OrganizationException{ - String testName = defaultOrg.getName(); - System.out.println("value of name: " + testName); - assertTrue(testName == NAME); -} - - -@Test -public void testGetDomain() throws OrganizationException{ - String testDomain = defaultOrg.getDomain(); - System.out.println("value of domain: " + testDomain); - assertTrue(testDomain == DOMAIN); -} - - - -@Test -public void testIsValidID(){ - String Result = defaultOrg.isValidID(Matchers.anyString()); - System.out.println("value of res " +Result); - assertNotNull(Result); -} - -@Mock -AuthzTrans authzTransMock; - - -} diff --git a/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrgIdentity.java b/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrgIdentity.java deleted file mode 100644 index 755f0b13..00000000 --- a/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrgIdentity.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.osaaf.defOrg; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.org.OrganizationException; -import org.onap.aaf.authz.org.Organization.Identity; -import org.onap.aaf.osaaf.defOrg.DefaultOrg; -import org.onap.aaf.osaaf.defOrg.DefaultOrgIdentity; -import org.onap.aaf.osaaf.defOrg.Identities.Data; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.modules.junit4.PowerMockRunner; - -@RunWith(PowerMockRunner.class) -public class JU_DefaultOrgIdentity { - - private DefaultOrgIdentity defaultOrgIdentity; - private DefaultOrgIdentity defaultOrgIdentityMock; - - @Mock - AuthzTrans authzTransMock; - - String key="key"; - - @Mock - private DefaultOrg defaultOrgMock; - @Mock - private Data dataMock; - @Mock - private Identity identityMock; - - @Before - public void setUp() throws OrganizationException{ - MockitoAnnotations.initMocks(this); - defaultOrgIdentityMock = PowerMockito.mock(DefaultOrgIdentity.class); - } - - @Test - public void testEquals(){ - Object b = null; - Boolean res = defaultOrgIdentityMock.equals(b); - System.out.println("value of res " +res); - } - - - @Test - public void testIsFound(){ - defaultOrgIdentityMock.isFound(); - System.out.println("value of found " +defaultOrgIdentityMock.isFound()); - assertFalse(defaultOrgIdentityMock.isFound()); - } - - @Test - public void testIsResponsible(){ - defaultOrgIdentityMock.isResponsible(); - System.out.println("value of res " +defaultOrgIdentityMock.isResponsible()); - assertFalse(defaultOrgIdentityMock.isResponsible()); - } - - @Test - public void testFullName(){ - String fullName = defaultOrgIdentityMock.fullName(); - System.out.println("value of fullname " +fullName); - assertTrue(fullName == null); - } - - -} diff --git a/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrgWarnings.java b/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrgWarnings.java deleted file mode 100644 index 60665944..00000000 --- a/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrgWarnings.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.osaaf.defOrg; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.MockitoAnnotations; -import org.onap.aaf.osaaf.defOrg.DefaultOrgWarnings; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.modules.junit4.PowerMockRunner; - -@RunWith(PowerMockRunner.class) -public class JU_DefaultOrgWarnings { - - private DefaultOrgWarnings defaultOrgWarningsMock; - private DefaultOrgWarnings defaultOrgWarnings; - - - @Before - public void setUp(){ - MockitoAnnotations.initMocks(this); - - defaultOrgWarningsMock = PowerMockito.mock(DefaultOrgWarnings.class); - - defaultOrgWarnings = new DefaultOrgWarnings(); - } - - - @Test - public void testApprEmailInterval() { - - assertEquals(259200000, defaultOrgWarnings.apprEmailInterval() ); - } - - @Test - public void testCredEmailInterval() { - assertEquals(604800000, defaultOrgWarnings.credEmailInterval()); - - } - - @Test - public void testCredExpirationWarning() { - assertEquals(2592000000L, defaultOrgWarnings.credExpirationWarning()); - } - - @Test - public void testEmailUrgentWarning() { - assertEquals(1209600000L, defaultOrgWarnings.emailUrgentWarning()); - } - - @Test - public void testRoleEmailInterval() { - assertEquals(604800000L, defaultOrgWarnings.roleEmailInterval()); - } - - @Test - public void testRoleExpirationWarning() { - assertEquals(2592000000L, defaultOrgWarnings.roleExpirationWarning()); - } - -} diff --git a/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_Identities.java b/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_Identities.java deleted file mode 100644 index 78551c03..00000000 --- a/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_Identities.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -/** - * - */ -package org.onap.aaf.osaaf.defOrg; - -import java.io.File; -import java.io.IOException; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.aaf.authz.env.AuthzEnv; -import org.onap.aaf.authz.env.AuthzTrans; -import org.onap.aaf.authz.local.AbsData.Reuse; -import org.onap.aaf.osaaf.defOrg.Identities; -import org.onap.aaf.osaaf.defOrg.Identities.Data; - -/** - * - */ -public class JU_Identities { - - private static final String DATA_IDENTITIES = "../opt/app/aaf/data/identities.dat"; - private static File fids; - private static Identities ids; - private static AuthzEnv env; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - env = new AuthzEnv(); - AuthzTrans trans = env.newTransNoAvg(); - // Note: utilize TimeTaken, from trans.start if you want to time. - fids = new File(DATA_IDENTITIES); - if(fids.exists()) { - ids = new Identities(fids); - ids.open(trans, 5000); - } else { - - throw new Exception("Data File for Tests, \"" + DATA_IDENTITIES - + "\" must exist before test can run. (Current dir is " + System.getProperty("user.dir") + ")"); - } - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - AuthzTrans trans = env.newTransNoAvg(); - if(ids!=null) { - ids.close(trans); - } - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception { - } - - @Test - public void test() throws IOException { - Reuse reuse = ids.reuse(); // this object can be reused within the same thread. - Data id = ids.find("osaaf",reuse); - Assert.assertNotNull(id); - System.out.println(id); - - id = ids.find("mmanager",reuse); - Assert.assertNotNull(id); - System.out.println(id); - - //TODO Fill out JUnit with Tests of all Methods in "Data id" - } - -} diff --git a/authz-defOrg/src/test/resources/test.txt b/authz-defOrg/src/test/resources/test.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/cadi/aaf/pom.xml b/cadi/aaf/pom.xml index d7b6f550..368d02a6 100644 --- a/cadi/aaf/pom.xml +++ b/cadi/aaf/pom.xml @@ -85,7 +85,7 @@ javax.servlet - javax.servlet-api + servlet-api provided diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java deleted file mode 100644 index ddc7f001..00000000 --- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java +++ /dev/null @@ -1,573 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * - ******************************************************************************/ -package org.onap.aaf.cadi.lur.aaf.test; - -import static org.junit.Assert.assertEquals; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.security.Principal; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Locale; -import java.util.Map; - -import javax.servlet.AsyncContext; -import javax.servlet.DispatcherType; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import javax.servlet.http.Part; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.Lur; -import org.onap.aaf.cadi.Permission; -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.Symm; -import org.onap.aaf.cadi.Taf.LifeForm; -import org.onap.aaf.cadi.aaf.AAFPermission; -import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp; -import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm; -import org.onap.aaf.cadi.aaf.v2_0.AAFTaf; -import org.onap.aaf.cadi.locator.DNSLocator; -import org.onap.aaf.cadi.lur.ConfigPrincipal; -import org.onap.aaf.cadi.lur.LocalPermission; -import org.onap.aaf.cadi.taf.TafResp; - -public class JU_Lur2_0Call { - private static AAFConHttp aaf; - private static PropAccess access; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - access = new PropAccess(); - aaf = new AAFConHttp(access,new DNSLocator(access,"https","localhost","8100")); - aaf.basicAuth("testid", "whatever"); - } - - @Test - public void test() throws Exception { - - AAFLurPerm aafLur = aaf.newLur(); - - Principal pri = new ConfigPrincipal("testid@aaf.att.com","whatever"); - for (int i = 0; i < 10; ++i) { - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|write"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|kumquat|write"),false); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|read"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|kumquat|read"),true); - - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","myInstance","write"),true); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","kumquat","write"),false); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","myInstance","read"),true); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","kumquat","read"),true); - - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!kum.*|read"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|!wr*"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance"),true); - - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","!kum.*","read"),true); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","myInstance","!wr*"),true); - - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!kum[Qq]uat|read"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!my[iI]nstance|!wr*"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!my[iI]nstance|!wr*"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|!wr*"),true); - - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","!kum[Qq]uat","read"),true); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","!my[iI]nstance","!wr*"),true); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","!my[iI]nstance","!wr*"),true); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","myInstance","!wr*"),true); - - - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!my.nstance|!wr*"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|my.nstance|!wr*"),false); - - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|my.nstance|!wr*"),false); - - //Maitrayee, aren't we going to have issues if we do RegExp with "."? - //Is it too expensive to only do Reg Ex in presence of special characters, []{}*, etc? Not sure this helps for GRID. - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|kum.quat|read"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!kum..uat|read"),true); - - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance"),true); // ok if Stored Action is "*" - - // Key Evaluations - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|:myCluster:*:!my.*|write"),true); // ok if Stored Action is "*" - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|:myCluster:*|write"),false); // not ok if key lengths don't match "*" - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|:myCluster:*:myCF|write"),true); // ok if Stored Action is "*" - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service",":myCluster:*:!my.*","write"),true); // ok if Stored Action is "*" - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service",":myCluster:*:myCF","write"),true); // ok if Stored Action is "*" - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service",":myCluster:*","write"),false); // not ok if key lengths don't match - - } - - print(aafLur, pri, new LocalPermission("bogus"),false); - -// try { -// Thread.sleep(7000); -// } catch (InterruptedException e) { -// e.printStackTrace(); -// } - for (int i = 0; i < 10; ++i) - print(aafLur, pri, new LocalPermission("supergroup"),false); - - System.out.println("All Done"); - } - @Test - public void testTaf() throws Exception { - AAFTaf aaft = new AAFTaf(aaf,true); - - TafResp resp; - // No Header - resp = aaft.validate(LifeForm.CBLF, new Req(), null); - assertEquals(TafResp.RESP.TRY_AUTHENTICATING, resp.isAuthenticated()); - - String auth = "Basic " + Symm.base64.encode("testid:whatever"); - resp = aaft.validate(LifeForm.CBLF, new Req("Authorization",auth), null); - assertEquals(TafResp.RESP.IS_AUTHENTICATED, resp.isAuthenticated()); - - } -// @Test -// public void testRole() throws CadiException { -// TestAccess ta = new TestAccess(); -// AAFLurRole1_0 aafLur = new AAFLurRole1_0( -// ta, -//// "http://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=1.0.0/envContext=UAT/routeOffer=BAU_SE", -// "http://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=1.0.0/envContext=DEV/routeOffer=D1", -// "m12345", "m12345pass", 50000, // dme Time -// // 5*60000); // 5 minutes User Expiration -// 50000, // 5 seconds after Expiration -// 200); // High Count of items.. These do not take much memory -// -// Principal pri = new ConfigPrincipal("xy1234","whatever"); -// for (int i = 0; i < 10; ++i) { -//// print(aafLur, pri, new LocalPermission("*|*|*|com.att.authz")); -// print(aafLur, pri, new LocalPermission("service|myInstance|write"),false); -// print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|write"),false); -// print(aafLur, pri, new LocalPermission("org.osaaf.cadi"),true); -// print(aafLur, pri, new LocalPermission("global"),true); -// print(aafLur, pri, new LocalPermission("kumquat"),false); -// } -// -// print(aafLur, pri, new LocalPermission("bogus"),false); -// -// for (int i = 0; i < 10; ++i) -// print(aafLur, pri, new LocalPermission("supergroup"),false); -// -// System.out.println("All Done"); -// } - - - private void print(Lur aafLur, Principal pri, Permission perm, boolean shouldBe) - throws CadiException { - long start = System.nanoTime(); - - // The Call - boolean ok = aafLur.fish(pri, perm); - - assertEquals(shouldBe,ok); - float ms = (System.nanoTime() - start) / 1000000f; - if (ok) { - System.out.println("Yes, part of " + perm.getKey() + " (" + ms - + "ms)"); - } else { - System.out.println("No, not part of " + perm.getKey() + " (" + ms - + "ms)"); - } - } - - @SuppressWarnings("rawtypes") - public class Req implements HttpServletRequest { - private String[] headers; - - public Req(String ... headers) { - this.headers = headers; - } - - public Object getAttribute(String name) { - // TODO Auto-generated method stub - return null; - } - - @SuppressWarnings("unchecked") - public Enumeration getAttributeNames() { - // TODO Auto-generated method stub - return null; - } - - public String getCharacterEncoding() { - // TODO Auto-generated method stub - return null; - } - - public void setCharacterEncoding(String env) - throws UnsupportedEncodingException { - // TODO Auto-generated method stub - - } - - public int getContentLength() { - // TODO Auto-generated method stub - return 0; - } - - public String getContentType() { - // TODO Auto-generated method stub - return null; - } - - public ServletInputStream getInputStream() throws IOException { - // TODO Auto-generated method stub - return null; - } - - public String getParameter(String name) { - // TODO Auto-generated method stub - return null; - } - - @SuppressWarnings("unchecked") - public Enumeration getParameterNames() { - // TODO Auto-generated method stub - return null; - } - - public String[] getParameterValues(String name) { - // TODO Auto-generated method stub - return null; - } - - @SuppressWarnings("unchecked") - public Map getParameterMap() { - // TODO Auto-generated method stub - return null; - } - - public String getProtocol() { - // TODO Auto-generated method stub - return null; - } - - public String getScheme() { - // TODO Auto-generated method stub - return null; - } - - public String getServerName() { - // TODO Auto-generated method stub - return null; - } - - public int getServerPort() { - // TODO Auto-generated method stub - return 0; - } - - public BufferedReader getReader() throws IOException { - // TODO Auto-generated method stub - return null; - } - - public String getRemoteAddr() { - // TODO Auto-generated method stub - return null; - } - - public String getRemoteHost() { - // TODO Auto-generated method stub - return null; - } - - public void setAttribute(String name, Object o) { - // TODO Auto-generated method stub - - } - - public void removeAttribute(String name) { - // TODO Auto-generated method stub - - } - - public Locale getLocale() { - // TODO Auto-generated method stub - return null; - } - - @SuppressWarnings("unchecked") - public Enumeration getLocales() { - // TODO Auto-generated method stub - return null; - } - - public boolean isSecure() { - // TODO Auto-generated method stub - return false; - } - - public RequestDispatcher getRequestDispatcher(String path) { - // TODO Auto-generated method stub - return null; - } - - public String getRealPath(String path) { - // TODO Auto-generated method stub - return null; - } - - public int getRemotePort() { - // TODO Auto-generated method stub - return 0; - } - - public String getLocalName() { - // TODO Auto-generated method stub - return null; - } - - public String getLocalAddr() { - // TODO Auto-generated method stub - return null; - } - - public int getLocalPort() { - // TODO Auto-generated method stub - return 0; - } - - public String getAuthType() { - // TODO Auto-generated method stub - return null; - } - - public Cookie[] getCookies() { - // TODO Auto-generated method stub - return null; - } - - public long getDateHeader(String name) { - // TODO Auto-generated method stub - return 0; - } - - public String getHeader(String name) { - for(int i=1;i getParts() throws IOException, ServletException { - // TODO Auto-generated method stub - return null; - } - - @Override - public Part getPart(String name) throws IOException, ServletException { - // TODO Auto-generated method stub - return null; - } - - } -} diff --git a/cadi/client/pom.xml b/cadi/client/pom.xml index 1081ab09..a553b1b0 100644 --- a/cadi/client/pom.xml +++ b/cadi/client/pom.xml @@ -72,7 +72,7 @@ javax.servlet - javax.servlet-api + servlet-api compile diff --git a/cadi/core/pom.xml b/cadi/core/pom.xml index 1e8ea1c9..5ad6baac 100644 --- a/cadi/core/pom.xml +++ b/cadi/core/pom.xml @@ -54,7 +54,7 @@ javax.servlet - javax.servlet-api + servlet-api provided diff --git a/cadi/pom.xml b/cadi/pom.xml index 7fecc035..0634cc69 100644 --- a/cadi/pom.xml +++ b/cadi/pom.xml @@ -233,8 +233,8 @@ javax.servlet - javax.servlet-api - 3.0.1 + servlet-api + 2.5 diff --git a/pom.xml b/pom.xml index ba5bab1b..ece3cd2a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,548 +1,62 @@ - 4.0.0 - org.onap.aaf.authz + osaaf parent - 1.0.1-SNAPSHOT - aaf-authz + 2.1.0-SNAPSHOT + AAF Overall Parent pom - https://github.com/att/AAF - - - org.onap.oparent - oparent - 1.1.0 - - - - - - Jonathan Gathman - - ATT - - - - This module is used to organize all of the common SWM (Software Manager) - artifacts and capabilities that are inherited by all modules that are SWM - packaged. This prevents duplication of these common artifacts, plugins, and - other settings and provides a single place to support this configuration. - - - UTF-8 - false - 1.0.0-SNAPSHOT - 1.0.0-SNAPSHOT - 1.0.0-SNAPSHOT - 3.1.200 - - 0.7.7.201606060606 - 3.2 - jacoco - - target/code-coverage/jacoco-ut.exec - target/code-coverage/jacoco-it.exec - - **/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/** - https://nexus.onap.org - /content/repositories/snapshots/ - /content/repositories/releases/ - /content/repositories/staging/ - /content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version} - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.8 - 1.8 - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.17 - - ${skipTests} - - **/JU*.java - - - - **/JU_DataFile.java - **/JU_ArtiDAO.java - **/JU_CertDAO.java - **/JU_FastCalling.java - **/JU_NsDAO.java - - - **/JU_RoleDAO.java - **/JU_PermDAO.java - **/JU_Question.java - - **/JU_HistoryDAO.java - **/JU_DelegateDAO.java - **/JU_CredDAO.java - **/JU_CacheInfoDAO.java - **/JU_ApprovalDAO.java - - **/JU_Identities.java - **/JU_AuthzTransFilter.java - **/JU_CachingFileAccess.java - - - **/JU_FileServer.java - **/JU_DirectAAFLur.java - **/JU_AuthAPI.java - **/JU_GwAPI.java - **/JU_NsDAO.java - **/JU_Delete.java - **/JU_Create.java - **/JU_Admin.java - **/JU_Attrib.java - **/JU_Describe.java - **/JU_ListUsersInRole.java - **/JU_ListUsersWithPerm.java - **/JU_Responsible.java - - - - - - - - - - - - - - org.codehaus.mojo - jaxb2-maven-plugin - 1.3 - - - generate-sources - - xjc - - - - - src/main/xsd - - - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.17 - - true - - - - integration-test - - integration-test - verify - - - - - - org.apache.maven.plugins - maven-jarsigner-plugin - 1.2 - - - sign - - sign - - - - target/${project.artifactId}-${project.version}.jar - - - - verify - - verify - - - target/${project.artifactId}-${project.version}.jar - - - - - true - aaf - /Volumes/Data/src/cadi/keys/aaf_cadi.jks - Surprise! - Surprise! - true - true - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.4 - - false - - - - attach-javadocs - - jar - - - - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.7 + + + org.apache.maven.plugins + maven-deploy-plugin - - html - xml - + true - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ${nexusproxy} - 176c31dfe190a - ecomp-staging - - - - org.jacoco - jacoco-maven-plugin - ${jacoco.version} - - - **/gen/** - **/generated-sources/** - **/yang-gen/** - **/pax/** - - - - - - pre-unit-test - - prepare-agent - - - ${project.build.directory}/code-coverage/jacoco-ut.exec - surefireArgLine - - - - - - post-unit-test - test - - report - - - ${project.build.directory}/code-coverage/jacoco-ut.exec - ${project.reporting.outputDirectory}/jacoco-ut - - - - pre-integration-test - pre-integration-test - - prepare-agent - - - ${project.build.directory}/code-coverage/jacoco-it.exec - - failsafeArgLine - - - - - - post-integration-test - post-integration-test - - report - - - ${project.build.directory}/code-coverage/jacoco-it.exec - ${project.reporting.outputDirectory}/jacoco-it - - - - - - - + - - - - junit - junit - 4.10 - test - - - - org.mockito - mockito-core - 1.10.19 - test - - - org.powermock - powermock-module-junit4 - 1.6.4 - test - - - org.powermock - powermock-api-mockito - 1.6.4 - test - - - - - + auth/auth-client + misc + cadi + auth - - - - org.onap.aaf.inno - env - ${project.innoVersion} - - - - org.onap.aaf.inno - log4j - ${project.innoVersion} - - - - org.onap.aaf.inno - rosetta - ${project.innoVersion} - - - - org.onap.aaf.inno - xgen - ${project.innoVersion} - - - - org.onap.aaf.cadi - cadi-core - ${project.cadiVersion} - - - - org.onap.aaf.cadi - cadi-client - ${project.cadiVersion} - - - - - org.onap.aaf.cadi - cadi-aaf - ${project.cadiVersion} - - - org.apache.cassandra - cassandra-all - - - - - - org.onap.aaf.authz - authz-client - ${project.interfaceVersion} - - - - - org.onap.aaf.authz - authz-core - ${project.version} - - - - org.onap.aaf.authz - authz-cass - ${project.version} - - - - org.onap.aaf.authz - authz-batch - ${project.interfaceVersion} - - - - - - org.onap.aaf.authz - authz-cmd - ${project.version} - - - org.onap.aaf.authz - authz-gw - ${project.version} - - - - com.att.aft - dme2 - ${project.dme2Version} - - - - javax.servlet - servlet-api - 2.5 - - - - org.eclipse.jetty - jetty-servlet - 9.0.3.v20130506 - - - - com.datastax.cassandra - cassandra-all - 2.1.10 - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - com.datastax.cassandra - cassandra-driver-core - - - 2.1.10 - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - - org.slf4j - slf4j-log4j12 - 1.7.5 - - - - javax.mail - mail - 1.4.5 - - - - - + + - ecomp-releases - AAF Release Repository - ${nexusproxy}${releaseNexusPath} + nexus + attarch-releases + http://mavencentral.it.att.com:8084/nexus/content/repositories/attarch-releases - ecomp-snapshots - AAF Snapshot Repository - ${nexusproxy}${snapshotNexusPath} + nexus + attarch-snapshots + http://mavencentral.it.att.com:8084/nexus/content/repositories/attarch-snapshots - - ecomp-site - dav:${nexusproxy}${sitePath} - - + -- 2.16.6