コード例 #1
0
  public CryptoCustomerIdentity createCryptoCustomerIdentity(String alias, byte[] profileImage)
      throws CantCreateCryptoCustomerIdentityException {
    try {
      DeviceUser loggedUser = deviceUserManager.getLoggedInDeviceUser();
      KeyPair keyPair = AsymmetricCryptography.generateECCKeyPair();
      // TODO BY DEFAULT THE CUSTOMER IS PUBLISHED
      CryptoCustomerIdentity cryptoCustomer =
          new CryptoCustomerIdentityImpl(
              alias, keyPair.getPrivateKey(), keyPair.getPublicKey(), profileImage, true);
      cryptoCustomerIdentityDatabaseDao.createNewCryptoCustomerIdentity(
          cryptoCustomer, keyPair.getPrivateKey(), loggedUser);

      return cryptoCustomer;

    } catch (CantGetLoggedInDeviceUserException e) {
      throw new CantCreateCryptoCustomerIdentityException(
          "CAN'T CREATE NEW CRYPTO CUSTOMER IDENTITY",
          e,
          "Error getting current logged in device user",
          "");
    } catch (CantCreateNewDeveloperException e) {
      throw new CantCreateCryptoCustomerIdentityException(
          "CAN'T CREATE NEW CRYPTO CUSTOMER IDENTITY", e, "Error save user on database", "");
    } catch (Exception e) {
      throw new CantCreateCryptoCustomerIdentityException(
          "CAN'T CREATE NEW CRYPTO CUSTOMER IDENTITY", FermatException.wrapException(e), "", "");
    }
  }