anchor.diff:           terminate/2, code_change/3]).
   
   
  +%% Constants
  +% Timeout of asychronous request handling == 30min
  +-define(ASYNC_TIMEOUT, 1000 * 60 * 30).
  +
  +
   %%%===================================================================
   %%% Type specifications
   %%%===================================================================
  
positive.code: %% @doc
  %% Handling call messages
  %%
  %% @end
  %%--------------------------------------------------------------------
  handle_call({be_req, new_lease, {Uid, KeyId, Path}}, _From, State) ->
      case p_new_lease(KeyId, Path) of
          {ok, LeaseToken} ->
              lager:info("Backend request: Uid: ~p - {new_lease, {~p, ~p}} -> Reply: ~p",
                         [Uid, KeyId, Path, LeaseToken]),
              {reply, {ok, LeaseToken}, State};
          Other ->
              lager:info("Backend request: Uid: ~p - {new_lease, {~p, ~p}} -> Reply: ~p",
                         [Uid, KeyId, Path, Other]),
              {reply, Other, State}
      end;
  handle_call({be_req, end_lease, {Uid, LeaseToken}}, _From, State) ->
      Reply = p_end_lease(LeaseToken),
      lager:info("Backend request: Uid: ~p - {end_lease, ~p} -> Reply: ~p",
                 [Uid, LeaseToken, Reply]),
      {reply, Reply, State};
  handle_call({be_req, submit_payload, {Uid, SubmissionData}}, _From, State) ->
      Reply = p_submit_payload(SubmissionData),
      {LeaseToken, _Payload, Digest, HeaderSize} = SubmissionData,
      lager:info("Backend request: Uid: ~p - {submit_payload, {~p, ~p, ~p, ~p}} -> Reply: ~p",
                 [Uid, LeaseToken, <<"payload_not_shown">>, Digest, HeaderSize, Reply]),
      {reply, Reply, State};
  handle_call({be_req, get_repos, Uid}, _From, State) ->
      Reply = p_get_repos(),
      lager:info("Backend request: Uid: ~p - {get_repos} -> Reply: ~p",
                 [Uid, Reply]),
      {reply, Reply, State};
  handle_call({be_req, check_hmac, {Uid, Message, KeyId, HMAC}}, _From, State) ->
      Reply = p_check_hmac(Message, KeyId, HMAC),
      lager:info("Backend request: Uid: ~p - {check_hmac, {~p, ~p, ~p}} -> Reply: ~p",
                 [Uid, Message, KeyId, HMAC, Reply]),
      {reply, Reply, State};
  handle_call({be_req, unique_id}, _From, State) ->
      Reply = p_unique_id(),
      lager:info("Backend request: {unique_id} -> Reply: ~p", [Reply]),
      {reply, Reply, State}.
  
  
  %%--------------------------------------------------------------------
  
negative.code:                                              LeaseToken :: binary().
  end_lease(Uid, LeaseToken) ->
      gen_server:call(?MODULE, {be_req, end_lease, {Uid, LeaseToken}}).
  
  
  %%--------------------------------------------------------------------
  %% @doc
  