[ 
https://issues.apache.org/jira/browse/OFBIZ-6071?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14322602#comment-14322602
 ] 

Divesh Dutta commented on OFBIZ-6071:
-------------------------------------


For creating tenant I am  using ant target "./ant create-tenant". Below is the 
snippet from console while running this target:

Note: I am  using default Derby database configuration and setting 
multitenant=Y in general.properties

{code}
mysystem@system:~/dev/ofbiz/ofbiz_trunk$ ./ant create-tenant
Buildfile: /home/rahulbho/dev/ofbiz/ofbiz_trunk/build.xml


get-tenant-data:
    [input] Enter Id for the tenant: 
TEST123
    [input] Enter name for tenant: 
TEST123
    [input] Enter domain name for tenant (Optional): 

    [input] Enter data to install.         Choices are e.g. 
seed,seed-initial,ext,demo.         Multipe datasets must be separated with a 
comma: 
 seed,seed-initial,ext,demo
    [input] Select your default database platform, D = Derby,M = MySQL, O = 
Oracle, P = PostgreSQL (D, M, O, P)
M
     [echo] Please make sure that the driver of the platform is installed and 
that the databases have been created (in function of the entityengine.xml 
datasource-names)
    [input] Enter IP address of the database server (you may add a port number)
127.0.0.1
    [input] Enter userID of database user: 
root
    [input] Enter password of database user: 
123456

tenant-data-entry:
     [echo] ------------------------------------
     [echo] tenantId = TEST123
     [echo] tenantName = TEST123
     [echo] domainName = 
     [echo] db-Platform = M
     [echo] db-IP = 127.0.0.1
     [echo] db-User = root
     [echo] db-Password = 123456
     [echo] ------------------------------------
     [echo] database for tenant data will be 'ofbiz_TEST123'
     [echo] database for tenant olap data will be 'ofbizolap_TEST123
     [echo] Please make sure that the driver of the platform is installed and 
that the databases have been created (Check names just above)
     [echo] ------------------------------------
    [input] Continue Y or N (N, n, Y, y)
Y
.
.
further processes will run here
.
.
load-tenant-admin-user-login:
     [echo] ------------------------------------
     [echo] Installing the admin for the tenant
     [echo] Delegator = default#TEST123
     [echo] Tenant admin = 'TEST123-admin'
     [echo] Password for tenant admin is 'ofbiz' must change on first login
     [echo] ------------------------------------
    [input] Continue Y or N (N, n, Y, y)
y
.
.
.

{code}

After this I started the server and logged in with UserName: TEST123-admin 
,Password: ofbiz,TenantId: TEST123

Tested this further on revision 1655795. The issue exists on revision 1655795 
too. So, sorry for the confusion here. 

Initially I thought r1608347 could be related to this because the code snippet 
in SqlJdbcUtil.java of method getValue which calls decryptFieldValue was not 
available before r1608347. And delegator used to call decryptFieldValue is 
default delegator. And I think delegator should be of tenant because at the 
time of encryption tenant's delegator was used. 

Please let me know if you want any other details. Thanks in advance

> Issue in decrypting entity fields where encrypt="true" is used in tenant 
> -------------------------------------------------------------------------
>
>                 Key: OFBIZ-6071
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-6071
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: Trunk, Upcoming Branch
>            Reporter: Divesh Dutta
>            Assignee: Jacques Le Roux
>            Priority: Blocker
>
> Error while adding a credit card from order manager when logged in with 
> tenant account.
> The error is as following:
> ERROR rendering error page [/error/error.jsp], but here is the error text: 
> org.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen 
> [component://party/widget/partymgr/PaymentMethodScreens.xml#editcreditcard]: 
> org.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen 
> [component://party/widget/partymgr/PaymentMethodScreens.xml#PaymentMethodDecorator]:
>  org.ofbiz.entity.transaction.GenericTransactionException: The current 
> transaction is marked for rollback, not beginning a new transaction and 
> aborting current operation; the rollbackOnly was caused by: Failure in 
> findByCondition operation for entity [CreditCard]: 
> org.ofbiz.entity.GenericEntityException: Error creating GenericValue 
> (org.ofbiz.base.util.GeneralException: javax.crypto.BadPaddingException: 
> Given final block not properly padded (Given final block not properly padded) 
> (javax.crypto.BadPaddingException: Given final block not properly padded 
> (Given final block not properly padded))). Rolling back 
> transaction.org.ofbiz.entity.GenericEntityException: Error creating 
> GenericValue (org.ofbiz.base.util.GeneralException: 
> javax.crypto.BadPaddingException: Given final block not properly padded 
> (Given final block not properly padded) (javax.crypto.BadPaddingException: 
> Given final block not properly padded (Given final block not properly 
> padded))) 
> It seems there is some issue with encryption-decryption mechanism for the 
> fields of an entity for which encrypt="true" is set. From the exception it 
> seemed that incorrect key is being used for decryption i.e. the key is not 
> appropriate with respect to the one which was used for encryption.
> After tracing the process flow we suspect that in SqlJdbcUtil.java while 
> calling 'decryptFieldValue' the delegator which is being used is 
> baseDelegator instead of tenant's delegator, but at the time of encryption 
> using 'encryptFieldValue' the delegator was tenant's delegator. May be this 
> is the reason why it is generating "javax.crypto.BadPaddingException".
> Steps to regenerate:
> 1. Create a tenant and login to tenant's admin account.
> 2. Navigate to ORDER > Order Entry > Sales Order
> 3. Use Demo Customer as Customer and continue.
> 4. Add some item to order and proceed for Quick Finalize Order.
> 5. Try to add new credit card.
> 6. On saving credit card information it will generate the above error. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to