View Javadoc
1   package com.srv4pos.server.api.infrastructure.credentials;
2   
3   import com.srv4pos.server.api.infrastructure.http.HttpHelper;
4   import org.apache.commons.codec.binary.Base64;
5   import sun.rmi.server.Activation;
6   
7   import static java.lang.String.format;
8   
9   /**
10   * Credentials for ROLE_ACTIVATION.
11   * Adds fields {@code productionNumber} and {@code activationSecurityToken}. Used for synchronize.
12   * Created by fasth on 27.08.2014.
13   */
14  public class ActivationCredentials extends SellerCredentials {
15  
16      private String apiKey;
17  
18      public ActivationCredentials(String country, String corporateId, String apiKey) {
19          super(country, corporateId);
20          this.apiKey = apiKey;
21      }
22  
23      public String getApiKey() {
24          return apiKey;
25      }
26  
27      /**
28       * Returns authentication {@code String}.
29       *
30       * @return returns Base64-encoded authentication {@code String} for apiKey
31       */
32      @Override
33      public String toAuthentication() {
34          return "Basic " + new String(Base64.encodeBase64(this.apiKey.getBytes(HttpHelper.CHARSET_FOR_TOKEN)), HttpHelper.CHARSET_UTF8);
35      }
36  }