<s> import xmlrpclib <EOL> from vt_manager . communication . sfa . trust . certificate import Certificate <EOL> from vt_manager . communication . sfa . trust . gid import GID <EOL> class SfaTicket ( Certificate ) : <EOL> gidCaller = None <EOL> gidObject = None <EOL> attributes = { } <EOL> rspec = { } <EOL> delegate = False <EOL> def __init__ ( self , create = False , subject = None , string = None , filename = None ) : <EOL> Certificate . __init__ ( self , create , subject , string , filename ) <EOL> def set_gid_caller ( self , gid ) : <EOL> self . gidCaller = gid <EOL> def get_gid_caller ( self ) : <EOL> if not self . gidCaller : <EOL> self . decode ( ) <EOL> return self . gidCaller <EOL> def set_gid_object ( self , gid ) : <EOL> self . gidObject = gid <EOL> def get_gid_object ( self ) : <EOL> if not self . gidObject : <EOL> self . decode ( ) <EOL> return self . gidObject <EOL> def set_attributes ( self , gid ) : <EOL> self . attributes = gid <EOL> def get_attributes ( self ) : <EOL> if not self . attributes : <EOL> self . decode ( ) <EOL> return self . attributes <EOL> def set_rspec ( self , gid ) : <EOL> self . rspec = gid <EOL> def get_rspec ( self ) : <EOL> if not self . rspec : <EOL> self . decode ( ) <EOL> return self . rspec <EOL> def set_delegate ( self , delegate ) : <EOL> self . delegate = delegate <EOL> def get_delegate ( self ) : <EOL> if not self . delegate : <EOL> self . decode ( ) <EOL> return self . delegate <EOL> def encode ( self ) : <EOL> dict = { "<STR_LIT>" : None , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : self . attributes , <EOL> "<STR_LIT>" : self . rspec , <EOL> "<STR_LIT>" : self . delegate } <EOL> if self . gidCaller : <EOL> dict [ "<STR_LIT>" ] = self . gidCaller . save_to_string ( save_parents = True ) <EOL> if self . gidObject : <EOL> dict [ "<STR_LIT>" ] = self . gidObject . save_to_string ( save_parents = True ) <EOL> str = "<STR_LIT>" + xmlrpclib . dumps ( ( dict , ) , allow_none = True ) <EOL> self . set_data ( str ) <EOL> def decode ( self ) : <EOL> data = self . get_data ( ) <EOL> if data : <EOL> dict = xmlrpclib . loads ( self . get_data ( ) [ <NUM_LIT:4> : ] ) [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> else : <EOL> dict = { } <EOL> self . attributes = dict . get ( "<STR_LIT>" , { } ) <EOL> self . rspec = dict . get ( "<STR_LIT>" , { } ) <EOL> self . delegate = dict . get ( "<STR_LIT>" , False ) <EOL> gidCallerStr = dict . get ( "<STR_LIT>" , None ) <EOL> if gidCallerStr : <EOL> self . gidCaller = GID ( string = gidCallerStr ) <EOL> else : <EOL> self . gidCaller = None <EOL> gidObjectStr = dict . get ( "<STR_LIT>" , None ) <EOL> if gidObjectStr : <EOL> self . gidObject = GID ( string = gidObjectStr ) <EOL> else : <EOL> self . gidObject = None <EOL> def dump ( self , dump_parents = False ) : <EOL> print "<STR_LIT>" , self . get_subject ( ) <EOL> print "<STR_LIT>" <EOL> gidCaller = self . get_gid_caller ( ) <EOL> if gidCaller : <EOL> gidCaller . dump ( <NUM_LIT:8> , dump_parents ) <EOL> print "<STR_LIT>" <EOL> gidObject = self . get_gid_object ( ) <EOL> if gidObject : <EOL> gidObject . dump ( <NUM_LIT:8> , dump_parents ) <EOL> print "<STR_LIT>" <EOL> for attrname in self . get_attributes ( ) . keys ( ) : <EOL> print "<STR_LIT:U+0020>" , attrname , self . get_attributes ( ) [ attrname ] <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT:U+0020>" , self . get_rspec ( ) <EOL> if self . parent and dump_parents : <EOL> print "<STR_LIT>" , <EOL> self . parent . dump ( dump_parents ) </s>
