WeBankBlockchain / WeIdentity-Sample

http://weidentity.webank.com/
GNU Lesser General Public License v3.0
16 stars 25 forks source link

The Issuer is work but User Agent is not. #51

Closed leeduckgo closed 4 years ago

leeduckgo commented 4 years ago

Conf of User Agent:

blockchain.orgid=2

# Persistence Layer configurations. Do NOT change this if you are not using Persistence Layer features!
# MySQL connection config
# Support multiple data source configurations with comma-separated multiple data sources.
datasource.name=datasource1

# The configuration of each data source is prefixed by the name of the data source.
datasource1.jdbc.url=jdbc:mysql://0.0.0.0:3306/database?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
datasource1.jdbc.username=user
datasource1.jdbc.password=passwd
datasource1.jdbc.maxActive=50
datasource1.jdbc.minIdle=5
datasource1.jdbc.maxIdle=5
datasource1.jdbc.maxWait=10000
datasource1.jdbc.timeBetweenEvictionRunsMillis=600000
datasource1.jdbc.numTestsPerEvictionRun=5
datasource1.jdbc.minEvictableIdleTimeMillis=1800000

# Domain configuration, which divides colons into two segments, the first segment is the name of the data source,
# the second segment is the name of the table, and if not, the default is the first data source and the default table `sdk_all_data`,
# Multiple domains can be configured at the same time.
# example:
# credential.domain=datasource1:credential_data
# weidDocument.domain=datasource1:weid_document_data

default.domain=datasource1:sdk_all_data

# Salt length for Proof creation.
salt.length=5

# AMOP Config
# Timeout for amop request, default: 5000ms
amop.request.timeout=5000

# Blockchain node info.
nodes=127.0.0.1:30300

Conf of src/main/resources/weidentity.properties:

# The organization ID for AMOP communication.
blockchain.orgid=1

# Persistence Layer configurations. Do NOT change this if you are not using Persistence Layer features!
# MySQL connection config
# Support multiple data source configurations with comma-separated multiple data sources.
datasource.name=datasource1

# The configuration of each data source is prefixed by the name of the data source.
datasource1.jdbc.url=jdbc:mysql://0.0.0.0:3306/database?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
datasource1.jdbc.username=user
datasource1.jdbc.password=passwd
datasource1.jdbc.maxActive=50
datasource1.jdbc.minIdle=5
datasource1.jdbc.maxIdle=5
datasource1.jdbc.maxWait=10000
datasource1.jdbc.timeBetweenEvictionRunsMillis=600000
datasource1.jdbc.numTestsPerEvictionRun=5
datasource1.jdbc.minEvictableIdleTimeMillis=1800000

# Domain configuration, which divides colons into two segments, the first segment is the name of the data source,
# the second segment is the name of the table, and if not, the default is the first data source and the default table `sdk_all_data`,
# Multiple domains can be configured at the same time.
# example:
# credential.domain=datasource1:credential_data
# weidDocument.domain=datasource1:weid_document_data

default.domain=datasource1:sdk_all_data

# Salt length for Proof creation.
salt.length=5

# AMOP Config
# Timeout for amop request, default: 5000ms
amop.request.timeout=5000

# Blockchain node info.
nodes=127.0.0.1:20200

The error of first time run "./command.sh user_agent":

+ daemon_pid=
+ [[ user_agent != \i\s\s\u\e\r ]]
+ [[ user_agent != \u\s\e\r\_\a\g\e\n\t ]]
+ [[ user_agent == daemon ]]
+ echo '--------- start user_agent ----------'
--------- start user_agent ----------
+ java -cp 'dist/conf/:dist/lib/*:dist/app/*' com.webank.weid.demo.command.DemoCommand user_agent
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/Users/liaohua/weid-sample/dist/lib/netty-all-4.1.15.Final.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
userAgent() init...

------------------------------

begin to create weId for useragent...

createWeId result:

result:(com.webank.weid.protocol.response.CreateWeIdDataResult)
   weId: did:weid:1:0xd4e4dd3b78e37f8d97b6c2714e6f352cc76260f9
   userWeIdPublicKey:(com.webank.weid.protocol.base.WeIdPublicKey)
      publicKey: 9112592668279748978468780166528424813495665644826845878749696420447167535182382776373563532368860320837090609595413558634632754523880198514235577088891179
   userWeIdPrivateKey:(com.webank.weid.protocol.base.WeIdPrivateKey)
      privateKey: 73596092635691082477558844353023878853821477308543500241024274153936527248271
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 80
   transactionHash: 0xf734c0a2bde4d8f56346abcc02194e5b69be4a20dc6e1e0330e55e948151958f
   transactionIndex: 0

------------------------------

begin to setAuthenticate...

setAuthentication result:

result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 81
   transactionHash: 0x8c020cbe0c985b53b50444c77941fb2807aec5ee2c2236c60dd9f0de89526315
   transactionIndex: 0

------------------------------

begin to get the credentialList from json...

------------------------------

begin to get the PolicyAndChallenge...

value length:271:271
queryPolicyAndChallenge from amop result:

result:null
errorCode: 160010
errorMessage: amop response messageBody error.
transactionInfo:null

The second time when I change conf of User Agent:

--------- start user_agent ----------
+ java -cp 'dist/conf/:dist/lib/*:dist/app/*' com.webank.weid.demo.command.DemoCommand user_agent
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/Users/liaohua/weid-sample/dist/lib/netty-all-4.1.15.Final.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "web3sdk-1" java.lang.IndexOutOfBoundsException: readerIndex(6) + length(32) exceeds writerIndex(18): PooledSlicedByteBuf(ridx: 6, widx: 18, cap: 18/18, unwrapped: PooledUnsafeDirectByteBuf(ridx: 18, widx: 18, cap: 47))
    at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1401)
    at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1388)
    at io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:870)
    at io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:878)
    at org.fisco.bcos.channel.handler.Message.readHeader(Message.java:21)
    at org.fisco.bcos.channel.handler.ConnectionCallback.onMessage(ConnectionCallback.java:140)
    at org.fisco.bcos.channel.handler.ChannelConnections.onReceiveMessage(ChannelConnections.java:473)
    at org.fisco.bcos.channel.handler.ChannelHandler$1.run(ChannelHandler.java:141)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:835)
Exception in thread "web3sdk-3" java.lang.IndexOutOfBoundsException: readerIndex(6) + length(32) exceeds writerIndex(18): PooledSlicedByteBuf(ridx: 6, widx: 18, cap: 18/18, unwrapped: PooledUnsafeDirectByteBuf(ridx: 18, widx: 18, cap: 47))
    at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1401)
    at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1388)
    at io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:870)
    at io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:878)
    at org.fisco.bcos.channel.handler.Message.readHeader(Message.java:21)
    at org.fisco.bcos.channel.handler.ConnectionCallback.onMessage(ConnectionCallback.java:140)
    at org.fisco.bcos.channel.handler.ChannelConnections.onReceiveMessage(ChannelConnections.java:473)
    at org.fisco.bcos.channel.handler.ChannelHandler$1.run(ChannelHandler.java:141)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:835)
^C%
yanggang-JV commented 4 years ago

您好!sample的运行涉及到AMOP调用

  1. 请在启动AMOP Server的时候(./command.sh daemon),确保配置的机构为:organizationA
  2. AMOP Server启动成功后,请修改dist/conf/weidentity.properties, 确保机构为: 非organizationA ,所连接的节点与AMOP Server所连接的节点不一致
  3. 依次运行./command.sh issuer ./command.sh user_agent ./command.sh verifier 三命令即可