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   
6   /**
7    * Created by misha on 1/18/18.
8    */
9   public class AdminCredentials implements Credentials {
10  
11      private static final String NAME_POSTFIX = "@";
12  
13      private String username;
14      private String password;
15  
16      public AdminCredentials(String username, String password) {
17          this.username = username;
18          this.password = password;
19      }
20  
21      public String toAuthentication() {
22          String token = String.format("%s:%s", username + NAME_POSTFIX, password);
23          return "Basic " + new String(Base64.encodeBase64(token.getBytes(HttpHelper.CHARSET_FOR_TOKEN)), HttpHelper.CHARSET_UTF8);
24      }
25  
26      public String getSellerId() {
27          return null;
28      }
29  }