package Ġcom . bol . k atalog . security . support Ċ Ċ import Ġcom . bol . k atalog . features . registry . Namespace Id Ċ import Ġcom . bol . k atalog . security .* Ċ import Ġcom . bol . k atalog . security . tokens .* Ċ import Ġcom . bol . k atalog . users . Group Permission Ċ import Ġorg . springframework . security . core . authority . Simple Granted Authority Ċ Ċ /** Ċ Ġ* ĠDefine Ġsome Ġdefault Ġgroups Ġand Ġusers Ċ Ġ* ĠThese Ġare Ġadded Ġto Ġthe Ġsecurity Ġsystem Ġin ĠTest Application , Ġwhere Ġthe Ġtest Security Aggregate Ġis Ġdefined Ċ Ġ*/ Ċ val Ġgroup 1 Ġ= ĠGroup ( ĊĠĠĠ ĠGroup Id (" id - group 1 "), Ġ" group 1 ", Ġempty List () Ċ ) Ċ val Ġgroup 2 Ġ= ĠGroup ( ĊĠĠĠ ĠGroup Id (" id - group 2 "), Ġ" group 2 ", Ġempty List () Ċ ) Ċ val Ġuser 1 Ġ= ĠUser (" id - user 1 ", Ġ" user 1 ", Ġ" password ", Ġset Of ( Simple Granted Authority (" ROLE _ USER "))) Ċ val Ġuser 2 Ġ= ĠUser (" id - user 2 ", Ġ" user 2 ", Ġ" password ", Ġset Of ( Simple Granted Authority (" ROLE _ USER "))) Ċ val Ġuser ReadOnly Ġ= ĠUser ( ĊĠĠĠ Ġ" id - user - read - only ", ĊĠĠĠ Ġ" user - read - only ", ĊĠĠĠ Ġ" password ", ĊĠĠĠ Ġset Of ( Simple Granted Authority (" ROLE _ USER ")) Ċ ) Ċ val Ġadmin Ġ= ĠUser ( ĊĠĠĠ Ġ" id - admin ", Ġ" admin ", Ġ" password ", Ġset Of ( ĊĠĠĠĠĠĠĠ ĠSimple Granted Authority (" ROLE _ USER "), ĊĠĠĠĠĠĠĠ ĠSimple Granted Authority (" ROLE _ ADMIN ") ĊĠĠĠ Ġ) Ċ ) Ċ val Ġuser No Groups Ġ= ĠUser ( ĊĠĠĠ Ġ" id - user - no - groups ", ĊĠĠĠ Ġ" user - no - groups ", ĊĠĠĠ Ġ" password ", ĊĠĠĠ Ġset Of ( Simple Granted Authority (" ROLE _ USER ")) Ċ ) Ċ Ċ /** Ċ Ġ* ĠThese Ġextension Ġmethods Ġcan Ġbe Ġused Ġto Ġsimplify Ġthe Ġcreation Ġof Ġcommands / events Ġin Ġtesting Ċ Ġ*/ Ċ fun ĠGroup . create () Ġ= ĠCreate Group Command ( id , Ġname ) Ċ Ċ fun ĠGroup . created () Ġ= ĠGroup Created Event ( id , Ġname ) Ċ fun ĠGroup . disable () Ġ= ĠDisable Group Command ( id ) Ċ fun ĠGroup . disabled () Ġ= ĠGroup Disabled Event ( id ) Ċ fun ĠUser . create () Ġ= ĊĠĠĠ ĠCreate User Command ( id , Ġusername , Ġencoded Password , Ġauthor ities . map Ġ{ Ġit . authority Ġ}. toSet ()) Ċ Ċ fun ĠUser . created () Ġ= ĊĠĠĠ ĠUser Created Event ( id , Ġusername , Ġencoded Password , Ġauthor ities . map Ġ{ Ġit . authority Ġ}. toSet ()) Ċ fun ĠUser . addTo Group ( group : ĠGroup , Ġpermissions : ĠSet < Group Permission > Ġ= Ġempty Set ()) Ġ= ĊĠĠĠ ĠAdd User To Group Command ( id , Ġgroup . id , Ġpermissions ) Ċ Ċ fun ĠUser . added To Group ( group : ĠGroup , Ġpermissions : ĠSet < Group Permission > Ġ= Ġempty Set ()) Ġ= ĊĠĠĠ ĠUser Added To Group Event ( id , Ġgroup . id , Ġpermissions ) Ċ Ċ fun ĠUser . remove From Group ( group : ĠGroup ) Ġ= ĊĠĠĠ ĠRemove User From Group Command ( id , Ġgroup . id ) Ċ Ċ fun ĠUser . removed From Group ( group : ĠGroup ) Ġ= ĊĠĠĠ ĠUser Removed From Group Event ( id , Ġgroup . id ) Ċ fun ĠUser . disable () Ġ= ĠDisable User Command ( id ) Ċ fun ĠUser . disabled () Ġ= ĠUser Disabled Event ( id ) Ċ Ċ fun ĠToken . issue ( namespace Id : ĠNamespace Id , Ġpermissions : ĠSet < Group Permission >) Ġ= ĊĠĠĠ ĠIssue Token Command ( id , Ġdescription , Ġsubject Id , Ġnamespace Id , Ġpermissions ) Ċ Ċ fun ĠToken . iss ued () Ġ= ĠToken Iss ued Event ( id , Ġdescription , Ġsubject Id , Ġtoken ) Ċ fun ĠToken . revoke () Ġ= ĠRe voke Token Command ( id ) Ċ fun ĠToken . rev oked () Ġ= ĠToken Rev oked Event ( id ) Ċ