package Ġorg . cloudfoundry . cred hub . permissions Ċ Ċ import Ġorg . apache . commons . lang 3 . StringUtils Ċ import Ġorg . cloudfoundry . cred hub . audit . CE FA udit Record Ċ import Ġorg . cloudfoundry . cred hub . audit . entities . Add Permission Ċ import Ġorg . cloudfoundry . cred hub . audit . entities . Delete Permissions Ċ import Ġorg . cloudfoundry . cred hub . audit . entities . Get Permissions Ċ import Ġorg . cloudfoundry . cred hub . requests . Permissions Request Ċ import Ġorg . cloudfoundry . cred hub . views . Permissions View Ċ import Ġorg . springframework . context . annotation . Profile Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . http . MediaType Ċ import Ġorg . springframework . validation . annotation . Validated Ċ import Ġorg . springframework . web . bind . annotation . RequestBody Ċ import Ġorg . springframework . web . bind . annotation . RequestMapping Ċ import Ġorg . springframework . web . bind . annotation . Request Method Ċ import Ġorg . springframework . web . bind . annotation . RequestParam Ċ import Ġorg . springframework . web . bind . annotation . ResponseStatus Ċ import Ġorg . springframework . web . bind . annotation . RestController Ċ Ċ @ Profile (" ! remote ") Ċ @ RestController Ċ @ RequestMapping ( path Ġ= Ġ[ Permissions V 1 Controller . ENDPOINT ], Ġproduces Ġ= Ġ[ MediaType . APPLICATION _ JSON _ UTF 8 _ VALUE ]) Ċ class ĠPermissions V 1 Controller ( ĊĠĠĠ Ġprivate Ġval Ġpermissions Handler : ĠPermissions V 1 Handler , ĊĠĠĠ Ġprivate Ġval Ġaudit Record : ĠCE FA udit Record Ċ ) Ġ{ ĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠEND POINT Ġ= Ġ"/ api / v 1 / permissions " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ RequestMapping ( method Ġ= Ġ[ Request Method . GET ], Ġpath Ġ= Ġ[ "" ]) ĊĠĠĠ Ġ@ ResponseStatus ( HttpStatus . OK ) ĊĠĠĠ Ġfun Ġget AccessControl List (@ RequestParam (" credential _ name ") Ġcredential Name : ĠString ): ĠPermissions View Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcredential Name With Leading Slash Ġ= ĠStringUtils . prepend If Missing ( credential Name , Ġ"/") ĊĠĠĠĠĠĠĠ Ġaudit Record . request Details Ġ= ĠGet Permissions ( credential Name ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġpermissions Handler . get Permissions ( credential Name With Leading Slash ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ RequestMapping ( method Ġ= Ġ[ Request Method . POST ], Ġpath Ġ= Ġ[ "" ], Ġconsume s Ġ= Ġ[ MediaType . APPLICATION _ JSON _ UTF 8 _ VALUE ]) ĊĠĠĠ Ġ@ ResponseStatus ( HttpStatus . CREATED ) ĊĠĠĠ Ġfun Ġset AccessControl Entries (@ Validated Ġ@ RequestBody Ġaccess Entries Request : ĠPermissions Request ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġadd Permission Ġ= ĠAdd Permission ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaccess Entries Request . credential Name , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaccess Entries Request . permissions ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġaudit Record . request Details Ġ= Ġadd Permission ĊĠĠĠĠĠĠĠ Ġpermissions Handler . write Permissions ( access Entries Request ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ RequestMapping ( method Ġ= Ġ[ Request Method . DELETE ], Ġpath Ġ= Ġ[ "" ]) ĊĠĠĠ Ġ@ ResponseStatus ( HttpStatus . NO _ CONTENT ) ĊĠĠĠ Ġfun Ġdelete AccessControl Entry ( ĊĠĠĠĠĠĠĠ Ġ@ RequestParam (" credential _ name ") Ġcredential Name : ĠString , ĊĠĠĠĠĠĠĠ Ġ@ RequestParam (" actor ") Ġactor : ĠString ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcredential Name With Pre pended Slash Ġ= ĠStringUtils . prepend If Missing ( credential Name , Ġ"/") ĊĊĠĠĠĠĠĠĠ Ġval Ġdelete Permissions Ġ= ĠDelete Permissions ( credential Name , Ġactor ) ĊĠĠĠĠĠĠĠ Ġaudit Record . request Details Ġ= Ġdelete Permissions ĊĊĠĠĠĠĠĠĠ Ġpermissions Handler . delete Permission Entry ( credential Name With Pre pended Slash , Ġactor ) ĊĠĠĠ Ġ} Ċ } Ċ