summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorInstrumental <jcgmisc@stl.gathman.org>2018-03-26 14:07:37 -0700
committerInstrumental <jcgmisc@stl.gathman.org>2018-03-26 14:07:42 -0700
commit10027f3cd15afd2c8ef341e5cd92de911e07965e (patch)
tree33982e04750074d4f123eeb960b5302522223f4b
parent71037c39a37d3549dcfe31926832a657744fbe05 (diff)
AT&T 2.0.19 Code drop, stage 4
Issue-ID: AAF-197 Change-Id: Ibe14fed4b583966dca5559710bced7bec868eae9 Signed-off-by: Instrumental <jcgmisc@stl.gathman.org>
-rw-r--r--auth/auth-batch/pom.xml6
-rw-r--r--auth/pom.xml2
-rw-r--r--authz-certman/pom.xml247
-rw-r--r--authz-certman/src/main/config/certman.props25
-rw-r--r--authz-certman/src/main/config/log4j.properties78
-rw-r--r--authz-certman/src/main/config/lrm-authz-certman.xml82
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/api/API_Artifact.java130
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/api/API_Cert.java100
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/AppCA.java356
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/CA.java84
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/ca/DevlCA.java226
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/BCFactory.java168
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/CSRMeta.java329
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/cert/StandardFields.java29
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertDrop.java27
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertRenew.java27
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertReq.java51
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertResp.java66
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/Facade.java161
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/Facade1_0.java47
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/FacadeFactory.java43
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/facade/FacadeImpl.java493
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/mapper/Mapper.java52
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/mapper/Mapper1_0.java246
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/service/CMService.java515
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/service/CertManAPI.java285
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/service/Code.java45
-rw-r--r--authz-certman/src/main/java/org/onap/aaf/authz/cm/validation/Validator.java165
-rw-r--r--authz-certman/src/test/java/org/onap/aaf/authz/cm/api/JU_API_Artifact.java108
-rw-r--r--authz-certman/src/test/java/org/onap/aaf/authz/cm/api/JU_API_Cert.java108
-rw-r--r--authz-certman/src/test/java/org/onap/aaf/authz/cm/ca/JU_AppCA.java287
-rw-r--r--authz-certman/src/test/java/org/onap/aaf/authz/cm/ca/JU_DevlCA.java287
-rw-r--r--authz-certman/src/test/java/org/onap/aaf/authz/cm/cert/JU_BCFactory.java132
-rw-r--r--authz-certman/src/test/java/org/onap/aaf/authz/cm/cert/JU_CSRMeta.java96
-rw-r--r--authz-certman/src/test/java/org/onap/aaf/authz/cm/data/JU_CertReq.java88
-rw-r--r--authz-certman/src/test/java/org/onap/aaf/authz/cm/facade/JU_FacadeImpl.java195
-rw-r--r--authz-cmd/aafcli.sh13
-rw-r--r--authz-cmd/etc/log4j.properties54
-rw-r--r--authz-cmd/pom.xml254
-rw-r--r--authz-cmd/src/main/assemble/authz-cmd.xml47
-rw-r--r--authz-cmd/src/main/assemble/swm.xml34
-rw-r--r--authz-cmd/src/main/config/log4j.properties54
-rw-r--r--authz-cmd/src/main/config/logging.props38
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/AAFcli.java722
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/BaseCmd.java69
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/BasicAuth.java56
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/Cmd.java499
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/Help.java112
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/MessageException.java46
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/Param.java38
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/Version.java45
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Cache.java34
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Clear.java86
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Deny.java102
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Log.java111
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Mgmt.java38
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/SessClear.java84
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/mgmt/Session.java34
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Admin.java106
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Attrib.java115
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Create.java128
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Delete.java90
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Describe.java96
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/List.java170
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListActivity.java81
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListAdminResponsible.java79
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListByName.java105
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListChildren.java82
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListNsKeysByAttrib.java89
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsers.java53
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsersInRole.java129
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/ListUsersWithPerm.java128
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/NS.java47
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/ns/Responsible.java111
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Create.java165
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Delete.java90
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Describe.java102
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Grant.java151
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/perm/List.java129
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListActivity.java77
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByNS.java72
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByName.java70
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByRole.java73
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/perm/ListByUser.java76
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Perm.java44
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/perm/Rename.java103
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/role/CreateDelete.java132
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/role/Describe.java96
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/role/List.java169
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListActivity.java76
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByNS.java73
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByNameOnly.java73
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByPerm.java79
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByRole.java70
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/role/ListByUser.java146
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/role/Role.java41
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/role/User.java171
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/user/Cred.java153
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/user/Delg.java136
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/user/List.java122
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListActivity.java81
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListApprovals.java104
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListDelegates.java95
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForCreds.java99
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForPermission.java104
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/user/ListForRoles.java93
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/user/Role.java158
-rw-r--r--authz-cmd/src/main/java/org/onap/aaf/cmd/user/User.java38
-rw-r--r--authz-cmd/src/main/scripts/aaflogin199
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/JU_AAFCli.java193
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/JU_BaseCmd.java235
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/JU_BasicAuth.java49
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/JU_Help.java92
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/JU_Version.java59
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_Clear.java63
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_Log.java63
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/mgmt/JU_SessClear.java63
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Admin.java65
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Attrib.java65
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Create.java65
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Delete.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Describe.java73
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListActivity.java70
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListAdminResponsible.java70
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListByName.java70
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListChildren.java70
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListNsKeysByAttrib.java70
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListUsersInRole.java67
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_ListUsersWithPerm.java67
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/ns/JU_Responsible.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Create.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Delete.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Describe.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Grant.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListActivity.java71
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByNS.java71
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByName.java71
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByRole.java71
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_ListByUser.java71
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/perm/JU_Rename.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_CreateDelete.java67
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_Describe.java67
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListActivity.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByNS.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByNameOnly.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByPerm.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByRole.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_ListByUser.java69
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/role/JU_User.java68
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Cred.java125
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Delg.java81
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListActivity.java70
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListApprovals.java70
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListDelegates.java70
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForCreds.java70
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForPermission.java70
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_ListForRoles.java70
-rw-r--r--authz-cmd/src/test/java/org/onap/aaf/cmd/user/JU_Role.java68
-rw-r--r--authz-core/pom.xml238
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/common/Define.java50
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/env/AuthzEnv.java264
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTrans.java71
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransFilter.java165
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransImpl.java198
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransOnlyFilter.java89
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/env/NullTrans.java225
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/layer/FacadeImpl.java38
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/layer/Result.java325
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/local/AbsData.java215
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/local/DataFile.java185
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/local/TextIndex.java253
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/org/EmailWarnings.java34
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/org/Executor.java35
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/org/Organization.java490
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/org/OrganizationException.java53
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/org/OrganizationFactory.java148
-rw-r--r--authz-core/src/main/java/org/onap/aaf/authz/server/AbsServer.java150
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cache/Cache.java195
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/Acceptor.java169
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/CachingFileAccess.java476
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/CodeSetter.java53
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/Content.java115
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/HttpCode.java111
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/HttpMethods.java30
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/Match.java211
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/Pair.java43
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/RServlet.java155
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/Route.java142
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/RouteReport.java34
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/Routes.java90
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/TransFilter.java136
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/TransOnlyFilter.java77
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/TypedCode.java268
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/Version.java93
-rw-r--r--authz-core/src/main/java/org/onap/aaf/cssa/rserv/doc/ApiDoc.java42
-rw-r--r--authz-core/src/test/java/org/onap/aaf/authz/common/JU_Define.java64
-rw-r--r--authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzEnv.java70
-rw-r--r--authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransFilter.java83
-rw-r--r--authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransImpl.java75
-rw-r--r--authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransOnlyFilter.java51
-rw-r--r--authz-core/src/test/java/org/onap/aaf/authz/env/JU_NullTrans.java47
-rw-r--r--authz-core/src/test/java/org/onap/aaf/authz/layer/JU_Result.java54
-rw-r--r--authz-core/src/test/java/org/onap/aaf/authz/local/JU_DataFile.java67
-rw-r--r--authz-core/src/test/java/org/onap/aaf/authz/local/JU_TextIndex.java52
-rw-r--r--authz-core/src/test/java/org/onap/aaf/authz/org/JU_OrganizationException.java49
-rw-r--r--authz-core/src/test/java/org/onap/aaf/authz/org/JU_OrganizationFactory.java65
-rw-r--r--authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_CachingFileAccess.java50
-rw-r--r--authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_CodeSetter.java69
-rw-r--r--authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Pair.java46
-rw-r--r--authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Routes.java72
-rw-r--r--authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_TypedCode.java53
-rw-r--r--authz-core/src/test/java/org/onap/aaf/cssa/rserv/JU_Version.java58
-rw-r--r--authz-core/src/test/java/org/onap/aaf/cssa/rserv/test/JU_BetterMatch.java166
-rw-r--r--authz-core/src/test/java/org/onap/aaf/cssa/rserv/test/JU_Content.java132
-rw-r--r--authz-defOrg/pom.xml207
-rw-r--r--authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrg.java596
-rw-r--r--authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrgIdentity.java147
-rw-r--r--authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/DefaultOrgWarnings.java64
-rw-r--r--authz-defOrg/src/main/java/org/onap/aaf/osaaf/defOrg/Identities.java144
-rw-r--r--authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrd/test/JU_Identities.java111
-rw-r--r--authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrg.java138
-rw-r--r--authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrgIdentity.java95
-rw-r--r--authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_DefaultOrgWarnings.java84
-rw-r--r--authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_Identities.java111
-rw-r--r--authz-defOrg/src/test/resources/test.txt0
-rw-r--r--cadi/aaf/pom.xml2
-rw-r--r--cadi/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java573
-rw-r--r--cadi/client/pom.xml2
-rw-r--r--cadi/core/pom.xml2
-rw-r--r--cadi/pom.xml4
-rw-r--r--pom.xml566
231 files changed, 46 insertions, 26731 deletions
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
@@ -94,12 +94,6 @@
</dependency>
<dependency>
- <groupId>org.joda</groupId>
- <artifactId>joda-time</artifactId>
- <version>2.5</version>
- </dependency>
-
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
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 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
- <version>3.0</version>
+ <version>2.5</version>
</dependency>
<dependency>
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 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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.
- *
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>parent</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>authz-certman</artifactId>
- <name>AAF Certification Managmenent</name>
- <description>Certificate Manager API</description>
- <url>https://github.com/att/AAF</url>
-
- <developers>
- <developer>
- <name>Jonathan Gathman</name>
- <email></email>
- <organization>ATT</organization>
- <organizationUrl></organizationUrl>
- </developer>
- </developers>
-
-
- <properties>
- <project.swmVersion>45</project.swmVersion>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.cadiVersion>1.0.0-SNAPSHOT</project.cadiVersion>
- <!-- SONAR -->
- <jacoco.version>0.7.7.201606060606</jacoco.version>
- <sonar.skip>true</sonar.skip>
- <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
- <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
- <!-- Default Sonar configuration -->
- <sonar.jacoco.reportPath>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>
- <sonar.jacoco.itReportPath>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
- <!-- Note: This list should match jacoco-maven-plugin's exclusion list below -->
- <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions>
- <nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-core</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-cass</artifactId>
- <version>${project.version}</version>
- </dependency>
-
-
- <dependency>
- <groupId>org.onap.aaf.cadi</groupId>
- <artifactId>cadi-aaf</artifactId>
- <version>${project.cadiVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>com.google.code.jscep</groupId>
- <artifactId>jscep</artifactId>
- <version>2.4.0</version>
- </dependency>
- <!-- TESTING -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <includes>
- <include>**/*.class</include>
- </includes>
- </configuration>
- <version>2.3.1</version>
- </plugin>
-
- <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
- <configuration>
- <failOnError>false</failOnError>
- </configuration>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.2.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <serverId>ecomp-staging</serverId>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>${jacoco.version}</version>
- <configuration>
- <excludes>
- <exclude>**/gen/**</exclude>
- <exclude>**/generated-sources/**</exclude>
- <exclude>**/yang-gen/**</exclude>
- <exclude>**/pax/**</exclude>
- </excludes>
- </configuration>
- <executions>
-
- <execution>
- <id>pre-unit-test</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>
- <propertyName>surefireArgLine</propertyName>
- </configuration>
- </execution>
-
-
- <execution>
- <id>post-unit-test</id>
- <phase>test</phase>
- <goals>
- <goal>report</goal>
- </goals>
- <configuration>
- <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
- </configuration>
- </execution>
- <execution>
- <id>pre-integration-test</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>
-
- <propertyName>failsafeArgLine</propertyName>
- </configuration>
- </execution>
-
-
- <execution>
- <id>post-integration-test</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>report</goal>
- </goals>
- <configuration>
- <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- <pluginManagement>
- <plugins/>
- </pluginManagement>
- </build>
-<distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>AAF Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>AAF Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
- </snapshotRepository>
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
- </distributionManagement>
-
-</project>
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 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
- ============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.
- *
--->
-<ns2:ManagedResourceList xmlns:ns2="http://scld.att.com/lrm/util" xmlns="http://scld.att.com/lrm/commontypes" xmlns:ns3="http://scld.att.com/lrm/types">
- <ns2:ManagedResource>
- <ResourceDescriptor>
- <ResourceName>com.att.authz._ARTIFACT_ID_</ResourceName>
- <ResourceVersion>
- <Major>_MAJOR_VER_</Major>
- <Minor>_MINOR_VER_</Minor>
- <Patch>_PATCH_VER_</Patch>
- </ResourceVersion>
- <RouteOffer>_ROUTE_OFFER_</RouteOffer>
- </ResourceDescriptor>
- <ResourceType>Java</ResourceType>
- <ResourcePath>com.att.authz.cm.service.CertManAPI</ResourcePath>
- <ResourceProps>
- <Tag>process.workdir</Tag>
- <Value>_ROOT_DIR_</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>jvm.version</Tag>
- <Value>1.8</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>jvm.args</Tag>
- <Value>-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 </Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>jvm.classpath</Tag>
- <Value>_ROOT_DIR_/etc:_ROOT_DIR_/lib/*:</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>jvm.heap.min</Tag>
- <Value>1024m</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>jvm.heap.max</Tag>
- <Value>2048m</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>start.class</Tag>
- <Value>com.att.authz.cm.service.CertManAPI</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>stdout.redirect</Tag>
- <Value>_ROOT_DIR_/logs/SystemOut.log</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>stderr.redirect</Tag>
- <Value>_ROOT_DIR_/logs/SystemErr.log</Value>
- </ResourceProps>
- <ResourceOSID>aft</ResourceOSID>
- <ResourceStartType>AUTO</ResourceStartType>
- <ResourceStartPriority>2</ResourceStartPriority>
- <ResourceMinCount>_RESOURCE_MIN_COUNT_</ResourceMinCount>
- <ResourceMaxCount>_RESOURCE_MAX_COUNT_</ResourceMaxCount>
- <ResourceRegistration>_RESOURCE_REGISTRATION_</ResourceRegistration>
- <ResourceSWMComponent>com.att.authz:_ARTIFACT_ID_</ResourceSWMComponent>
- <ResourceSWMComponentVersion>_ARTIFACT_VERSION_</ResourceSWMComponentVersion>
- </ns2:ManagedResource>
-</ns2:ManagedResourceList>
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<Void> 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<Void> 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<Void> 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<Void> 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<Void> 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<Void> 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<Void> 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<Void> 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<X509Certificate> trustCerts = new ArrayList<X509Certificate>();
- for(Client client : clients) {
- CertStore cs = client.getCaCertificate(MS_PROFILE);
-
- Collection<? extends Certificate> 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;i<bi.length();++i) {
- if(i>1 && 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<? extends Certificate> 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<Client>{
- /**
- * 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<urlstrs.length;++i) {
- String[] info = Split.split('/', urlstrs[i]);
- if(info.length<3) {
- throw new MalformedURLException("Configuration needs LAT and LONG, i.e. ip:port/lat/long");
- }
- client[i] = new Client(new URL(CA_PREFIX + info[0] + CA_POSTFIX),
- new CertificateVerifier() {
- @Override
- public boolean verify(X509Certificate cert) {
- return true;
- }
- }
- );
- double d = GreatCircle.calc(info[1],info[2],localLat,localLong);
- if(d<distance) {
- preferred = i;
- distance=d;
- }
- }
- trans.init().printf("Preferred Certificate Authority is %s",urlstrs[preferred]);
- for(int i=0;i<urlstrs.length;++i) {
- if(i!=preferred) {
- trans.init().printf("Alternate Certificate Authority is %s",urlstrs[i]);
- }
- }
- }
- private Client best() throws ClientException {
- if(failure[preferred]==null) {
- return client[preferred];
- } else {
- Client c=null;
- // See if Alternate available
- for(int i=0;i<failure.length;++i) {
- if(failure[i]==null) {
- c=client[i];
- }
- }
-
- // If not, see if any expirations can be cleared
- Date now = new Date();
- for(int i=0;i<failure.length;++i) {
- if(now.after(failure[i])) {
- failure[i]=null;
- if(c==null) {
- c=client[i];
- }
- }
- }
-
- // if still nothing found, then throw.
- if(c==null) {
- throw new ClientException("No available machines to call");
- }
- return c;
- }
- }
-
- public void invalidate(Client clt) {
- for(int i=0;i<client.length;++i) {
- if(client[i].equals(clt)) {
- failure[i]=new Date(System.currentTimeMillis()+180000 /* 3 mins */);
- }
- }
- }
-
- @Override
- public Iterator<Client> iterator() {
- return new Iterator<Client>() {
- 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<? extends Certificate> certs;
- try {
- certs = Factory.toX509Certificate(bytes);
- } catch (CertificateException e) {
- throw new CertException(e);
- }
- List<String> lTrust = new ArrayList<String>();
- 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<GeneralName> lsan = new ArrayList<GeneralName>();
- 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<args.length;++i) {
- if(args[i].charAt(0)=='-') {
- for(int j=0;j<fld.length;++j) {
- if(fld[j].getType().equals(String.class) && args[i].substring(1).equals(fld[j].getName())) {
- fld[j].set(csr,args[++i]);
- break;
- }
- }
- }
- }
- String errs = validate(csr);
- if(errs!=null) {
- throw new CertException(errs);
- }
- return csr;
- }
-
-
- public static CSRMeta createCSRMeta(CA ca, String mechid, String sponsorEmail, List<String> 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<String> sanList = new ArrayList<String>();
-
- 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<String> 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<String> fqdns;
- // Notify
- public List<String> 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<REQ,CERT,ARTIFACTS,ERROR> {
-
-///////////////////// 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<Void> check(AuthzTrans trans, HttpServletResponse resp, String perm) throws IOException;
-
- /**
- *
- * @return
- */
- public Mapper<REQ,CERT,ARTIFACTS,ERROR> mapper();
-
-///////////////////// STANDARD ELEMENTS //////////////////
-
- /**
- *
- * @param trans
- * @param resp
- * @param rservlet
- * @return
- */
- public abstract Result<Void> requestCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, boolean withTrust);
-
- /**
- *
- * @param trans
- * @param req
- * @param resp
- * @return
- */
- public abstract Result<Void> renewCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, boolean withTrust);
-
- /**
- *
- * @param trans
- * @param req
- * @param resp
- * @return
- */
- public abstract Result<Void> dropCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
-
- /**
- *
- * @param trans
- * @param req
- * @param resp
- * @return
- */
- Result<Void> createArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
-
- /**
- *
- * @param trans
- * @param req
- * @param resp
- * @return
- */
- Result<Void> readArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
-
- /**
- *
- * @param trans
- * @param resp
- * @param mechid
- * @param machine
- * @return
- */
- Result<Void> readArtifacts(AuthzTrans trans, HttpServletResponse resp, String mechid, String machine);
-
- /**
- *
- * @param trans
- * @param req
- * @param resp
- * @return
- */
- Result<Void> updateArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
-
- /**
- *
- * @param trans
- * @param req
- * @param resp
- * @return
- */
- Result<Void> deleteArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
-
- /**
- *
- * @param trans
- * @param resp
- * @param mechid
- * @param machine
- * @return
- */
- Result<Void> 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<BaseRequest,CertInfo, Artifacts, Error> {
- public Facade1_0(CertManAPI certman,
- CMService service,
- Mapper<BaseRequest,CertInfo,Artifacts,Error> 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<REQ,CERT,ARTIFACTS,ERROR> extends org.onap.aaf.authz.layer.FacadeImpl implements Facade<REQ,CERT,ARTIFACTS,ERROR>
- {
- 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<ERROR> errDF;
- private final RosettaDF<REQ> certRequestDF, certRenewDF, certDropDF;
- private final RosettaDF<CERT> certDF;
- private final RosettaDF<ARTIFACTS> artiDF;
- private Mapper<REQ, CERT, ARTIFACTS, ERROR> mapper;
- private Slot sCertAuth;
- private CertManAPI certman;
- private final String voidResp;
-
- public FacadeImpl(CertManAPI certman,
- CMService service,
- Mapper<REQ,CERT,ARTIFACTS,ERROR> 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<REQ,CERT,ARTIFACTS,ERROR> 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<Void> 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<Void> requestCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, boolean withTrust) {
- TimeTaken tt = trans.start(REQUEST_CERT, Env.SUB|Env.ALWAYS);
- try {
- REQ request;
- try {
- Data<REQ> 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<CertResp> rcr = service.requestCert(trans,mapper.toReq(trans,request));
- if(rcr.notOK()) {
- return Result.err(rcr);
- }
-
- CA certAuth = trans.get(sCertAuth,null);
- Result<CERT> rc = mapper.toCert(trans, rcr, withTrust?certAuth.getTrustChain():null);
- switch(rc.status) {
- case OK:
- RosettaData<CERT> 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<Void> renewCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, boolean withTrust) {
- TimeTaken tt = trans.start(RENEW_CERT, Env.SUB|Env.ALWAYS);
- try {
- REQ request;
- try {
- Data<REQ> 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<CertResp> rcr = service.renewCert(trans,mapper.toRenew(trans,request));
- Result<CERT> rc = mapper.toCert(trans, rcr, certman.getTrustChain(certAuth));
-
- switch(rc.status) {
- case OK:
- RosettaData<CERT> 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<Void> dropCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) {
- TimeTaken tt = trans.start(DROP_CERT, Env.SUB|Env.ALWAYS);
- try {
- REQ request;
- try {
- Data<REQ> 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<Void> 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<Void> createArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) {
- TimeTaken tt = trans.start(CREATE_ARTIFACTS, Env.SUB);
- try {
- ARTIFACTS arti;
- try {
- Data<ARTIFACTS> 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<Void> 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<ARTIFACTS> 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<ARTIFACTS> 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<Void> 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<ARTIFACTS> ra = mapper.fromArtifacts(service.readArtifacts(trans,add));
- if(ra.isOK()) {
- RosettaData<ARTIFACTS> 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<Void> updateArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) {
- TimeTaken tt = trans.start(UPDATE_ARTIFACTS, Env.SUB);
- try {
- ARTIFACTS arti;
- try {
- Data<ARTIFACTS> 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<Void> deleteArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) {
- TimeTaken tt = trans.start(DELETE_ARTIFACTS, Env.SUB);
- try {
- ARTIFACTS arti;
- try {
- Data<ARTIFACTS> 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<Void> 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<Void> deleteArtifacts(AuthzTrans trans, HttpServletResponse resp, String mechid, String machine) {
- TimeTaken tt = trans.start(DELETE_ARTIFACTS, Env.SUB);
- try {
- Result<Void> 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<REQ,CERT,ARTIFACTS,ERROR>
-{
- public enum API{ERROR,VOID,CERT,CERT_REQ,CERT_RENEW,CERT_DROP,ARTIFACTS};
-
- public Class<?> getClass(API api);
- public<A> A newInstance(API api);
-
- public ERROR errorFromMessage(StringBuilder holder, String msgID, String text, String... detail);
-
- public Result<CERT> toCert(AuthzTrans trans, Result<CertResp> in, String[] trustChain) throws IOException;
- public Result<CertReq> toReq(AuthzTrans trans, REQ req);
- public Result<CertRenew> toRenew(AuthzTrans trans, REQ req);
- public Result<CertDrop> toDrop(AuthzTrans trans, REQ req);
-
- public List<ArtiDAO.Data> toArtifact(AuthzTrans trans, ARTIFACTS arti);
- public Result<ARTIFACTS> fromArtifacts(Result<List<ArtiDAO.Data>> 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<BaseRequest,CertInfo,Artifacts,Error> {
-
- @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> 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<CertInfo> toCert(AuthzTrans trans, Result<CertResp> 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<CertReq> 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<CertRenew> 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<CertDrop> 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<ArtiDAO.Data> toArtifact(AuthzTrans trans, Artifacts artifacts) {
- List<ArtiDAO.Data> ladd = new ArrayList<ArtiDAO.Data>();
- 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<Artifacts> fromArtifacts(Result<List<Data>> 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<AuthzTrans, ?>[] 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<AuthzTrans, ?>[]) 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<AuthzTrans,?> dao : daos) {
- dao.close(trans);
- }
-
-// sessionFilter.destroy();
- cluster.close();
- }
- });
- }
-
- public Result<CertResp> requestCert(AuthzTrans trans,Result<CertReq> 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<String> notes = null;
- List<String> 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<List<ArtiDAO.Data>> 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<String>();
- 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<String>();}
- 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<CertResp> renewCert(AuthzTrans trans, Result<CertRenew> renew) {
- if(renew.isOK()) {
- return Result.err(Result.ERR_NotImplemented,"Not implemented yet");
- } else {
- return Result.err(renew);
- }
- }
-
- public Result<Void> dropCert(AuthzTrans trans, Result<CertDrop> drop) {
- if(drop.isOK()) {
- return Result.err(Result.ERR_NotImplemented,"Not implemented yet");
- } else {
- return Result.err(drop);
- }
- }
-
- ///////////////
- // Artifact
- //////////////
- public Result<Void> createArtifact(AuthzTrans trans, List<ArtiDAO.Data> 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.renewDays<MIN_RENEWAL) {
- add.renewDays = STD_RENEWAL;
- } else if(add.renewDays>MAX_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<ArtiDAO.Data> 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<List<ArtiDAO.Data>> 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<List<ArtiDAO.Data>> 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<List<ArtiDAO.Data>> 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<List<ArtiDAO.Data>> rv = artiDAO.readByMachine(trans, machine);
- return rv;
- }
-
- public Result<Void> updateArtifact(AuthzTrans trans, List<ArtiDAO.Data> 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.renewDays<MIN_RENEWAL) {
- add.renewDays = STD_RENEWAL;
- } else if(add.renewDays>MAX_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<Void> 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<List<ArtiDAO.Data>> 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<Void> 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<Void> deleteArtifact(AuthzTrans trans, List<ArtiDAO.Data> list) {
- Validator v = new Validator().artisRequired(list, 1);
- if(v.err()) {
- return Result.err(Result.ERR_BadData,v.errs());
- }
-
- try {
- boolean partial = false;
- Result<Void> 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<String> 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<String,CA> certAuths = new TreeMap<String,CA>();
- 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<String, Dated> 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<CA> cac = (Class<CA>)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<params.length;++i) {
- idx = i+1;
- ptype[idx]=String.class;
- pinst[idx]=params[i];
- }
- Constructor<CA> 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<DME2ServletHolder> slist = new ArrayList<DME2ServletHolder>();
- 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<RequestDispatcherType> edlist = EnumSet.of(
- RequestDispatcherType.REQUEST,
- RequestDispatcherType.FORWARD,
- RequestDispatcherType.ASYNC
- );
-
- ///////////////////////
- // Apply Filters
- ///////////////////////
- List<DME2FilterHolder> flist = new ArrayList<DME2FilterHolder>();
-
- // 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<AuthzTrans,Facade1_0> 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 extends Code> 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<String> list, int min) {
- if(list==null) {
- msg(name + IS_NULL);
- } else {
- if(list.size()<min) {
- msg(name + MUST_HAVE_AT_LEAST + min + ENTR + (min==1?Y:IES));
- } else {
- for(String s : list) {
- nullOrBlank("List Item",s);
- }
- }
- }
- return this;
- }
-
- public Validator artisRequired(List<ArtiDAO.Data> list, int min) {
- if(list==null) {
- msg(ARTIFACT_LIST_IS_NULL);
- } else {
- if(list.size()<min) {
- msg(ARTIFACTS_MUST_HAVE_AT_LEAST + min + ENTR + (min==1?Y:IES));
- } else {
- for(ArtiDAO.Data a : list) {
- allRequired(a);
- }
- }
- }
- return this;
- }
-
- public Validator artisKeys(List<ArtiDAO.Data> list, int min) {
- if(list==null) {
- msg(ARTIFACT_LIST_IS_NULL);
- } else {
- if(list.size()<min) {
- msg(ARTIFACTS_MUST_HAVE_AT_LEAST + min + ENTR + (min==1?Y:IES));
- } else {
- for(ArtiDAO.Data a : list) {
- keys(a);
- }
- }
- }
- return this;
- }
-
-
- public Validator keys(ArtiDAO.Data add) {
- if(add==null) {
- msg("Artifact is null.");
- } else {
- nullOrBlank(MECHID, add.mechid);
- nullOrBlank(MACHINE, add.machine);
- }
- return this;
- }
-
- private Validator allRequired(Data a) {
- if(a==null) {
- msg("Artifact is null.");
- } else {
- nullOrBlank(MECHID, a.mechid);
- nullOrBlank(MACHINE, a.machine);
- nullOrBlank("ca",a.ca);
- nullOrBlank("dir",a.dir);
- nullOrBlank("os_user",a.os_user);
- // Note: AppName, Notify & Sponsor are currently not required
- }
- return this;
- }
-
-}
diff --git a/authz-certman/src/test/java/org/onap/aaf/authz/cm/api/JU_API_Artifact.java b/authz-certman/src/test/java/org/onap/aaf/authz/cm/api/JU_API_Artifact.java
deleted file mode 100644
index 96cba46b..00000000
--- a/authz-certman/src/test/java/org/onap/aaf/authz/cm/api/JU_API_Artifact.java
+++ /dev/null
@@ -1,108 +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 static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-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.runners.MockitoJUnitRunner;
-import org.onap.aaf.authz.cm.api.API_Artifact;
-import org.onap.aaf.authz.cm.service.CertManAPI;
-import org.onap.aaf.authz.env.AuthzTrans;
-;
-
-@RunWith(MockitoJUnitRunner.class)
-public class JU_API_Artifact {
-
- @Mock
- private static API_Artifact api;
-
- @Mock
- private static CertManAPI certManApi;
-
- private static CertManAPI noMockAPI;
- private static API_Artifact api_1;
-
- private static HttpServletRequest req;
- private static HttpServletResponse res;
-
- @BeforeClass
- public static void setUp() {
- AuthzTrans trans = mock(AuthzTrans.class);
- req = mock(HttpServletRequest.class);
- trans.setProperty("testTag", "UserValue");
- trans.set(req);
- }
-
- @Rule
- public ExpectedException thrown= ExpectedException.none();
-
- @Test
- public void init_bothValued() {
- try {
- api.init(certManApi);
- } catch (Exception e) {
- thrown.expect(NullPointerException.class);
- e.printStackTrace();
- }
- }
-
- @Test
- public void init_Null_() {
- try {
- api.init(null);
- } catch (Exception e) {
- //thrown.expect(Exception.class);
- e.printStackTrace();
- }
- }
-
- @Test
- public void init_NMC_Null() {
- try {
- api_1.init(null);
- } catch (Exception e) {
- //thrown.expect(NullPointerException.class);
- e.printStackTrace();
- }
- }
-
- @Test
- public void init_NMC() {
- try {
- api_1.init(noMockAPI);
- } catch (Exception e) {
- //thrown.expect(NullPointerException.class);
- e.printStackTrace();
- }
- }
-}
diff --git a/authz-certman/src/test/java/org/onap/aaf/authz/cm/api/JU_API_Cert.java b/authz-certman/src/test/java/org/onap/aaf/authz/cm/api/JU_API_Cert.java
deleted file mode 100644
index 367e5e38..00000000
--- a/authz-certman/src/test/java/org/onap/aaf/authz/cm/api/JU_API_Cert.java
+++ /dev/null
@@ -1,108 +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 static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-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.runners.MockitoJUnitRunner;
-import org.onap.aaf.authz.cm.api.API_Cert;
-import org.onap.aaf.authz.cm.service.CertManAPI;
-import org.onap.aaf.authz.env.AuthzTrans;
-;
-
-@RunWith(MockitoJUnitRunner.class)
-public class JU_API_Cert {
-
- @Mock
- private static API_Cert api;
-
- @Mock
- private static CertManAPI certManApi;
-
- private static CertManAPI noMockAPI;
- private static API_Cert api_1;
-
- private static HttpServletRequest req;
- private static HttpServletResponse res;
-
- @BeforeClass
- public static void setUp() {
- AuthzTrans trans = mock(AuthzTrans.class);
- req = mock(HttpServletRequest.class);
- trans.setProperty("testTag", "UserValue");
- trans.set(req);
- }
-
- @Rule
- public ExpectedException thrown= ExpectedException.none();
-
- @Test
- public void init_bothValued() {
- try {
- api.init(certManApi);
- } catch (Exception e) {
- //thrown.expect(NullPointerException.class);
- e.printStackTrace();
- }
- }
-
- @Test
- public void init_Null_() {
- try {
- api.init(null);
- } catch (Exception e) {
- //thrown.expect(Exception.class);
- e.printStackTrace();
- }
- }
-
- @Test
- public void init_NMC_Null() {
- try {
- api_1.init(null);
- } catch (Exception e) {
- //thrown.expect(NullPointerException.class);
- e.printStackTrace();
- }
- }
-
- @Test
- public void init_NMC() {
- try {
- api_1.init(noMockAPI);
- } catch (Exception e) {
- //thrown.expect(NullPointerException.class);
- e.printStackTrace();
- }
- }
-}
diff --git a/authz-certman/src/test/java/org/onap/aaf/authz/cm/ca/JU_AppCA.java b/authz-certman/src/test/java/org/onap/aaf/authz/cm/ca/JU_AppCA.java
deleted file mode 100644
index c6dd8550..00000000
--- a/authz-certman/src/test/java/org/onap/aaf/authz/cm/ca/JU_AppCA.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.AppCA;
-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_AppCA {
-
- @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 AppCA appCA;
-
- @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);
- appCA = mock(AppCA.class);
- X509Certificate cert = new X509Certificate() {
-
- @Override
- public boolean hasUnsupportedCriticalExtension() {
- return false;
- }
-
- @Override
- public Set<String> getNonCriticalExtensionOIDs() {
-
- return null;
- }
-
- @Override
- public byte[] getExtensionValue(String oid) {
-
- return null;
- }
-
- @Override
- public Set<String> 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<String> getNonCriticalExtensionOIDs() {
-
- return null;
- }
-
- @Override
- public byte[] getExtensionValue(String oid) {
-
- return null;
- }
-
- @Override
- public Set<String> 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<String> fqdnsas = new ArrayList<String>();
- fqdnsas.add("String1");
- List<String> emails = new ArrayList<String>();
- 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<REQ,CERT,ARTIFACTS,ERROR> {
-
- private static AuthzTrans trans;
- private static HttpServletResponse resp;
- private static CertManAPI certman;
- private static FacadeImpl hImpl;
- private static CMService service;
- private Mapper<REQ,CERT,ARTIFACTS,ERROR> 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<Void> 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 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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.
- *
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>parent</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>authz-cmd</artifactId>
- <name>Authz Command</name>
- <description>Command Line Processor for Authz</description>
- <packaging>jar</packaging>
- <url>https://github.com/att/AAF</url>
-
- <developers>
- <developer>
- <name>Jonathan Gathman</name>
- <email></email>
- <organization>ATT</organization>
- <organizationUrl></organizationUrl>
- </developer>
- </developers>
-
- <properties>
- <maven.test.failure.ignore>false</maven.test.failure.ignore>
- <project.swmVersion>21</project.swmVersion>
- <project.cadiVersion>1.0.0-SNAPSHOT</project.cadiVersion>
- <!-- SONAR -->
- <jacoco.version>0.7.7.201606060606</jacoco.version>
- <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
- <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
- <!-- Default Sonar configuration -->
- <sonar.jacoco.reportPath>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>
- <sonar.jacoco.itReportPath>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
- <!-- Note: This list should match jacoco-maven-plugin's exclusion list below -->
- <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions>
- <nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.aaf.cadi</groupId>
- <artifactId>cadi-aaf</artifactId>
- <version>${project.cadiVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-core</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- <version>2.14.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <classifier>tests</classifier>
- <archive>
- <manifestEntries>
- <Sealed>true</Sealed>
- </manifestEntries>
- </archive>
- </configuration>
- <executions>
- <execution>
- <id>full</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>src/main/assemble/authz-cmd.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
- <configuration>
- <failOnError>false</failOnError>
- </configuration>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.2.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <serverId>ecomp-staging</serverId>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>${jacoco.version}</version>
- <configuration>
- <excludes>
- <exclude>**/gen/**</exclude>
- <exclude>**/generated-sources/**</exclude>
- <exclude>**/yang-gen/**</exclude>
- <exclude>**/pax/**</exclude>
- </excludes>
- </configuration>
- <executions>
-
- <execution>
- <id>pre-unit-test</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>
- <propertyName>surefireArgLine</propertyName>
- </configuration>
- </execution>
-
-
- <execution>
- <id>post-unit-test</id>
- <phase>test</phase>
- <goals>
- <goal>report</goal>
- </goals>
- <configuration>
- <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
- </configuration>
- </execution>
- <execution>
- <id>pre-integration-test</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>
-
- <propertyName>failsafeArgLine</propertyName>
- </configuration>
- </execution>
-
-
- <execution>
- <id>post-integration-test</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>report</goal>
- </goals>
- <configuration>
- <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
-
- </plugins>
- <pluginManagement>
- <plugins/>
- </pluginManagement>
- </build>
-<distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>AAF Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>AAF Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
- </snapshotRepository>
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
- </distributionManagement>
-
-</project>
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 @@
-<!--
- ============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.
- *
--->
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
-
- <id>jar-with-dependencies</id>
- <formats>
- <format>jar</format>
- </formats>
-
- <includeBaseDirectory>false</includeBaseDirectory>
- <dependencySets>
- <dependencySet>
- <unpack>true</unpack>
- <scope>compile</scope>
- </dependencySet>
-
- </dependencySets>
- <fileSets>
- <fileSet>
- <directory>src/main/xsd</directory>
- </fileSet>
- <fileSet>
- <directory>etc</directory>
- </fileSet>
- </fileSets>
-</assembly>
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 @@
-<!--
- ============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.
- *
--->
-<assembly>
- <id>swm</id>
- <formats>
- <format>zip</format>
- </formats>
- <baseDirectory>${artifactId}</baseDirectory>
- <fileSets>
- <fileSet>
- <directory>target/swm</directory>
- </fileSet>
- </fileSets>
-</assembly>
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<HttpURLConnection> ss;
- protected AuthzEnv env;
- private boolean close;
- private List<Cmd> cmds;
-
- // Lex State
- private ArrayList<Integer> expect = new ArrayList<Integer>();
- 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<HttpURLConnection> 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<Cmd>();
-
- 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<HttpURLConnection>) 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 <Return> 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<String> arr = new ArrayList<String>();
- 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<HttpURLConnection>) 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<CMD extends Cmd> extends Cmd {
- protected List<Cmd> cmds;
-
- public BaseCmd(AAFcli aafcli, String name, Param ... params) {
- super(aafcli, null, name, params);
- cmds = new ArrayList<Cmd>();
- }
-
- public BaseCmd(CMD parent, String name, Param ... params) {
- super(parent.aafcli, parent, name, params);
- cmds = new ArrayList<Cmd>();
- }
-
-
- @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<DME2Client> {
- 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<Cmd> children;
- private final ConcurrentHashMap<Class<?>,RosettaDF<?>> dfs = new ConcurrentHashMap<Class<?>,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<Cmd>();
- 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<required) {
- throw new CadiException(build(new StringBuilder("Too few args: "),null).toString());
- }
- return _exec(idx,args);
- }
-
- protected abstract int _exec(int idx, final String ... args) throws CadiException, APIException, LocatorException;
-
- public void detailedHelp(int indent,StringBuilder sb) {
- }
-
- protected void detailLine(StringBuilder sb, int length, String s) {
- multiChar(sb,length,' ',0);
- sb.append(s);
- }
-
- public void apis(int indent,StringBuilder sb) {
- }
-
- protected void api(StringBuilder sb, int _indent, HttpMethods hmeth, String pathInfo, Class<?> 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<indent;++i)sb.append(' ');
- for(int i=indent;i<length;++i)sb.append(c);
- }
-
- public StringBuilder build(StringBuilder sb, StringBuilder detail) {
- if(name!=null) {
- sb.append(name);
- sb.append(' ');
- }
- int line = sb.lastIndexOf("\n")+1;
- if(line<0) {
- line=0;
- }
- int indent = sb.length()-line;
- for(Param p : params) {
- sb.append(p.required?'<':'[');
- sb.append(p.tag);
- sb.append(p.required?"> ": "] ");
- }
-
- 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<String> stack = new Stack<String>();
- 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<String> vars = err.getVariables();
- int pipe;
- for (int varCounter=0;varCounter<vars.size();) {
- String var = vars.get(varCounter);
- ++varCounter;
- if (messageBody.indexOf("%" + 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("<html>")){ // 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<T> RosettaDF<T> getDF(Class<T> cls) throws APIException {
- RosettaDF<T> rdf = (RosettaDF<T>)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<lineLength;++i)pw().print('-');
- pw().println();
-
- pw().format(hformat,"Date","Table","User","Memo");
- for(int i=0;i<lineLength;++i)pw().print('-');
- pw().println();
-
- // Save Server time by Sorting locally
- List<Item> items = history.getItem();
- java.util.Collections.sort(items, new Comparator<Item>() {
- @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<options.length;++i) {
- if(options[i].equals(test)) {
- return i;
- }
- }
- throw new CadiException(build(new StringBuilder("Invalid Option: "),null).toString());
- }
-
- protected RosettaEnv env() {
- return aafcli.env;
- }
-
- protected HMangr hman() {
- return aafcli.hman;
- }
-
- public<RET> RET same(Retryable<RET> 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> RET all(Retryable<RET> retryable) throws APIException, CadiException, LocatorException {
- this.setQueryParamsOn(retryable.lastClient);
- return aafcli.hman.all(aafcli.ss,retryable);
- }
-
- public<RET> RET oneOf(Retryable<RET> 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<lineLength;++i)pw().print('-');
- pw().println();
- }
-
- protected void setQueryParamsOn(Rcli<?> 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<Cmd> cmds;
-
- public Help(AAFcli aafcli, List<Cmd> 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 <tag>=<value> - Set any System Property to a new value");
- detailLine(sb,indent,"as <id:password> - Change Credentials. Password may be encrypted");
- detailLine(sb,indent,"expect <int> [int]* - In test mode, check for proper HTTP Status Codes");
- detailLine(sb,indent,"sleep <int> - Wait for <int> 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 + "=<value>\"");
- 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 + "=<value>\"");
- }
-}
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<Mgmt> {
- 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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws APIException, CadiException {
- int rv = 409;
- Future<Void> 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<Mgmt> {
- 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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws APIException, CadiException {
- int rv = 409;
- Future<Void> 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<Mgmt> {
- 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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws APIException, CadiException {
- int rv = 409;
- Future<Void> 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<Mgmt> {
- 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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws APIException, CadiException {
- int rv = 409;
- Future<Void> 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<Mgmt> {
- 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<NS> {
- 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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<Void> 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/<ns>/admin/<id>",Void.class,true);
- api(sb,indent,HttpMethods.DELETE,"authz/ns/<ns>/admin/<id>",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<NS> {
- 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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<Void> 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/<ns>/admin/<id>",Void.class,true);
- api(sb,indent,HttpMethods.DELETE,"authz/ns/<ns>/admin/<id>",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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- // Requestable
- setQueryParamsOn(client);
- Future<NsRequest> 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<Integer>() {
- @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<Void> 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/<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<Integer>() {
- @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<NsRequest> 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<NS> {
-
- 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<Nss> 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<Nss> fp, String ... str) {
- reportHead(str);
- if(fp!=null && fp.value!=null) {
- java.util.List<Ns> nss = fp.value.getNs();
- Collections.sort(nss, new Comparator<Ns>() {
- @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<Roles> 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<Perms> 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<Users> fc) {
- if(fc!=null && fc.value!=null && fc.value.getUser().size()>0) {
- pw().println(" Credentials");
- java.util.List<User> users = fc.value.getUser();
- Collections.sort(users, new Comparator<User>() {
- @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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<History> 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/<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<Integer>() {
- @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<Nss> 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/<admin|responsible>/<user>",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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<Nss> 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<Roles> 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<Perms> 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<Users> 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/<ns>",Nss.class,true);
- detailLine(sb,indent,"Indirectly uses:");
- api(sb,indent,HttpMethods.GET,"authz/roles/ns/<ns>",Roles.class,false);
- api(sb,indent,HttpMethods.GET,"authz/perms/ns/<ns>",Perms.class,false);
- api(sb,indent,HttpMethods.GET,"authn/creds/ns/<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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<Nss> 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/<ns>",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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<Keys> 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/<ns>",Nss.class,true);
- detailLine(sb,indent,"Indirectly uses:");
- api(sb,indent,HttpMethods.GET,"authz/roles/ns/<ns>",Roles.class,false);
- api(sb,indent,HttpMethods.GET,"authz/perms/ns/<ns>",Perms.class,false);
- api(sb,indent,HttpMethods.GET,"authn/creds/ns/<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<List> {
-
- 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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- ((ListUsers)parent).report(HEADER,ns);
- Future<Nss> fn = client.read("/authz/nss/"+ns,getDF(Nss.class));
- if(fn.get(AAFcli.timeout())) {
- if(fn.value!=null) {
- Set<String> uset = detail?null:new HashSet<String>();
- for(Ns n : fn.value.getNs()) {
- Future<Roles> 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<Users> 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/<ns>",Nss.class,true);
- api(sb,indent,HttpMethods.GET,"authz/roles/ns/<ns>",Roles.class,false);
- api(sb,indent,HttpMethods.GET,"authz/users/role/<ns>",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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- ((ListUsers)parent).report(HEADER,ns);
- Future<Nss> fn = client.read("/authz/nss/"+ns,getDF(Nss.class));
- if(fn.get(AAFcli.timeout())) {
- if(fn.value!=null) {
- Set<String> uset = detail?null:new HashSet<String>();
-
- for(Ns n : fn.value.getNs()) {
- Future<Perms> 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<Users> 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/<ns>",Nss.class,true);
- api(sb,indent,HttpMethods.GET,"authz/perms/ns/<ns>",Perms.class,false);
- api(sb,indent,HttpMethods.GET,"authz/users/perm/<type>/<instance>/<action>",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<NS> {
-// 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<NS> {
- 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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<Void> 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/<ns>/responsible/<id>",Void.class,true);
- api(sb,indent,HttpMethods.DELETE,"authz/ns/<ns>/responsible/<id>",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<Integer>() {
- @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<RoleRequest> 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<PermRequest> 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<RoleRequest> 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<Integer>() {
- @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<PermRequest> 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<Integer>() {
- @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<PermRequest> 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<Integer>() {
- @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<RolePermRequest> 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/<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<Perm> {
-// 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<Integer> {
- protected int list(Future<Perms> fp,Rcli<?> client, String header, String parentPerm) throws CadiException, APIException {
- if(fp.get(AAFcli.timeout())) {
- ArrayList<String> permNss = null;
- if (aafcli.isDetailed()) {
- permNss = new ArrayList<String>();
- String permNs = null;
- for(Pkey perm : fp.value.getPerm()) {
- if (permNs != null && perm.getType().contains(permNs)) {
- permNss.add(permNs);
- } else {
- Future<Nss> 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<aaf.v2_0.Perm> permCompare = new Comparator<aaf.v2_0.Perm>() {
- @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<Perms> fp, ArrayList<String> 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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- int idx = index;
- String type = args[idx++];
- Future<History> 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/<type>",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<Perms> 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/<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<Perms> 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/<parent type>",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<Perms> 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/<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<Perms> 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/<user id>",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<Perm> {
- 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<Integer>() {
- @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<PermRequest> 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,"<type> <instance> <action>");
- detailLine(sb,indent,"to:");
- detailLine(sb,indent+2,"<new type> <new instance> <new action>");
- sb.append('\n');
- detailLine(sb,indent,"Namespace must be the same in <type> and <new type>");
- detailLine(sb,indent+4,"see Create for definitions of type,instance and action");
- api(sb,indent,HttpMethods.PUT,"authz/perm/<type>/<instance>/<action>",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<Integer>() {
- @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<RoleRequest> 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<Integer>() {
- @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<RoleRequest> 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<Role> {
- 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<Integer> {
- protected int list(Future<Roles> fp,Rcli<?> client, String header) throws APIException, CadiException {
- if(fp.get(AAFcli.timeout())) {
- Future<Nss> fn = null;
- ArrayList<String> roleNss = null;
- ArrayList<String> permNss = null;
- if (aafcli.isDetailed()) {
- roleNss = new ArrayList<String>();
- permNss = new ArrayList<String>();
- 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<Nss> 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<aaf.v2_0.Role> roleCompare = new Comparator<aaf.v2_0.Role>() {
- @Override
- public int compare(aaf.v2_0.Role a, aaf.v2_0.Role b) {
- return a.getName().compareTo(b.getName());
- }
- };
- public void report(Future<Roles> fp, ArrayList<String> roleNss, ArrayList<String> permNss,
- HashMap<String,Boolean> 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("<No Roles Found>");
- } 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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<History> 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/<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<Roles> 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/<ns>",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<Roles> 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/<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<Roles> 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/<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<Roles> 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/<role>",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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
-
- Future<Roles> fp = client.read(
- "/authz/roles/user/"+fullUser,
- getDF(Roles.class)
- );
- if(fp.get(AAFcli.timeout())) {
- Future<Nss> fn = null;
- ArrayList<String> roleNss = null;
- ArrayList<String> permNss = null;
- HashMap<String, Boolean> expiredMap = new HashMap<String, Boolean>();
- if (aafcli.isDetailed()) {
- roleNss = new ArrayList<String>();
- permNss = new ArrayList<String>();
- 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<Nss> 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<Users> 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/<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<Role> {
- 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<Integer>() {
- @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/<user>/<role>",Void.class,false);
- api(sb,indent,HttpMethods.PUT,"authz/userRole/<role>",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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<CredRequest> 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<User> {
- 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<Integer>() {
- @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<DelgRequest> fp;
- RosettaDF<DelgRequest> 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<User> {
-
- 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<aaf.v2_0.Users.User> sorted = users.getUser();
- Collections.sort(sorted, new Comparator<aaf.v2_0.Users.User>() {
- @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<Approval> lapp = approvals.getApprovals();
- Collections.sort(lapp, new Comparator<Approval>() {
- @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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
-
- Future<History> 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/<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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<Approvals> 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/<value>",Approvals.class,true);
- api(sb,indent,HttpMethods.GET,"authz/approval/approver/<value>",Approvals.class,false);
- api(sb,indent,HttpMethods.GET,"authz/approval/ticket/<value>",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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
-
- Future<Delgs> 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/<id>",Delgs.class,true);
- api(sb,indent,HttpMethods.GET,"authz/delegates/delegate/<id>",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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<Users> 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<User>() {
- @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/<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<Integer>() {
- @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<Users> 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<User>() {
- @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/<type>/<instance>/<action>",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<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<Users> 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<User>() {
- @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/<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<Integer>() {
- @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/<user>/<role>", Void.class, false);
- api(sb, indent, HttpMethods.PUT, "authz/userRole/<user>", 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<User> {
- 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<String> future = new Future<String>() {
-
- @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<String> future = new Future<String>() {
-
- @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 "{<html><code>1</code></html>";
- }
-
- @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<String> future = new Future<String>() {
-
- @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<Cmd> 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 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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.
- *
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>parent</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>authz-core</artifactId>
- <name>Authz Core</name>
- <description>Core Libraries for Authz</description>
- <packaging>jar</packaging>
- <url>https://github.com/att/AAF</url>
-
- <developers>
- <developer>
- <name>Jonathan Gathman</name>
- <email></email>
- <organization>ATT</organization>
- <organizationUrl></organizationUrl>
- </developer>
- </developers>
-<properties>
- <project.cadiVersion>1.0.0-SNAPSHOT</project.cadiVersion>
- <project.innoVersion>1.0.0-SNAPSHOT</project.innoVersion>
- <!-- SONAR -->
- <jacoco.version>0.7.7.201606060606</jacoco.version>
- <sonar.skip>true</sonar.skip>
- <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
- <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
- <!-- Default Sonar configuration -->
- <sonar.jacoco.reportPath>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>
- <sonar.jacoco.itReportPath>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
- <!-- Note: This list should match jacoco-maven-plugin's exclusion list below -->
- <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions>
- <nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath>
-</properties>
- <dependencies>
- <dependency>
- <groupId>org.onap.aaf.inno</groupId>
- <artifactId>env</artifactId>
- <version>${project.innoVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.aaf.inno</groupId>
- <artifactId>log4j</artifactId>
- <version>${project.innoVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.aaf.inno</groupId>
- <artifactId>rosetta</artifactId>
- <version>${project.innoVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.aaf.cadi</groupId>
- <artifactId>cadi-aaf</artifactId>
- <version>${project.cadiVersion}</version>
- <exclusions>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- </exclusions>
-
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- </plugins>
- <pluginManagement>
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
- <configuration>
- <failOnError>false</failOnError>
- </configuration>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.2.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <serverId>ecomp-staging</serverId>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>${jacoco.version}</version>
- <configuration>
- <excludes>
- <exclude>**/gen/**</exclude>
- <exclude>**/generated-sources/**</exclude>
- <exclude>**/yang-gen/**</exclude>
- <exclude>**/pax/**</exclude>
- </excludes>
- </configuration>
- <executions>
-
- <execution>
- <id>pre-unit-test</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>
- <propertyName>surefireArgLine</propertyName>
- </configuration>
- </execution>
-
-
- <execution>
- <id>post-unit-test</id>
- <phase>test</phase>
- <goals>
- <goal>report</goal>
- </goals>
- <configuration>
- <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
- </configuration>
- </execution>
- <execution>
- <id>pre-integration-test</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>
-
- <propertyName>failsafeArgLine</propertyName>
- </configuration>
- </execution>
-
-
- <execution>
- <id>post-integration-test</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>report</goal>
- </goals>
- <configuration>
- <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </pluginManagement>
- </build>
- <distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>AAF Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>AAF Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
- </snapshotRepository>
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
- </distributionManagement>
-
-
-</project>
-
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;i<times.length;++i) {
- if(times[i]>0) {
- if(prev>0) {
- ++count;
- pot += times[i]-prev;
- }
- prev = times[i];
- }
- }
- for(int i=0;i<idx;++i) {
- if(times[i]>0) {
- 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<Object, Object> 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<AuthzTrans> {
- 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<serviceMetric.buckets.length;++i) {
- serviceMetric.buckets[i]+=m.buckets[i];
- }
-
- // Log current info
- sb.append(" Total: ");
- sb.append(m.total);
- sb.append(" Remote: ");
- sb.append(m.buckets[0]);
- sb.append(" JSON: ");
- sb.append(m.buckets[1]);
- trans.info().log(sb);
- } else {
- // IMPORTANT!!! if you add more entries here, change "BUCKETSIZE"!!!
- StringBuilder content = new StringBuilder();
- Metric m = trans.auditTrail(1, content, Env.REMOTE,Env.JSON);
- // Add current Metrics to total metrics
- serviceMetric.total+= m.total;
- for(int i=0;i<serviceMetric.buckets.length;++i) {
- serviceMetric.buckets[i]+=m.buckets[i];
- }
-
- StringBuilder sb = new StringBuilder();
- sb.append("user=");
- Principal p = trans.getUserPrincipal();
- if(p==null) {
- sb.append("n/a");
- } else {
- sb.append(p.getName());
- if(p instanceof TrustPrincipal) {
- sb.append('(');
- sb.append(((TrustPrincipal)p).getOrigName());
- sb.append(')');
- } else {
- sb.append('[');
- if(p instanceof X509Principal) {
- sb.append("x509");
- } else if(p instanceof BasicPrincipal) {
- sb.append("BAth");
- } else {
- sb.append(p.getClass().getSimpleName());
- }
- sb.append(']');
- }
- }
- sb.append(",ip=");
- sb.append(trans.ip());
- sb.append(",port=");
- sb.append(trans.port());
- sb.append(",ms=");
- sb.append(m.total);
- sb.append(",meth=");
- sb.append(trans.meth());
- sb.append(",path=");
- sb.append(trans.path());
-
- Long tsi;
- if((tsi=trans.get(transIDslot, null))!=null) {
- sb.append(",traceID=");
- sb.append(Long.toHexString(tsi));
- }
-
- if(content.length()>0) {
- sb.append(",msg=\"");
- sb.append(content);
- sb.append('"');
- }
-
- trans.warn().log(sb);
- }
- }
-
-}
diff --git a/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransImpl.java b/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransImpl.java
deleted file mode 100644
index 40cdb7f2..00000000
--- a/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransImpl.java
+++ /dev/null
@@ -1,198 +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.authz.org.OrganizationFactory;
-
-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.impl.BasicTrans;
-
-public class AuthzTransImpl extends BasicTrans implements AuthzTrans {
- private static final String TRUE = "true";
- private Principal user;
- private String ip,agent,meth,path;
- private int port;
- private Lur lur;
- private Organization org;
- private String force;
- private boolean futureRequested;
-
- public AuthzTransImpl(AuthzEnv env) {
- super(env);
- ip="n/a";
- org=null;
- }
-
- /**
- * @see org.onap.aaf.authz.env.AuthTrans#set(javax.servlet.http.HttpServletRequest)
- */
- @Override
- public AuthzTrans set(HttpServletRequest req) {
- user = req.getUserPrincipal();
- ip = req.getRemoteAddr();
- port = req.getRemotePort();
- agent = req.getHeader("User-Agent");
- meth = req.getMethod();
- path = req.getPathInfo();
- force = req.getParameter("force");
- futureRequested = TRUE.equalsIgnoreCase(req.getParameter("request"));
- org=null;
- return this;
- }
-
- @Override
- public void setUser(Principal p) {
- user = p;
- }
-
- /**
- * @see org.onap.aaf.authz.env.AuthTrans#user()
- */
- @Override
- public String user() {
- return user==null?"n/a":user.getName();
- }
-
- /**
- * @see org.onap.aaf.authz.env.AuthTrans#getUserPrincipal()
- */
- @Override
- public Principal getUserPrincipal() {
- return user;
- }
-
- /**
- * @see org.onap.aaf.authz.env.AuthTrans#ip()
- */
- @Override
- public String ip() {
- return ip;
- }
-
- /**
- * @see org.onap.aaf.authz.env.AuthTrans#port()
- */
- @Override
- public int port() {
- return port;
- }
-
-
- /* (non-Javadoc)
- * @see org.onap.aaf.authz.env.AuthzTrans#meth()
- */
- @Override
- public String meth() {
- return meth;
- }
-
- /* (non-Javadoc)
- * @see org.onap.aaf.authz.env.AuthzTrans#path()
- */
- @Override
- public String path() {
- return path;
- }
-
- /**
- * @see org.onap.aaf.authz.env.AuthTrans#agent()
- */
- @Override
- public String agent() {
- return agent;
- }
-
- @Override
- public AuthzEnv env() {
- return (AuthzEnv)delegate;
- }
-
- @Override
- public boolean forceRequested() {
- return TRUE.equalsIgnoreCase(force);
- }
-
- public void forceRequested(boolean force) {
- this.force = force?TRUE:"false";
- }
-
- @Override
- public boolean moveRequested() {
- return "move".equalsIgnoreCase(force);
- }
-
- @Override
- public boolean futureRequested() {
- return futureRequested;
- }
-
-
- @Override
- public void setLur(Lur lur) {
- this.lur = lur;
- }
-
- @Override
- public boolean fish(Permission p) {
- if(lur!=null) {
- return lur.fish(user, p);
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.onap.aaf.authz.env.AuthzTrans#org()
- */
- @Override
- public Organization org() {
- if(org==null) {
- try {
- if((org = OrganizationFactory.obtain(env(), user()))==null) {
- org = Organization.NULL;
- }
- } catch (Exception e) {
- org = Organization.NULL;
- }
- }
- return org;
- }
-
- /* (non-Javadoc)
- * @see org.onap.aaf.authz.env.AuthzTrans#logAuditTrailOnly(org.onap.aaf.inno.env.LogTarget)
- */
- @Override
- public void logAuditTrail(LogTarget lt) {
- if(lt.isLoggable()) {
- StringBuilder sb = new StringBuilder();
- auditTrail(1, sb);
- lt.log(sb);
- }
- }
-}
diff --git a/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransOnlyFilter.java b/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransOnlyFilter.java
deleted file mode 100644
index d1be8571..00000000
--- a/authz-core/src/main/java/org/onap/aaf/authz/env/AuthzTransOnlyFilter.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.authz.env;
-
-import java.security.Principal;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
-
-import org.onap.aaf.cssa.rserv.TransOnlyFilter;
-
-import org.onap.aaf.inno.env.Env;
-import org.onap.aaf.inno.env.TimeTaken;
-import org.onap.aaf.inno.env.Trans.Metric;
-
-public class AuthzTransOnlyFilter extends TransOnlyFilter<AuthzTrans> {
- 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<serviceMetric.buckets.length;++i) {
- serviceMetric.buckets[i]+=m.buckets[i];
- }
- // Log current info
- sb.append(" Total: ");
- sb.append(m.total);
- sb.append(" Remote: ");
- sb.append(m.buckets[0]);
- sb.append(" JSON: ");
- sb.append(m.buckets[1]);
- trans.info().log(sb);
- }
-
-}
diff --git a/authz-core/src/main/java/org/onap/aaf/authz/env/NullTrans.java b/authz-core/src/main/java/org/onap/aaf/authz/env/NullTrans.java
deleted file mode 100644
index 62ebe526..00000000
--- a/authz-core/src/main/java/org/onap/aaf/authz/env/NullTrans.java
+++ /dev/null
@@ -1,225 +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.Decryptor;
-import org.onap.aaf.inno.env.Encryptor;
-import org.onap.aaf.inno.env.LogTarget;
-import org.onap.aaf.inno.env.Slot;
-import org.onap.aaf.inno.env.StaticSlot;
-import org.onap.aaf.inno.env.TimeTaken;
-
-/**
- * A NULL implementation of AuthzTrans, for use in DirectAAF Taf/Lurs
- */
-public class NullTrans implements AuthzTrans {
- private static final AuthzTrans singleton = new NullTrans();
-
- public static final AuthzTrans singleton() {
- return singleton;
- }
-
- public void checkpoint(String text) {}
- public void checkpoint(String text, int additionalFlag) {}
- public Metric auditTrail(int indent, StringBuilder sb, int... flag) {return null;}
- public LogTarget fatal() {
- return LogTarget.NULL;
- }
-
- public LogTarget error() {
- return LogTarget.NULL;
- }
-
- public LogTarget audit() {
- return LogTarget.NULL;
- }
-
- /* (non-Javadoc)
- * @see com.att.env.Env#init()
- */
- @Override
- public LogTarget init() {
- return LogTarget.NULL;
- }
-
- public LogTarget warn() {
- return LogTarget.NULL;
- }
-
- public LogTarget info() {
- return LogTarget.NULL;
- }
-
- public LogTarget debug() {
- return LogTarget.NULL;
- }
-
- public LogTarget trace() {
- return LogTarget.NULL;
- }
-
- public TimeTaken start(String name, int flag) {
- return new TimeTaken(name,flag) {
- public void output(StringBuilder sb) {
- sb.append(name);
- sb.append(' ');
- sb.append(millis());
- sb.append("ms");
- }
- };
- }
-
- @Override
- public String setProperty(String tag, String value) {
- return value;
- }
-
- @Override
- public String getProperty(String tag) {
- return tag;
- }
-
- @Override
- public String getProperty(String tag, String deflt) {
- return deflt;
- }
-
- @Override
- public Decryptor decryptor() {
- return null;
- }
-
- @Override
- public Encryptor encryptor() {
- return null;
- }
- @Override
- public AuthzTrans set(HttpServletRequest req) {
- return null;
- }
-
- @Override
- public String user() {
- return null;
- }
-
- @Override
- public Principal getUserPrincipal() {
- return null;
- }
-
- @Override
- public String ip() {
- return null;
- }
-
- @Override
- public int port() {
- return 0;
- }
- @Override
- public String meth() {
- return null;
- }
-
- @Override
- public String path() {
- return null;
- }
-
- @Override
- public void put(Slot slot, Object value) {
- }
- @Override
- public <T> T get(Slot slot, T deflt) {
- return null;
- }
- @Override
- public <T> 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<RV> {
- 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<R> Result<R> ok(R value) {
- return new Result<R>(value,OK,SUCCESS,null);
- }
-
- /**
- * Accept Arrays and mark as empty or not
- * @param value
- * @return
- */
- public static<R> Result<R[]> ok(R value[]) {
- return new Result<R[]>(value,OK,SUCCESS,null).emptyList(value.length==0);
- }
-
- /**
- * Accept Sets and mark as empty or not
- * @param value
- * @return
- */
- public static<R> Result<Set<R>> ok(Set<R> value) {
- return new Result<Set<R>>(value,OK,SUCCESS,null).emptyList(value.size()==0);
- }
-
- /**
- * Accept Lists and mark as empty or not
- * @param value
- * @return
- */
- public static<R> Result<List<R>> ok(List<R> value) {
- return new Result<List<R>>(value,OK,SUCCESS,null).emptyList(value.size()==0);
- }
-
- /**
- * Accept Collections and mark as empty or not
- * @param value
- * @return
- */
- public static<R> Result<Collection<R>> ok(Collection<R> value) {
- return new Result<Collection<R>>(value,OK,SUCCESS,null).emptyList(value.size()==0);
- }
-
-
- /**
- * Special Case for Void Type
- * @return
- */
- public static Result<Void> ok() {
- return new Result<Void>(null,OK,SUCCESS,null);
- }
-
- /**
- * Create a Status (usually non OK, with a details statement
- * @param value
- * @param status
- * @param details
- * @return
- */
-// public static<R> Result<R> err(int status, String details) {
-// return new Result<R>(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<R> Result<R> err(int status, String details, String ... variables) {
- return new Result<R>(null,status,details,variables);
- }
-
- /**
- * Create Error from status and Details of previous Result (and not data)
- * @param pdr
- * @return
- */
- public static<R> Result<R> err(Result<?> pdr) {
- return new Result<R>(null,pdr.status,pdr.details,pdr.variables);
- }
-
- /**
- * Create General Error from Exception
- * @param e
- * @return
- */
- public static<R> Result<R> err(Exception e) {
- return new Result<R>(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<R> Result<R> create(R value, int status, String details, String ... vars) {
- return new Result<R>(value,status,details,vars);
- }
-
- /**
- * Create a Status from a previous status' result/details
- * @param value
- * @param status
- * @param details
- * @return
- */
- public static<R> Result<R> create(R value, Result<?> result) {
- return new Result<R>(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<RV> 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<RV> 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<String> {
- 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()) && begin<end) {
- if(first) {
- trans.warn().log("Waiting for",lockf.getCanonicalPath(),"to close");
- first = false;
- }
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- break;
- }
- begin = System.currentTimeMillis();
- }
- if(exists) {
- throw new IOException(lockf.getCanonicalPath() + "exists. May not open Datafile");
- }
- data.open();
- try {
- ensureIdxGood(trans);
- } catch (IOException e) {
- data.close();
- throw e;
- }
- ti.open();
- opened = true;
-
- } finally {
- tt.done();
- }
- if(!opened) {
- throw new IOException("DataFile pair for " + name + " was not able to be opened in " + timeout + "ms");
- }
- }
-
- private synchronized void ensureIdxGood(AuthzTrans trans) throws IOException {
- if(!idxf.exists() || idxf.length()==0 || dataf.lastModified()>idxf.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<String> {
- 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;++i) {
- if(buff[i]=='\n') {
- end = i;
- next += i+1;
- return true;
- }
- }
- return false;
- }
-
- public IntBuffer getIntBuffer() {
- return ByteBuffer.wrap(buff).asIntBuffer();
- }
-
-
-
- public String toString() {
- return new String(buff,0,end);
- }
- public class Field {
- char delim;
- int idx;
- ByteBuffer bb;
-
- public Field(char delimiter) {
- delim = delimiter;
- idx = 0;
- bb = null;
- }
-
- public Field reset() {
- idx = 0;
- return this;
- }
-
- public String next() {
- if(idx>=end)return null;
- int start = idx;
- byte c=0;
- int endStr = -1;
- while(idx<end && idx<buff.length && (c=buff[idx])!=delim && c!='\n') { // for DOS
- if(c=='\r')endStr=idx;
- ++idx;
- }
-
- if(endStr<0) {
- endStr=idx-start;
- } else {
- endStr=endStr-start;
- }
- ++idx;
- return new String(buff,start,endStr);
- }
-
- public String at(int fieldOffset) {
- int start;
- byte c=0;
- for(int count = idx = start = 0; idx<end && idx<buff.length; ++idx) {
- if((c=buff[idx])==delim || c=='\n') {
- if(count++ == fieldOffset) {
- break;
- }
- start = idx+1;
- }
- }
- return new String(buff,start,(idx-start-(c=='\r'?1:0)));
- }
-
- public String atToEnd(int fieldOffset) {
- int start;
- byte c=0;
- for(int count = idx = start = 0; idx<end && idx<buff.length; ++idx) {
- if((c=buff[idx])==delim || c=='\n') {
- if(count++ == fieldOffset) {
- break;
- }
- start = idx+1;
- }
- }
-
- for(; idx<end && idx<buff.length && (c=buff[idx])!='\n'; ++idx) {
- ++idx;
- }
- return new String(buff,start,(idx-start-((c=='\r' || 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(lhash<hash) {
- min=curr+1;
- } else if(lhash>hash) {
- max=curr-1;
- } else {
- min=curr-40;
- max=curr+40;
- break;
- }
- }
-
- List<Integer> entries = new ArrayList<Integer>();
- 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<Idx> list = new LinkedList<Idx>(); // 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<skipLines;++i) {
- t.nextLine();
- }
- tt2 = trans.start("Read", Env.SUB);
- try {
- while(t.nextLine()) {
- list.add(new Idx(f.at(fieldOffset),t.pos()));
- ++count;
- }
- } finally {
- tt2.done();
- }
- trans.checkpoint(" Read " + count + " records");
- tt2 = trans.start("Sort List", Env.SUB);
- Collections.sort(list);
- tt2.done();
- tt2 = trans.start("Write Idx", Env.SUB);
- try {
- ByteBuffer bb = ByteBuffer.allocate(8*1024);
- IntBuffer ib = bb.asIntBuffer();
- for(Idx idx : list) {
- if(!ib.hasRemaining()) {
- fos.write(bb);
- ib.clear();
- bb.rewind();
- }
- ib.put(idx.hash);
- ib.put(idx.pos);
- }
- bb.limit(4*ib.position());
- fos.write(bb);
- } finally {
- tt2.done();
- }
- } finally {
- fos.close();
- raf.close();
- }
- }
-
- public class Iter {
- private int idx;
- private Token t;
- private long end;
- private IntBuffer ib;
-
-
- public Iter() {
- try {
- idx = 0;
- end = dataFile.size();
- t = dataFile.new Token(REC_SIZE);
- ib = t.getIntBuffer();
-
- } catch (IOException e) {
- end = -1L;
- }
- }
-
- public int next() {
- t.pos(idx);
- ib.clear();
- ib.get();
- int rec = ib.get();
- idx += REC_SIZE;
- return rec;
- }
-
- public boolean hasNext() {
- return idx<end;
- }
- }
-
- private static class Idx implements Comparable<Idx> {
- 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<b?-1:0;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object o) {
- if(o!=null && o instanceof Idx) {
- return hash == ((Idx)o).hash;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return hash;
- }
- }
-}
diff --git a/authz-core/src/main/java/org/onap/aaf/authz/org/EmailWarnings.java b/authz-core/src/main/java/org/onap/aaf/authz/org/EmailWarnings.java
deleted file mode 100644
index 857a9538..00000000
--- a/authz-core/src/main/java/org/onap/aaf/authz/org/EmailWarnings.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.authz.org;
-
-public interface EmailWarnings
-{
- public long credExpirationWarning();
- public long roleExpirationWarning();
- public long credEmailInterval();
- public long roleEmailInterval();
- public long apprEmailInterval();
- public long emailUrgentWarning();
-
-}
diff --git a/authz-core/src/main/java/org/onap/aaf/authz/org/Executor.java b/authz-core/src/main/java/org/onap/aaf/authz/org/Executor.java
deleted file mode 100644
index 14718f7a..00000000
--- a/authz-core/src/main/java/org/onap/aaf/authz/org/Executor.java
+++ /dev/null
@@ -1,35 +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 interface Executor {
- // remove User from user/Role
- // remove user from Admins
- // if # of Owners > 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<String> 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<String> 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<String> toList, List<String> 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<Identity> getApprovers(AuthzTrans trans, String user) throws OrganizationException ;
-
- /*
- *
- * @param user
- * @param type
- * @param users
- * @return
- public Response notifyRequest(AuthzTrans trans, String user, Approval type, List<User> 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<Identity> nullList = new ArrayList<Identity>();
- private final Set<String> nullStringSet = new HashSet<String>();
- private final Identity nullIdentity = new Identity() {
- List<String> nullIdentity = new ArrayList<String>();
- @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<String> 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<String> 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<String> toList, List<String> 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<Identity> 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<String,Organization> orgs = new ConcurrentHashMap<String,Organization>();
- private static Slot orgSlot;
-
- public static void setDefaultOrg(AuthzEnv env, String orgClass) throws APIException {
- orgSlot = env.slot(ORG_SLOT);
- try {
- @SuppressWarnings("unchecked")
- Class<Organization> cls = (Class<Organization>) Class.forName(orgClass);
- Constructor<Organization> 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<Organization> cls = (Class<Organization>) Class.forName(orgClass);
- Constructor<Organization> 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<AuthzTrans> {
- 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> RET clientAsUser(Principal p,Retryable<RET> 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 <TRANS>
- * @param <DATA>
- */
-public class Cache<TRANS extends Trans, DATA> {
- 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<String,Map<String,Dated>> cacheMap;
-
- static {
- cacheMap = new HashMap<String,Map<String,Dated>>();
- }
-
- /**
- * 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 <T> Dated(T t) {
- timestamp = new Date();
- ArrayList<T> al = new ArrayList<T>(1);
- al.add(t);
- data = al;
- }
-
- public void touch() {
- timestamp = new Date();
- }
- }
-
- public static Map<String,Dated> obtain(String key) {
- Map<String, Dated> m = cacheMap.get(key);
- if(m==null) {
- m = new ConcurrentHashMap<String, Dated>();
- 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<String> 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<String>();
- }
-
- 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<String,Dated> map = cacheMap.get(name);
- if(map!=null) for(Map.Entry<String,Dated> 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 <TRANS>
- */
-class Acceptor<TRANS extends Trans> {
- private List<Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>>> types;
- List<Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>>> acceptable;
-
- public Acceptor(List<Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>>> types) {
- this.types = types;
- acceptable = new ArrayList<Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>>>();
- }
-
- private boolean eval(HttpCode<TRANS,?> code, String str, List<String> props) {
-// int plus = str.indexOf('+');
-// if(plus<0) {
- boolean ok = false;
- boolean any = false;
- for(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type : types) {
- ok = true;
- if(type.x.equals(str)) {
- for(Iterator<String> 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<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> 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<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type, String tag, String value) {
- boolean rv = false;
- if(type.y!=null) {
- for(Pair<String,Object> 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<TRANS, ?> code, String cntnt) {
- byte bytes[] = cntnt.getBytes();
-
- int cis,cie=-1,cend;
- int sis,sie,send;
- String name;
- ArrayList<String> props = new ArrayList<String>();
- 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(cis<bytes.length && Character.isSpaceChar(bytes[cis]))++cis;
- cie = cntnt.indexOf(',',cis); // find comma end
- cend = cie<0?bytes.length:cie; // If no comma, set comma end to full length, else cie
- while(cend>cis && Character.isSpaceChar(bytes[cend-1]))--cend;
- // Start SEMIS
- sie=cis-1;
- do {
- sis = sie+1; // semi start is one after previous end
- while(sis<bytes.length && Character.isSpaceChar(bytes[sis]))++sis;
- sie = cntnt.indexOf(';',sis);
- send = sie>cend || 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<send) {
- props.add(new String(bytes,sis,eq-sis));
- props.add(new String(bytes,eq+1,send-(eq+1)));
- }
- }
- // End Property
- } while(sie<=cend && sie>=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<TRANS extends Trans> extends HttpCode<TRANS, Void> {
- public static void setEnv(Store store, String[] args) {
- for(int i=0;i<args.length-1;i+=2) { // cover two parms required for each
- if(CFA_WEB_DIR.equals(args[i])) {
- store.put(store.staticSlot(CFA_WEB_DIR), args[i+1]);
- } else if(CFA_CACHE_CHECK_INTERVAL.equals(args[i])) {
- store.put(store.staticSlot(CFA_CACHE_CHECK_INTERVAL), Long.parseLong(args[i+1]));
- } else if(CFA_MAX_SIZE.equals(args[i])) {
- store.put(store.staticSlot(CFA_MAX_SIZE), Integer.parseInt(args[i+1]));
- }
- }
- }
-
- private static String MAX_AGE = "max-age=3600"; // 1 hour Caching
- private final Map<String,String> typeMap;
- private final NavigableMap<String,Content> content;
- private final Set<String> 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<String,Content>(); // multi-thread changes possible
-
- attachOnly = new HashSet<String>(); // short, unchanged
-
- typeMap = new TreeMap<String,String>(); // 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<String, Content> content;
-
- public Cleanup(NavigableMap<String, Content> content, int size) {
- maxSize = size;
- this.content = content;
- }
-
- private class Comp implements Comparable<Comp> {
- public Map.Entry<String, Content> entry;
-
- public Comp(Map.Entry<String, Content> 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<Comp> scont = new ArrayList<Comp>(size);
- Object[] entries = content.entrySet().toArray();
- for(int i=0;i<size;++i) {
- scont.add(i, new Comp((Map.Entry<String,Content>)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<end;++i) {
- Entry<String, Content> 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<size;++i) {
- Entry<String, Content> 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<TRANS extends Trans> {
- private HttpCode<TRANS,?> 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<TRANS> 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<TRANS,?> 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<TRANS extends Trans> {
- public static final String Q = "q";
- protected abstract Pair<String,Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>> types(HttpCode<TRANS,?> code, String str);
- protected abstract boolean props(Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>> 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<TRANS,?> 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<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> 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<send) {
- String tag = new String(bytes,sis,eq-sis);
- String value = new String(bytes,eq+1,send-(eq+1));
- // trans.checkpoint(" Prop " + tag + "=" + value);
- boolean bool = props(me,tag,value);
- if(!bool) {
- contProp=false;
- }
- }
- }
- // End Property
- } while(sie<=cend && sie>=cis);
- // End SEMIS
- } while(cie>=0);
- return contType && contProp; // for use in finds, True if a type found AND all props matched
- }
-
-}
diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/HttpCode.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/HttpCode.java
deleted file mode 100644
index 49a4ba14..00000000
--- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/HttpCode.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.cssa.rserv;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.onap.aaf.inno.env.Trans;
-
-/**
- * HTTP Code element, which responds to the essential "handle Method".
- *
- * Use Native HttpServletRe[quest|sponse] calls for questions like QueryParameters (getParameter, etc)
- *
- * Use local "pathParam" method to obtain in an optimized manner the path parameter, which must be interpreted by originating string
- *
- * i.e. my/path/:id/:other/*
- *
- *
- * @param <TRANS>
- * @param <T>
- */
-public abstract class HttpCode<TRANS extends Trans, CONTEXT> {
- 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<String, Integer> 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<String,Integer>();
- 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;i<pa.length && !wildcard;++i) {
- if(pa[i].startsWith(":")) {
- if(pa[i].endsWith("*")) {
- val = i | pa.length<<16; // load end value in high order bits
- key = pa[i].substring(0, pa[i].length()-1);// remove *
- wildcard = true;
- } else {
- val = i;
- key = pa[i];
- }
- params.put(key,val); //put in :key
- params.put(key.substring(1,key.length()), val); // put in just key, better than adding a missing one, like Spark
- // values[i]=null; // null stands for Variable
- vars[i]=val;
- } else {
- values[i]=pa[i].getBytes();
- if(pa[i].endsWith("*")) {
- wildcard = true;
- if(pa[i].length()>1) {
- /* 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;i<start;++i) {
- idx = path.indexOf('/',idx+1);
- if(idx<0)break;
- }
- if(i==start) {
- ++idx;
- if(end==0) {
- end = path.indexOf('/',idx);
- if(end<0)end=path.length();
- } else {
- end=path.length();
- }
- return path.substring(idx,end);
- } else if(i==start-1) { // if last spot was left blank, i.e. :key*
- return "";
- }
- }
- return null;
- }
-
- public boolean match(String path) {
- if(path==null|| path.length()==0 || "/".equals(path) ) {
- if(values==null)return true;
- switch(values.length) {
- case 0: return true;
- case 1: return values[0].length==0;
- default: return false;
- }
- }
- boolean rv = true;
- byte[] pabytes = path.getBytes();
- int field=0;
- int fieldIdx = 0;
-
- int lastField = values.length;
- int lastByte = pabytes.length;
- boolean fieldMatched = false; // = lastByte>0?(pabytes[0]=='/'):false;
- // IF DEBUG: System.out.println("\n -- " + path + " --");
- for(int i=0;rv && i<lastByte;++i) {
- if(field>=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; j<end && k<lastByte; ++k) {
- // IF DEBUG: System.out.print((char)pabytes[k]);
- if(pabytes[k]=='/') {
- ++field;
- ++j;
- }
- }
-
- if(k==lastByte && pabytes[k-1]!='/')++field;
- if(k>i)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<lastField;
- // reset
- fieldMatched = false;
- fieldIdx = 0;
- } else if(values[field].length==0) {
- // double slash in path, but content in field. We check specially here to avoid
- // Array out of bounds issues.
- rv = false;
- } else {
- if(fieldMatched) {
- rv =false; // field is already matched, now there's too many bytes
- } else {
- rv = pabytes[i]==values[field][fieldIdx++]; // compare expected (pabytes[i]) with value for particular field
- fieldMatched=values[field].length==fieldIdx; // are all the bytes match in the field?
- if(fieldMatched && (i==lastByte-1 || (wildcard && field==lastField-1)))
- return true; // last field info
- }
- }
- }
- }
- if(field!=lastField || pabytes.length!=lastByte) rv = false; // have we matched all the fields and all the bytes?
- return rv;
- }
-
- public Set<String> 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 <X>
- * @param <Y>
- */
-public class Pair<X,Y> {
- 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<TRANS extends Trans> implements Servlet {
- private Routes<TRANS> routes = new Routes<TRANS>();
-
- 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<TRANS, ?> code, String ... moreTypes) {
- Route<TRANS> 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<TRANS> route;
- HttpCode<TRANS,?> 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<TRANS> codesetter = new CodeSetter<TRANS>(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> 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<TRANS extends Trans> {
- public final String auditText;
- public final HttpMethods meth;
- public final String path;
-
- private Match match;
- // package on purpose
- private final TypedCode<TRANS> 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<TRANS>();
- }
-
- public void add(HttpCode<TRANS,?> code, String ... others) {
- code.match = match;
- content.add(code, others);
- }
-
-// public void add(HttpCode<TRANS,?> code, Class<?> cls, String version, String ... others) {
-// code.match = match;
-// content.add(code, cls, version, others);
-// }
-//
- public HttpCode<TRANS,?> 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<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> 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<TRANS> matches(String method, String path) {
- return meth.name().equalsIgnoreCase(method) && match.match(path)?this:null;
- }
-
- public TimeTaken start(Trans trans, String auditText, HttpCode<TRANS,?> 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<TRANS, ?> 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<TRANS, ?> 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<String> contextTypes = new ArrayList<String>();
-
-}
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<TRANS extends Trans> {
- // Since this must be very, very fast, and only needs one creation, we'll use just an array.
- private Route<TRANS>[] 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<TRANS> findOrCreate(HttpMethods meth, String path) {
- Route<TRANS> rv = null;
- for(int i=0;i<end;++i) {
- if(routes[i].resolvesTo(meth,path))rv = routes[i];
- }
-
- if(rv==null) {
- if(end>=routes.length) {
- @SuppressWarnings("unchecked")
- Route<TRANS>[] temp = new Route[end+10];
- System.arraycopy(routes, 0, temp, 0, routes.length);
- routes = temp;
- }
-
- routes[end++]=rv=new Route<TRANS>(meth,path);
- }
- return rv;
- }
-
- public Route<TRANS> derive(HttpServletRequest req, CodeSetter<TRANS> codeSetter) throws IOException, ServletException {
- Route<TRANS> rv = null;
- String path = req.getPathInfo();
- String meth = req.getMethod();
- //TODO a TREE would be better
- for(int i=0;rv==null && i<end; ++i) {
- rv = routes[i].matches(meth,path);
- if(rv!=null && !codeSetter.matches(rv)) { // potential match, check if has Code
- rv = null; // not quite, keep going
- }
- }
- //TODO a Default?
- return rv;
- }
-
- public List<RouteReport> routeReport() {
- ArrayList<RouteReport> ltr = new ArrayList<RouteReport>();
- for(int i=0;i<end;++i) {
- ltr.add(routes[i].api());
- }
- return ltr;
- }
-}
diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/TransFilter.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/TransFilter.java
deleted file mode 100644
index f7fa997b..00000000
--- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/TransFilter.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.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 javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.onap.aaf.cadi.Access;
-import org.onap.aaf.cadi.CadiException;
-import org.onap.aaf.cadi.CadiWrap;
-import org.onap.aaf.cadi.Connector;
-import org.onap.aaf.cadi.Lur;
-import org.onap.aaf.cadi.TrustChecker;
-import org.onap.aaf.cadi.filter.CadiHTTPManip;
-import org.onap.aaf.cadi.taf.TafResp;
-import org.onap.aaf.cadi.taf.TafResp.RESP;
-import org.onap.aaf.inno.env.Env;
-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 TransFilter<TRANS extends TransStore> 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<TRANS extends TransStore> 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 <TRANS>
- */
-public class TypedCode<TRANS extends Trans> extends Content<TRANS> {
- private List<Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String, Object>>>>> types;
-
- public TypedCode() {
- types = new ArrayList<Pair<String,Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>>>();
- }
-
- /**
- * Construct Typed Code based on ContentType parameters passed in
- *
- * @param code
- * @param others
- * @return
- */
- public TypedCode<TRANS> add(HttpCode<TRANS,?> 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<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> types(HttpCode<TRANS,?> code, String str) {
- Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String, Object>>>> type = null;
- ArrayList<Pair<String, Object>> props = new ArrayList<Pair<String,Object>>();
- // Want Q percentage is to be first in the array everytime. If not listed, 1.0 is default
- props.add(new Pair<String,Object>(Q,1f));
- Pair<HttpCode<TRANS,?>, List<Pair<String,Object>>> cl = new Pair<HttpCode<TRANS,?>, List<Pair<String,Object>>>(code, props);
-// // breakup "plus" stuff, i.e. application/xaml+xml
-// int plus = str.indexOf('+');
-// if(plus<0) {
- type = new Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>>(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<String, Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>>(nstr, cl);
-// types.add(type);
-// prev = plus+1;
-// plus = str.indexOf('+',prev);
-// }
-// return type;
-// }
- }
-
- @Override
- protected boolean props(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> 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<String,Object>(tag,"version".equals(tag)?new Version(value):value));
- }
-
- public Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> prep(TRANS trans, String compare) throws IOException, ServletException {
- Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> 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<TRANS> acc = new Acceptor<TRANS>(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<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> bestT = null;
- for(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> 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<TRANS,?>
-// 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<TRANS, ?> code, StringBuilder sb) {
- boolean first = true;
- for(Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> pair : types) {
- if(code==null || pair.y.x == code) {
- if(first) {
- first = false;
- } else {
- sb.append(',');
- }
- sb.append(pair.x);
- for(Pair<String,Object> 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<Pair<String, Object>> getContent(HttpCode<TRANS,?> code) {
- for(Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> 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<HttpCode<?,?>,StringBuilder> psb = new HashMap<HttpCode<?,?>,StringBuilder>();
- StringBuilder temp;
- tr.desc = null;
-
- // Read through Code/TypeCode trees for all accepted Typecodes
- for(Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> 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<String, Object> 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<length;++i) { // match on declared parts
- if(i==1) {
- if(parts[1] instanceof Integer && ver.parts[1] instanceof Integer) {
- // Match on Minor version if this Version is less than Version to be checked
- if(((Integer)parts[1])<((Integer)ver.parts[1])) {
- return false;
- }
- continue; // don't match next line
- }
- }
- if(!parts[i].equals(ver.parts[i])) {
- return false; // other spots exact match
- }
- }
- return true;
- }
- return false;
- }
-
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return super.hashCode();
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- for(Object obj : parts) {
- if(first) {
- first = false;
- } else {
- sb.append('.');
- }
- sb.append(obj.toString());
- }
- return sb.toString();
- }
-}
diff --git a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/doc/ApiDoc.java b/authz-core/src/main/java/org/onap/aaf/cssa/rserv/doc/ApiDoc.java
deleted file mode 100644
index b95b3835..00000000
--- a/authz-core/src/main/java/org/onap/aaf/cssa/rserv/doc/ApiDoc.java
+++ /dev/null
@@ -1,42 +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.doc;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.onap.aaf.cssa.rserv.HttpMethods;
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
-public @interface ApiDoc {
- HttpMethods method();
- String path();
- int expectedCode();
- int[] errorCodes();
- String[] text();
- /** Format with name|type|[true|false] */
- String[] params();
-
-}
diff --git a/authz-core/src/test/java/org/onap/aaf/authz/common/JU_Define.java b/authz-core/src/test/java/org/onap/aaf/authz/common/JU_Define.java
deleted file mode 100644
index 9415c7cc..00000000
--- a/authz-core/src/test/java/org/onap/aaf/authz/common/JU_Define.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.authz.common;
-
-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.authz.common.Define;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import org.onap.aaf.cadi.CadiException;
-import org.onap.aaf.cadi.config.Config;
-import org.onap.aaf.inno.env.Env;
-
-@RunWith(PowerMockRunner.class)
-public class JU_Define {
- Define define;
- public static String ROOT_NS="NS.Not.Set";
- public static String ROOT_COMPANY=ROOT_NS;
-
- @Mock
- Env envMock;
-
-
- @Before
- public void setUp(){
- define = new Define();
- }
-
- @Test
- public void testSet() throws CadiException {
- PowerMockito.when(envMock.getProperty(Config.AAF_ROOT_NS)).thenReturn("aaf_root_ns");
- PowerMockito.when(envMock.getProperty(Config.AAF_ROOT_COMPANY)).thenReturn("aaf_root_company");
- //PowerMockito.when(envMock.init().log()).thenReturn(null);
- //PowerMockito.doNothing().doThrow(new CadiException()).when(envMock).init().log(Matchers.anyString());
- //define.set(envMock);
- }
-
-}
diff --git a/authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzEnv.java b/authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzEnv.java
deleted file mode 100644
index 937b03dc..00000000
--- a/authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzEnv.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.authz.env;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-
-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.powermock.modules.junit4.PowerMockRunner;
-
-import org.onap.aaf.cadi.Access.Level;
-
-@RunWith(PowerMockRunner.class)
-public class JU_AuthzEnv {
- private static final org.onap.aaf.cadi.Access.Level DEBUG = null;
- AuthzEnv authzEnv;
- enum Level {DEBUG, INFO, AUDIT, INIT, WARN, ERROR};
-
- @Before
- public void setUp(){
- authzEnv = new AuthzEnv();
- }
-
- @Test
- public void testTransRate() {
- Long Result = authzEnv.transRate();
- System.out.println("value of result " +Result); //Expected 300000
- assertNotNull(Result);
- }
-
- @Test(expected = IOException.class)
- public void testDecryptException() throws IOException{
- String encrypted = null;
- authzEnv.decrypt(encrypted, true);
- }
-
- @Test
- public void testDecrypt() throws IOException{
- String encrypted = "encrypted";
- String Result = authzEnv.decrypt(encrypted, true);
- System.out.println("value of res " +Result);
- assertEquals("encrypted",Result);
- }
-
-}
diff --git a/authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransFilter.java b/authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransFilter.java
deleted file mode 100644
index 1a15da18..00000000
--- a/authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransFilter.java
+++ /dev/null
@@ -1,83 +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 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.env.AuthzTrans;
-import org.onap.aaf.authz.env.AuthzTransFilter;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import org.onap.aaf.cadi.CadiException;
-import org.onap.aaf.cadi.Connector;
-import org.onap.aaf.cadi.TrustChecker;
-
-@RunWith(PowerMockRunner.class)
-public class JU_AuthzTransFilter {
-AuthzTransFilter authzTransFilter;
-@Mock
-AuthzEnv authzEnvMock;
-@Mock
-Connector connectorMock;
-@Mock
-TrustChecker trustCheckerMock;
-@Mock
-AuthzTrans authzTransMock;
-Object additionalTafLurs;
-
- @Before
- public void setUp(){
- try {
- authzTransFilter = new AuthzTransFilter(authzEnvMock, connectorMock, trustCheckerMock, additionalTafLurs);
- } catch (CadiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void test()
- {
- //authzTransFilter.newTrans();
- assertTrue(true);
- }
-
- @Test
- public void testTallyHo(){
- PowerMockito.when(authzTransMock.info().isLoggable()).thenReturn(true);
- //if(trans.info().isLoggable())
- authzTransFilter.tallyHo(authzTransMock);
-
- }
-
-
-// AuthzTrans at = env.newTrans();
-// at.setLur(getLur());
-// return at
-}
diff --git a/authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransImpl.java b/authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransImpl.java
deleted file mode 100644
index 901f94ee..00000000
--- a/authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransImpl.java
+++ /dev/null
@@ -1,75 +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 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.env.AuthzTransImpl;
-import org.onap.aaf.authz.org.Organization;
-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.LogTarget;
-
-@RunWith(PowerMockRunner.class)
-public class JU_AuthzTransImpl {
-
- AuthzTransImpl authzTransImpl;
- @Mock
- AuthzEnv authzEnvMock;
-
- private Organization org=null;
-
- @Before
- public void setUp(){
- authzTransImpl = new AuthzTransImpl(authzEnvMock);
-
- }
-
- @Test
- public void testOrg(){
- Organization result=null;
- result = authzTransImpl.org();
- System.out.println("value of Organization " + result);
- //assertTrue(true);
- }
-
- @Mock
- LogTarget logTargetMock;
-
- @Test
- public void testLogAuditTrail(){
-
- PowerMockito.when(logTargetMock.isLoggable()).thenReturn(false);
- authzTransImpl.logAuditTrail(logTargetMock);
-
- assertTrue(true);
- }
-
-}
diff --git a/authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransOnlyFilter.java b/authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransOnlyFilter.java
deleted file mode 100644
index d55a6342..00000000
--- a/authz-core/src/test/java/org/onap/aaf/authz/env/JU_AuthzTransOnlyFilter.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.env;
-
-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.runners.MockitoJUnitRunner;
-import org.onap.aaf.authz.env.AuthzEnv;
-import org.onap.aaf.authz.env.AuthzTransOnlyFilter;
-
-@RunWith(MockitoJUnitRunner.class)
-public class JU_AuthzTransOnlyFilter {
- AuthzTransOnlyFilter authzTransOnlyFilter;
- @Mock
- AuthzEnv authzEnvMock;
-
- @Before
- public void setUp(){
- authzTransOnlyFilter = new AuthzTransOnlyFilter(authzEnvMock);
- }
-
- @Test
- public void test() {
- assertTrue(true);
- }
-
-}
diff --git a/authz-core/src/test/java/org/onap/aaf/authz/env/JU_NullTrans.java b/authz-core/src/test/java/org/onap/aaf/authz/env/JU_NullTrans.java
deleted file mode 100644
index 5ee70669..00000000
--- a/authz-core/src/test/java/org/onap/aaf/authz/env/JU_NullTrans.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.env;
-
-import static org.junit.Assert.*;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.aaf.authz.env.NullTrans;
-
-@RunWith(MockitoJUnitRunner.class)
-public class JU_NullTrans {
- NullTrans nullTrans;
-
- @Before
- public void setUp(){
- nullTrans = new NullTrans();
- }
-
- @Test
- public void test() {
- assertTrue(true);
- }
-
-}
diff --git a/authz-core/src/test/java/org/onap/aaf/authz/layer/JU_Result.java b/authz-core/src/test/java/org/onap/aaf/authz/layer/JU_Result.java
deleted file mode 100644
index e276e688..00000000
--- a/authz-core/src/test/java/org/onap/aaf/authz/layer/JU_Result.java
+++ /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.
- * *
- ******************************************************************************/
-package org.onap.aaf.authz.layer;
-
-import static org.junit.Assert.*;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.onap.aaf.authz.layer.Result;
-
-public class JU_Result {
- Result result;
-// @Mock
-// RV value;
- int status=0;
- String details = "details";
- String[] variables;
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Before
- public void setUp(){
- result = new Result(result, status, details, variables);
- }
-
- @Test
- public void testPartialContent() {
- Result Res = result.partialContent(true);
- System.out.println("Res" +Res);
- assertEquals(details,Res.toString());
-
- }
-
-}
diff --git a/authz-core/src/test/java/org/onap/aaf/authz/local/JU_DataFile.java b/authz-core/src/test/java/org/onap/aaf/authz/local/JU_DataFile.java
deleted file mode 100644
index a5321c51..00000000
--- a/authz-core/src/test/java/org/onap/aaf/authz/local/JU_DataFile.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.authz.local;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.AfterClass;
-import org.junit.Test;
-import org.onap.aaf.authz.local.DataFile;
-import org.onap.aaf.authz.local.DataFile.Token;
-import org.onap.aaf.authz.local.DataFile.Token.Field;
-
-public class JU_DataFile {
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Test
- public void test() throws Exception {
- File file = new File("../authz-batch/data/v1.dat");
- DataFile df = new DataFile(file,"r");
- int count = 0;
- List<String> list = new ArrayList<String>();
- 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<Trans> codeSetterMock;
- Route<Trans> 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("<pass>/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<TransJAXB, String> cBool = new HttpCode<TransJAXB,String>(BOOL,"Standard String") {
- @Override
- public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) {
- try {
- resp.getOutputStream().write(context.getBytes());
- } catch (IOException e) {
- }
- }
- };
-
- HttpCode<TransJAXB,String> cXML = new HttpCode<TransJAXB,String>(XML, "Standard String") {
- @Override
- public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) {
- try {
- resp.getOutputStream().write(context.getBytes());
- } catch (IOException e) {
- }
- }
- };
-
- TypedCode<TransJAXB> ct = new TypedCode<TransJAXB>()
- .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 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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.
- *
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>parent</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>authz-defOrg</artifactId>
- <name>Default Organization</name>
- <description>Example Organization Module</description>
- <packaging>jar</packaging>
- <url>https://github.com/att/AAF</url>
-
- <developers>
- <developer>
- <name>Jonathan Gathman</name>
- <email></email>
- <organization>ATT</organization>
- <organizationUrl></organizationUrl>
- </developer>
- </developers>
-
- <properties>
- <maven.test.failure.ignore>false</maven.test.failure.ignore>
- <project.swmVersion>0</project.swmVersion>
- <project.cadiVersion>1.0.0-SNAPSHOT</project.cadiVersion>
- <project.innoVersion>1.0.0-SNAPSHOT</project.innoVersion>
- <!-- SONAR -->
- <jacoco.version>0.7.7.201606060606</jacoco.version>
- <sonar.skip>true</sonar.skip>
- <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
- <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
- <!-- Default Sonar configuration -->
- <sonar.jacoco.reportPath>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>
- <sonar.jacoco.itReportPath>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
- <!-- Note: This list should match jacoco-maven-plugin's exclusion list below -->
- <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions>
- <nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath>
-</properties>
-
-
- <dependencies>
- <dependency>
- <groupId>org.onap.aaf.cadi</groupId>
- <artifactId>cadi-core</artifactId>
- <version>${project.cadiVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-core</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
- <configuration>
- <failOnError>false</failOnError>
- </configuration>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <serverId>ecomp-staging</serverId>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>${jacoco.version}</version>
- <configuration>
- <excludes>
- <exclude>**/gen/**</exclude>
- <exclude>**/generated-sources/**</exclude>
- <exclude>**/yang-gen/**</exclude>
- <exclude>**/pax/**</exclude>
- </excludes>
- </configuration>
- <executions>
-
- <execution>
- <id>pre-unit-test</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>
- <propertyName>surefireArgLine</propertyName>
- </configuration>
- </execution>
-
-
- <execution>
- <id>post-unit-test</id>
- <phase>test</phase>
- <goals>
- <goal>report</goal>
- </goals>
- <configuration>
- <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
- </configuration>
- </execution>
- <execution>
- <id>pre-integration-test</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>
-
- <propertyName>failsafeArgLine</propertyName>
- </configuration>
- </execution>
-
-
- <execution>
- <id>post-integration-test</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>report</goal>
- </goals>
- <configuration>
- <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </pluginManagement>
- </build>
- <distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>AAF Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>AAF Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
- </snapshotRepository>
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
- </distributionManagement>
-
-
-</project>
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<String> NULL_DELEGATES = new ArrayList<String>();
-
- public Identities identities;
- private boolean dryRun;
- private Session session;
- public enum Types {Employee, Contractor, Application, NotActive};
- private final static Set<String> typeSet;
-
- static {
- typeSet = new HashSet<String>();
- 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<String> 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<String> toList = new ArrayList<String>();
- 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<String> ccList = new ArrayList<String>();
-
- // If we're sending an urgent email, CC the user's supervisor
- //
- if (urgent) {
- trans.info().log("urgent msg for: " + identities[0]);
- try {
- List<Identity> 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<String> toList, List<String> ccList, String subject, String body,
- Boolean urgent) throws OrganizationException {
- int status = 1;
-
- List<String> to = new ArrayList<String>();
- for(String em : toList) {
- if(em.indexOf('@')<0) {
- to.add(new DefaultOrgIdentity(trans, em, this).email());
- } else {
- to.add(em);
- }
- }
-
- List<String> cc = new ArrayList<String>();
- 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<String> newBody = new ArrayList<String>();
-
- 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<Identity> getApprovers(AuthzTrans trans, String user) throws OrganizationException {
- Identity orgIdentity = getIdentity(trans, user);
- List<Identity> orgIdentitys = new ArrayList<Identity>();
- 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<String> 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<String> 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<String> 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<String> 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
--- a/authz-defOrg/src/test/resources/test.txt
+++ /dev/null
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 @@
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
+ <artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
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<HttpURLConnection>(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<headers.length;i=i+2) {
- if(headers[i-1].equals(name)) return headers[i];
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public Enumeration getHeaders(String name) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public Enumeration getHeaderNames() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int getIntHeader(String name) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public String getMethod() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getPathInfo() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getPathTranslated() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getContextPath() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getQueryString() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getRemoteUser() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean isUserInRole(String role) {
- // TODO Auto-generated method stub
- return false;
- }
-
- public Principal getUserPrincipal() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getRequestedSessionId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getRequestURI() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public StringBuffer getRequestURL() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getServletPath() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public HttpSession getSession(boolean create) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public HttpSession getSession() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean isRequestedSessionIdValid() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isRequestedSessionIdFromCookie() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isRequestedSessionIdFromURL() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isRequestedSessionIdFromUrl() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public ServletContext getServletContext() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public AsyncContext startAsync() throws IllegalStateException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public AsyncContext startAsync(ServletRequest servletRequest,
- ServletResponse servletResponse) throws IllegalStateException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isAsyncStarted() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean isAsyncSupported() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public AsyncContext getAsyncContext() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public DispatcherType getDispatcherType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean authenticate(HttpServletResponse response)
- throws IOException, ServletException {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public void login(String username, String password)
- throws ServletException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void logout() throws ServletException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public Collection<Part> 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 @@
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
+ <artifactId>servlet-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
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 @@
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
+ <artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
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 @@
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.0.1</version>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
</dependency>
<dependency>
diff --git a/pom.xml b/pom.xml
index ba5bab1b..ece3cd2a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,548 +1,62 @@
<!--
- ============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.
- *
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 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====================================================
+ *
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
<modelVersion>4.0.0</modelVersion>
- <groupId>org.onap.aaf.authz</groupId>
+ <groupId>osaaf</groupId>
<artifactId>parent</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <name>aaf-authz</name>
+ <version>2.1.0-SNAPSHOT</version>
+ <name>AAF Overall Parent</name>
<packaging>pom</packaging>
- <url>https://github.com/att/AAF</url>
-
- <parent>
- <groupId>org.onap.oparent</groupId>
- <artifactId>oparent</artifactId>
- <version>1.1.0</version>
- </parent>
-
-
- <developers>
- <developer>
- <name>Jonathan Gathman</name>
- <email></email>
- <organization>ATT</organization>
- <organizationUrl></organizationUrl>
- </developer>
- </developers>
- <description>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.
- </description>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <skipTests>false</skipTests>
- <project.interfaceVersion>1.0.0-SNAPSHOT</project.interfaceVersion>
- <project.innoVersion>1.0.0-SNAPSHOT</project.innoVersion>
- <project.cadiVersion>1.0.0-SNAPSHOT</project.cadiVersion>
- <project.dme2Version>3.1.200</project.dme2Version>
- <!-- SONAR -->
- <jacoco.version>0.7.7.201606060606</jacoco.version>
- <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
- <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
- <!-- Default Sonar configuration -->
- <sonar.jacoco.reportPath>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>
- <sonar.jacoco.itReportPath>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
- <!-- Note: This list should match jacoco-maven-plugin's exclusion list below -->
- <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions>
- <nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath>
- </properties>
<build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.17</version>
- <configuration>
- <skipTests>${skipTests}</skipTests>
- <includes>
- <include>**/JU*.java</include>
- </includes>
- <excludes>
-
- <exclude>**/JU_DataFile.java</exclude>
- <exclude>**/JU_ArtiDAO.java</exclude>
- <exclude>**/JU_CertDAO.java</exclude>
- <exclude>**/JU_FastCalling.java</exclude>
- <exclude>**/JU_NsDAO.java</exclude>
- <!-- <exclude>**/authz-cass/**</exclude> -->
- <!-- <exclude>**/JU_UseCase1.java</exclude> -->
- <exclude>**/JU_RoleDAO.java</exclude>
- <exclude>**/JU_PermDAO.java</exclude>
- <exclude>**/JU_Question.java</exclude>
- <!-- <exclude>**/JU_NS.java</exclude> -->
- <exclude>**/JU_HistoryDAO.java</exclude>
- <exclude>**/JU_DelegateDAO.java</exclude>
- <exclude>**/JU_CredDAO.java</exclude>
- <exclude>**/JU_CacheInfoDAO.java</exclude>
- <exclude>**/JU_ApprovalDAO.java</exclude>
- <!-- <exclude>**/JU_Define.java</exclude> -->
- <exclude>**/JU_Identities.java</exclude>
- <exclude>**/JU_AuthzTransFilter.java</exclude>
- <exclude>**/JU_CachingFileAccess.java</exclude>
- <!-- <exclude>**/AbsServiceTest.java</exclude> -->
- <!-- <exclude>**/JU_DefaultOrg.java</exclude> -->
- <exclude>**/JU_FileServer.java</exclude>
- <exclude>**/JU_DirectAAFLur.java</exclude>
- <exclude>**/JU_AuthAPI.java</exclude>
- <exclude>**/JU_GwAPI.java</exclude>
- <exclude>**/JU_NsDAO.java</exclude>
- <exclude>**/JU_Delete.java</exclude>
- <exclude>**/JU_Create.java</exclude>
- <exclude>**/JU_Admin.java</exclude>
- <exclude>**/JU_Attrib.java</exclude>
- <exclude>**/JU_Describe.java</exclude>
- <exclude>**/JU_ListUsersInRole.java</exclude>
- <exclude>**/JU_ListUsersWithPerm.java</exclude>
- <exclude>**/JU_Responsible.java</exclude>
-
-
-
-
- <!-- <exclude>**/JU_Perm_2_0*.java</exclude> -->
- <!-- <exclude>**/JU_Role_2_0*.java</exclude> -->
-
- </excludes>
-
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jaxb2-maven-plugin</artifactId>
- <version>1.3</version>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>xjc</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <schemaDirectory>src/main/xsd</schemaDirectory>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <version>2.17</version>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
- <executions>
- <execution>
- <id>integration-test</id>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jarsigner-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <id>sign</id>
- <goals>
- <goal>sign</goal>
- </goals>
- <configuration>
- <!-- skip>${skipSigning}</skip -->
- <archive>target/${project.artifactId}-${project.version}.jar</archive>
- </configuration>
- </execution>
- <execution>
- <id>verify</id>
- <goals>
- <goal>verify</goal>
- </goals>
- <configuration>
- <archive>target/${project.artifactId}-${project.version}.jar</archive>
- </configuration>
- </execution>
- </executions>
- <configuration>
- <skip>true</skip>
- <alias>aaf</alias>
- <keystore>/Volumes/Data/src/cadi/keys/aaf_cadi.jks</keystore>
- <storepass>Surprise!</storepass>
- <keypass>Surprise!</keypass>
- <verbose>true</verbose>
- <certs>true</certs>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
- <configuration>
- <failOnError>false</failOnError>
- </configuration>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.2.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.7</version>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
<configuration>
- <formats>
- <format>html</format>
- <format>xml</format>
- </formats>
+ <skip>true</skip>
</configuration>
</plugin>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <serverId>ecomp-staging</serverId>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>${jacoco.version}</version>
- <configuration>
- <excludes>
- <exclude>**/gen/**</exclude>
- <exclude>**/generated-sources/**</exclude>
- <exclude>**/yang-gen/**</exclude>
- <exclude>**/pax/**</exclude>
- </excludes>
- </configuration>
- <executions>
-
- <execution>
- <id>pre-unit-test</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>
- <propertyName>surefireArgLine</propertyName>
- </configuration>
- </execution>
-
-
- <execution>
- <id>post-unit-test</id>
- <phase>test</phase>
- <goals>
- <goal>report</goal>
- </goals>
- <configuration>
- <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
- </configuration>
- </execution>
- <execution>
- <id>pre-integration-test</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>
-
- <propertyName>failsafeArgLine</propertyName>
- </configuration>
- </execution>
-
-
- <execution>
- <id>post-integration-test</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>report</goal>
- </goals>
- <configuration>
- <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </pluginManagement>
+ </plugins>
</build>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.10</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
-
-
- </dependencies>
-
<modules>
+ <module>auth/auth-client</module>
+ <module>misc</module>
+ <module>cadi</module>
+ <module>auth</module>
</modules>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.onap.aaf.inno</groupId>
- <artifactId>env</artifactId>
- <version>${project.innoVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.inno</groupId>
- <artifactId>log4j</artifactId>
- <version>${project.innoVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.inno</groupId>
- <artifactId>rosetta</artifactId>
- <version>${project.innoVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.inno</groupId>
- <artifactId>xgen</artifactId>
- <version>${project.innoVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.cadi</groupId>
- <artifactId>cadi-core</artifactId>
- <version>${project.cadiVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.cadi</groupId>
- <artifactId>cadi-client</artifactId>
- <version>${project.cadiVersion}</version>
- </dependency>
-
-
- <dependency>
- <groupId>org.onap.aaf.cadi</groupId>
- <artifactId>cadi-aaf</artifactId>
- <version>${project.cadiVersion}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.cassandra</groupId>
- <artifactId>cassandra-all</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-client</artifactId>
- <version>${project.interfaceVersion}</version>
- </dependency>
-
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-core</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-cass</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-batch</artifactId>
- <version>${project.interfaceVersion}</version>
- </dependency>
-
-
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-cmd</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-gw</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>com.att.aft</groupId>
- <artifactId>dme2</artifactId>
- <version>${project.dme2Version}</version>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-servlet</artifactId>
- <version>9.0.3.v20130506</version>
- </dependency>
-
- <dependency>
- <groupId>com.datastax.cassandra</groupId>
- <artifactId>cassandra-all</artifactId>
- <version>2.1.10</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.datastax.cassandra</groupId>
- <artifactId>cassandra-driver-core</artifactId>
- <!-- version>1.0.3</version -->
- <!-- version>1.0.5</version -->
- <version>2.1.10</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.7.5</version>
- </dependency>
-
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.4.5</version>
- </dependency>
-
-
- </dependencies>
- </dependencyManagement>
+
+
<distributionManagement>
<repository>
- <id>ecomp-releases</id>
- <name>AAF Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
+ <id>nexus</id>
+ <name>attarch-releases</name>
+ <url>http://mavencentral.it.att.com:8084/nexus/content/repositories/attarch-releases</url>
</repository>
<snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>AAF Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
+ <id>nexus</id>
+ <name>attarch-snapshots</name>
+ <url>http://mavencentral.it.att.com:8084/nexus/content/repositories/attarch-snapshots</url>
</snapshotRepository>
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
</distributionManagement>
-
+
</project>