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), "", ""); } }
public final CryptoBrokerIdentity createCryptoBrokerIdentity(String alias, byte[] image) throws CantCreateCryptoBrokerIdentityException { try { DeviceUser loggedUser = deviceUserManager.getLoggedInDeviceUser(); KeyPair keyPair = new ECCKeyPair(); CryptoBrokerIdentity cryptoBroker = new CryptoBrokerIdentityImpl(alias, keyPair, image, ExposureLevel.HIDE); cryptoBrokerIdentityDatabaseDao.createNewCryptoBrokerIdentity( cryptoBroker, keyPair.getPrivateKey(), loggedUser); return cryptoBroker; } catch (CantGetLoggedInDeviceUserException e) { this.errorManager.reportUnexpectedPluginException( this.getPluginVersionReference(), UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw new CantCreateCryptoBrokerIdentityException( "CAN'T CREATE NEW CRYPTO BROKER IDENTITY", e, "Error getting current logged in device user", ""); } catch (CantCreateNewDeveloperException e) { this.errorManager.reportUnexpectedPluginException( this.getPluginVersionReference(), UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw new CantCreateCryptoBrokerIdentityException( "CAN'T CREATE NEW CRYPTO BROKER IDENTITY", e, "Error save user on database", ""); } catch (Exception e) { this.errorManager.reportUnexpectedPluginException( this.getPluginVersionReference(), UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw new CantCreateCryptoBrokerIdentityException( "CAN'T CREATE NEW CRYPTO BROKER IDENTITY", FermatException.wrapException(e), "", ""); } }