/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 1 9 ĠThe Ġlg ou 2 w Ġ< lg ou 2 w @ hotmail . com > Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġcom . lg ou 2 w . y gg dr as il Ċ Ċ import Ġcom . google . gson . Gson Ċ import Ġcom . google . gson . Gson Builder Ċ import Ġcom . lg ou 2 w . ld k . common . notNull Ċ import Ġcom . lg ou 2 w . y gg dr as il . dao . Dao Ċ import Ġcom . lg ou 2 w . y gg dr as il . dao . Permission Ċ import Ġcom . lg ou 2 w . y gg dr as il . dao . Permission Serializer Ċ import Ġcom . lg ou 2 w . y gg dr as il . email . Email Ċ import Ġcom . lg ou 2 w . y gg dr as il . email . Email Manager Ċ import Ġcom . lg ou 2 w . y gg dr as il . email . Email Serializer Ċ import Ġcom . lg ou 2 w . y gg dr as il . manager . Textures Manager Ċ import Ġcom . lg ou 2 w . y gg dr as il . security . Has hed Password Ċ import Ġcom . lg ou 2 w . y gg dr as il . security . Has hed Password Serializer Ċ import Ġcom . lg ou 2 w . y gg dr as il . security . Password Encryption Ċ import Ġcom . lg ou 2 w . y gg dr as il . security . Password s Ċ import Ġcom . lg ou 2 w . y gg dr as il . storage . Storage Ċ import Ġcom . lg ou 2 w . y gg dr as il . storage . Storage Coroutine Context Ċ import Ġcom . lg ou 2 w . y gg dr as il . storage . Storage s Ċ import Ġcom . lg ou 2 w . y gg dr as il . util . DateTime Serializer Ċ import Ġcom . lg ou 2 w . y gg dr as il . util . UUID Serializer Ċ import Ġorg . joda . time . DateTime Ċ import Ġjava . io . Closeable Ċ import Ġjava . io . File Ċ import Ġjava . util . UUID Ċ import Ġjava . util . concurrent . atomic . Atomic Boolean Ċ Ċ interface ĠY gg dr as il Service Ġ{ ĊĠĠĠ Ġval Ġconf Ġ: ĠY gg dr as il Conf ĊĠĠĠ Ġval Ġwork Dir Ġ: ĠFile ĊĠĠĠ Ġval Ġmanager Ġ: ĠY gg dr as il Manager ĊĠĠĠ Ġval Ġpassword Encryption Ġ: ĠPassword Encryption ĊĠĠĠ Ġval Ġemail Manager Ġ: ĠEmail Manager ĊĠĠĠ Ġsuspend Ġfun Ġ< T > Ġtransaction ( block : ĠStorage Coroutine Context . () Ġ-> ĠT ): ĠT Ċ } Ċ Ċ class ĠY gg dr as il Manager ( val Ġconf : ĠY gg dr as il Conf ) Ġ: ĠClose able Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġinitialized Ġ= ĠAtomic Boolean ( false ) ĊĠĠĠ Ġprivate Ġvar Ġm Password Encryption Ġ: ĠPassword Encryption ? Ġ= Ġnull ĊĠĠĠ Ġprivate Ġvar Ġm Email Mess ager Ġ: ĠEmail Manager ? Ġ= Ġnull ĊĠĠĠ Ġprivate Ġvar Ġm Storage Ġ: ĠStorage ? Ġ= Ġnull ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Textures Manager Ġ: ĠText ures Manager ĊĊĠĠĠ Ġval Ġgson Ġ: ĠGson Ġby Ġlazy Ġ{ ĊĠĠĠĠĠĠĠ ĠGson Builder (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġregister Type Adapter ( UUID :: class . java , ĠUUID Serializer ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġregister Type Adapter ( DateTime :: class . java , ĠDateTime Serializer ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġregister Type Hierarchy Adapter ( Email :: class . java , ĠEmail Serializer ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġregister Type Hierarchy Adapter ( Has hed Password :: class . java , ĠHas hed Password Serializer ( password Encryption )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġregister Type Hierarchy Adapter ( Permission :: class . java , ĠPermission Serializer ) ĊĠĠĠĠĠĠĠ Ġ}. create () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġinitialize () Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ(! initialized . compare AndSet ( false , Ġtrue )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ ĠY gg dr as il Log . info (" åĪĿå§ĭåĮĸ ĠY gg dr as il Ġ ç®¡çĲĨ åĻ¨ ...") ĊĠĠĠĠĠĠĠ Ġval Ġstorage Type Ġ= Ġconf . storage Type ĊĠĠĠĠĠĠĠ Ġval Ġpassword Encryption Ġ= Ġconf . password Encryption ĊĠĠĠĠĠĠĠ Ġm Password Encryption Ġ= ĠPassword s . new Encryption ( password Encryption ) ĊĠĠĠĠĠĠĠ Ġm Email Mess ager Ġ= ĠEmail Manager ( conf ) ĊĠĠĠĠĠĠĠ Ġm Storage Ġ= ĠStorage s . new Storage ( storage Type ) ĊĠĠĠĠĠĠĠ Ġm Storage ?. initialize ( conf ) ĊĠĠĠĠĠĠĠ Ġm Storage ?. initialize Dao Ġ{ ĠDao . initialize Registers () Ġ} ĊĠĠĠĠĠĠĠ ĠY gg dr as il Log . info (" ä½¿çĶ¨ æķ°æį® åŃĺåĤ¨ ç±»åŀĭ Ġ: Ġ$ storage Type ") ĊĠĠĠĠĠĠĠ ĠY gg dr as il Log . info (" ä½¿çĶ¨ å¯Ĩçłģ åĬłå¯Ĩ ç±»åŀĭ Ġ: Ġ$ password Encryption ") ĊĠĠĠĠĠĠĠ Ġcheck And Log Unsafe Password Encryption () ĊĊĠĠĠĠĠĠĠ Ġm Textures Manager Ġ= ĠText ures Manager ( conf ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġclose () Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ(! initialized . compare AndSet ( true , Ġfalse )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ ĠY gg dr as il Log . info (" åħ³éĹŃ ĠY gg dr as il Ġ ç®¡çĲĨ åĻ¨ ...") ĊĠĠĠĠĠĠĠ Ġm Password Encryption Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġm Email Mess ager ?. close () ĊĠĠĠĠĠĠĠ Ġm Email Mess ager Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġm Storage ?. shutdown () ĊĠĠĠĠĠĠĠ Ġm Storage Ġ= Ġnull ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġ< T > ĠT ?. notNull Field (): ĠT Ġ= Ġnot Null (" ç®¡çĲĨ åĻ¨ å° ļ æľª åĪĿå§ĭåĮĸ .") ĊĊĠĠĠ Ġval Ġstorage Ġ: ĠStorage Ġget () Ġ= Ġm Storage . notNull Field () ĊĠĠĠ Ġval Ġpassword Encryption Ġ: ĠPassword Encryption Ġget () Ġ= Ġm Password Encryption . notNull Field () ĊĠĠĠ Ġval Ġemail Manager Ġ: ĠEmail Manager Ġget () Ġ= Ġm Email Mess ager . notNull Field () ĊĠĠĠ Ġval Ġtextures Manager Ġ: ĠText ures Manager Ġget () Ġ= Ġm Textures Manager ĊĊĠĠĠ Ġprivate Ġfun Ġcheck And Log Unsafe Password Encryption () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġclazz Ġ= Ġm Password Encryption ?. java Class ĊĠĠĠĠĠĠĠ Ġif Ġ( clazz ?. getAnnotation ( Deprecated :: class . java ) Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠY gg dr as il Log . warn (" èŃ¦ åĳĬ : Ġä½¿çĶ¨ çļĦ å¯Ĩçłģ åĬłå¯Ĩ ç±»åŀĭ ä¸į å®īåħ¨ .") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠY gg dr as il Log . warn (" å»ºè®® ä½¿çĶ¨ é«ĺ å¼º åº¦ å¯Ĩçłģ åĬłå¯Ĩ ç±»åŀĭ ä»¥ ç¡® ä¿Ŀ å®īåħ¨ æĢ§ .") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ