def ValidateToken(token, targets):
 def GetSubjectForError():
  if (len(targets) == 1):
   return list(targets)[0]
  else:
   return None
 if (not token):
  raise access_control.UnauthorizedAccess(('Must give an authorization token for %s' % targets), subject=GetSubjectForError())
 token.CheckExpiry()
 if (not token.username):
  raise access_control.UnauthorizedAccess(('Must specify a username for access to %s.' % targets), subject=GetSubjectForError())
 return True

def ValidateToken ( token , targets ) : def GetSubjectForError ( ) : if ( len ( targets ) == 1 ) : return list ( targets ) [ 0 ] else : return None if ( not token ) : raise access_control . UnauthorizedAccess ( ( 'Must give an authorization token for %s' % targets ) , subject = GetSubjectForError ( ) ) token . CheckExpiry ( ) if ( not token . username ) : raise access_control . UnauthorizedAccess ( ( 'Must specify a username for access to %s.' % targets ) , subject = GetSubjectForError ( ) ) return True
does basic token validation .