https://www.java.net//forum/topic/jxta/jxta-community-forum/how-initialize-pse-jxse-27

————————————————————————————————————————————————————————————————————

borysd
Offline
Joined: 2009-11-22
 
 

Does anybody know how to initialize PSE in 2.7? If I start a rdv peer without peerId or infrastructureID then an edge peer can connect to it. As soon as I set any of IDs I'm getting the following message on the edge peer
SEVERE: EndpointRouterMsg declared src address does not match the sender's address.
tempMsgERM.getSrcAddress()=jxta://uuid-59616261646162614A78746150325033246734A29C11461D9CC3BB9B20842C1E03,

tempEASuposedToBe=jxta://cbid-59616261646162614A78746150325033426F9328E59F083D855D65F748B6F87E03

It looks to me that it wants the peerId to be generated based on a
certificate that jxse automatically generated for the WorldGroup. But if
I want the peerId to be always the same it seems that I need to
generate all artifacts for PSE myself.
How to properly initialize PSE in 2.7? I mean how it supposed to be
initialized? Examples provided with jxse 2.7 were not working for me
till I commented peerId out. I think there is some way designers of jxse
2.7 intended PSE to be used.

Thank you.

********************************

buzzheavyyear
Offline
Joined: 2005-06-18
 
 

Sounds like you are deleting the keystore each time you do a restart - if 2.7 discovers that the keystore has gone then it creates a new one and generates a new certificate. Don't forget to save and restore the configuration and it helps to delete the cache.

*********************************

borysd
Offline
Joined: 2009-11-22
 
 

Can you explain me how to save it?
I tried
MyNetworkConfigurator.save();

but it causes exception in
PeerGroup NetPeerGroup = MyNetworkManager.startNetwork();

May 24, 2011 8:40:57 AM net.jxta.impl.peergroup.StdPeerGroup initFirst
SEVERE: Failed to make PSE membership credential 'ready for join'
May 24, 2011 8:40:57 AM net.jxta.peergroup.WorldPeerGroupFactory newWorldPeerGroup
SEVERE: World Peer Group could not be instantiated.

net.jxta.exception.PeerGroupException: Failed to login to this group: null. Error=0
at net.jxta.impl.peergroup.StdPeerGroup.initFirst(StdPeerGroup.java:704)
at net.jxta.impl.peergroup.Platform.initFirst(Platform.java:214)
at net.jxta.impl.peergroup.GenericPeerGroup.init(GenericPeerGroup.java:907)
at net.jxta.peergroup.WorldPeerGroupFactory.newWorldPeerGroup(WorldPeerGroupFactory.java:312)
at net.jxta.peergroup.WorldPeerGroupFactory.<init>(WorldPeerGroupFactory.java:182)
at net.jxta.peergroup.NetPeerGroupFactory.<init>(NetPeerGroupFactory.java:203)
at net.jxta.platform.NetworkManager.startNetwork(NetworkManager.java:408)
at Examples.K_Service.Edge_Jill_The_Customer.main(Edge_Jill_The_Customer.java:128)
Edge Jill, The Customer net.jxta.exception.PeerGroupException: World Peer Group could not be instantiated.

Thank you

***********************************
 
buzzheavyyear
Offline
Joined: 2005-06-18
 
 

1. Delete your jxta run dir/folder
2. Create a new jxta configuration, including peer name, peerid if you need to, username, password and all of your network setup
3. Save the configuration file - this usually defaults to PlatformConfig in the jxta run dir
4. Set up the path to the keystore - there is a default
5. Start jxta.
6. Stop jxta, turn off the machine and have a cup of coffee
7. You might want to delete the cache files/dirs in the jxta run dir. Don't delete the keystore!
8. Load the configuration - you shouldn't need to set anything except
for the username and password - these are for the keystore - everything
else should be in the config file.
9. Set the keystore path if you need to ... must be the one defined above
9 Start jxta.
Read through the source of NetworkManager and NetworkConfigurtor. Believe me, it works!

*********************************
tah_mas
Offline
Joined: 2012-08-06
 
 

I've got the same problem i.e. as soon as I set the peerID my code breaks with:

Aug 6, 2012 4:48:53 PM net.jxta.impl.endpoint.WireFormatMessageBinary$Instantiator enforceCbjxOnIncoming
SEVERE: EndpointRouterMsg declared src address does not match the
sender's address.
tempMsgERM.getSrcAddress()=jxta://cbid-59616261646162614E504720503250331884408F6046A2521650BBCBACD41AB303,

tempEASuposedToBe=jxta://cbid-59616261646162614A787461503250335BBE5BCADE2ABB3297475FFEBE0F860903

I've followed your instructions above and modified the practicaljxta2 (http://sourceforge.net/projects/practicaljxta/files/)
examples Examples.B_Exploring_Connectivity_Issues.RendezVous_Jack and
Examples.B_Exploring_Connectivity_Issues.Endge_Anna to reflect this but I
cannot get 2.7 to work without commenting out the setPeerId
(MyNetworkConfigurator.setPeerID(PID)) and removing the
configurator.save() call. Unfortunately in my application I must set the
peerID so this is not a solution for me.

Any advice / pointers appreciated as I'm not sure what to try next.

Thanks,
tah_mas

*************************************
tah_mas
Offline
Joined: 2012-08-06
 
 

ok I think I have solved it.. I used to call NetworkConfigurator.setPeerId but changing this to NetworkManager.setPeerId fixes the problem. I'm new to jxta so not quite sure what the difference is...

 **********************************************************************************
 
 发现个问题,即使通过NetworkManager.setPeerId设置了结点id,但是通过PeerGroup.getPeerID返回的确实另外一个值,说明该调用并没有起作用。。。,Why?
 **********************************************************************************
Oh, my!还是忘掉MembershipService和AccessService吧!!!
 **********************************************************************************
 
问题基本解决,虽然对PSEMembershipService还是一知半解:
      参照《Practical JXTA II》的例子Example 620 - Custom PSE Peer Group & Joining。
 
在开始的时候创建keystore等,首先是变量声明:
    // ************************ PSEMembershipService *******************************
// TODO: myPrivateKeyPassword与myKeyStorePassword必须相同
public static final String myPrincipalName = "Principal - " + refPeerGroupName;
public static final String myPrivateKeyPassword = "PrivateKey Password - " + refPeerGroupName;
// public static final String myPrivateKeyPassword = "a123456"; public static final String myKeyStoreFileName = "MyKeyStoreFile";
public static final String myKeyStoreLocation = ".jxta";
public static final String myKeyStorePassword = "KeyStore Password - " + refPeerGroupName;
// public static final String myKeyStorePassword = "a123456";
public static final String myKeyStoreProvider = "KeyStore Provider - " + refPeerGroupName; public static final File myKeyStoreDirectory = new File(myKeyStoreLocation);
public static final File myKeyStoreFile = new File(myKeyStoreLocation + File.separator + myKeyStoreFileName); public static final X509Certificate theX509Certificate;
public static final PrivateKey thePrivateKey; static {
// Static initialization of certificates
PSEUtils.IssuerInfo forPSE = PSEUtils.genCert(refPeerGroupName, null);
theX509Certificate = forPSE.cert;
thePrivateKey = forPSE.issuerPkey;
}

其次是配置:

            // Preparing data
myKeyStoreDirectory.mkdirs(); // Creating the key store
FileKeyStoreManager myFileKeyStoreManager = new FileKeyStoreManager((String)null, myKeyStoreProvider, myKeyStoreFile);
myFileKeyStoreManager.createKeyStore(myKeyStorePassword.toCharArray()); if(!myFileKeyStoreManager.isInitialized()) {
System.out.println("Keystore is NOT initialized");
} else {
System.out.println("Keystore is initialized");
} // Loading the (empty) keystore
KeyStore myKeyStore = myFileKeyStoreManager.loadKeyStore(myKeyStorePassword.toCharArray()); // Setting data
X509Certificate[] temp = {theX509Certificate};
myKeyStore.setKeyEntry(config.getPeerId(), thePrivateKey, myPrivateKeyPassword.toCharArray(), temp); // Saving the data
myFileKeyStoreManager.saveKeyStore(myKeyStore, myKeyStorePassword.toCharArray()); // Reloading the KeyStore
myKeyStore = myFileKeyStoreManager.loadKeyStore(myKeyStorePassword.toCharArray()); // Retrieving Certificate
X509Certificate myCertificate = (X509Certificate)myKeyStore.getCertificate(config.getPeerId()); if(myCertificate == null) {
System.out.println("X509 Certificate CANNOT be retrieved");
} else {
System.out.println("X509 Certificate can be retrieved: " + myCertificate.toString());
} // Retrieving private key
PrivateKey myPrivateKey = (PrivateKey)myKeyStore.getKey(config.getPeerId(), myPrivateKeyPassword.toCharArray());
if(myPrivateKey == null) {
System.out.println("Private key CANNOT be retrieved");
} else {
System.out.println("Private key can be retrieved: " + myPrivateKey.toString());
}

尤其需要注意的是:myPrivateKeyPassword与myKeyStorePassword必须相同,否则还是会抛出异常。按理来说不应该是这样的,怀疑可能是jxta的实现有问题,太乱,反正现在能跑起来了,先这样吧。

设置结点ID的时候,要调用NetworkConfigurator.setPeerId。

 
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
一个有趣的现象,在ShadowPeerGroup.java的不同版本中,getDefaultModuleImplAdvertisement方法使用的MembershipService是不同的。
v2.5版中,使用的是PSEMembershipService;v2.6版中使用的是NoneMembershipService;而v2.7版中又回到了PSEMembershipService。在《Practical JXTA II》中(P127),有这样的说明,PSE Membership Service是默认的Membership Service,虽然该书基于JXTA v2.6版本(显然与源代码冲突)。
 
 #####################################################################
晕了,还是不行,启动时抛异常(网上没有解决方法):
SEVERE: EndpointRouterMsg declared src address does not match the sender's address. tempMsgERM.getSrcAddress()=jxta://cbid-8A634329B1C84ABF9E489F006BDE4B9EC627F04A469202F565EB71A52CAFFDA303, tempEASuposedToBe=jxta://cbid-59616261646162614A78746150325033DD0327CEA6B0E911250B6820AF286AD703

两种解决方式:

1 使用v2.6版(还需要解决无法连接外网rdv的问题)

2 参考v2.6版(主要是ShadowPeerGroup.java),修改v2.7版,使用NoneMembershipService。

 
 我X,用v2.6版一切正常(现在连接外网rdv也没有问题了);还是以前的观点,v2.7版问题多多,只具有参考意义。
 
 
 

设置结点的ID为固定ID的更多相关文章

  1. 获取和设置用户id以及组id

    #include<unistd.h> uid_t getuid(void); uid_t geteuid(void);//获取有效用户id gid_t getgid(void); gid_ ...

  2. WordPress后台的文章、分类,媒体,页面,评论,链接等所有信息中显示ID并将ID设置为第一列

    WordPress后台默认是不显示文章.分类等信息ID的,查看起来非常不方便,不知道Wp团队出于什么原因默认不显示这个但可以使用Simply Show IDs插件来实现 不使用插件,其他网友的实现: ...

  3. 《UNIX环境高级编程》笔记--更改用户ID和组ID

    在unix系统中,特权是基于用户和组ID的,当程序需要增加特权,或需要访问当前并不允许访问的资源时,我们需要更换自己 用户ID或组ID,使的新ID具有合适的特权或访问权限.与此类似,当程序需要降低其特 ...

  4. 进程控制之更改用户ID和组ID

    在UNIX系统中,特权(例如能改变当前日期的表示法以及访问控制(例如,能否读.写一特定文件))是基于用户ID和组ID的.当程序需要增加特权,或需要访问当前并不允许访问的资源时,我们需要更换自己的用户I ...

  5. Linux下文件权限(一)用户ID和用户组ID

    最近在读<unix环境高级编程>,看到文件权限这里比较糊涂,主要设计多个用户ID和用户组ID,包括下面两个: (1)实际用户ID和实际用户组ID:这一部分表示我们究竟是谁.这两个字段在登录 ...

  6. 用户id,组id和文件访问权限

    实际用户ID和实际组ID:标示了我们究竟是谁,这两个字段在登录时取自口令文件中的登录项 有效用户ID和有效组ID以及附属组ID:决定了我们的文件的访问权限(通常有效用户ID等于实际用户ID,有效组ID ...

  7. 多进程编程之用户ID和用户组ID

      实际用户ID(real user id):用于在系统中标识一个用户是谁,当用户使用用户名和密码成功登录后一个UNIX系统后就唯一确定了他的uid:(实际用户组ID类似) 有效用户ID(effect ...

  8. 现有某电商网站用户对商品的收藏数据,记录了用户收藏的商品id以及收藏日期,名为buyer_favorite1。 buyer_favorite1包含:买家id,商品id,收藏日期这三个字段,数据以“\t”分割

    实验内容(mapReduce安装请按照林子雨教程http://dblab.xmu.edu.cn/blog/631-2/) 现有某电商网站用户对商品的收藏数据,记录了用户收藏的商品id以及收藏日期,名为 ...

  9. 更改用户id 和组id

    转自 http://blog.csdn.net/todd911/article/details/16370577 在unix系统中,特权是基于用户和组ID的,当程序需要增加特权,或需要访问当前并不允许 ...

随机推荐

  1. QTP鼠标点击和浏览器事件的动态切换

    今天在群里有人问到一个问题,我觉得应该会有很多人会碰到,今天根据自己的思路把这个解决方案整理出来,供自己和大家参考 需求描述: 当输入一个身份证号码的时候,这个号码所对应的数据会被加载到所属的省和市的 ...

  2. 07-语言入门-07-A Famous Music Composer

    题目地址: http://blog.csdn.net/sevenmit/article/details/8231994  描述 Mr. B is a famous music composer. On ...

  3. mac下app store 无法完成您的购物操作

    最近在mac下使用app store 的时候出现提示:“我们无法完成您的购物操作 网络连接已中断”.但是我的网络是好的,图片如下: 网上找了各种解决办法,比如将DNS改成 114.114.114.11 ...

  4. BZOJ2086: [Poi2010]Blocks

    题解: 想了想发现只需要求出最长的一段平均值>k即可. 平均值的问题给每个数减去k,判断是否连续的一段>0即可. 然后我们发现如果i<j 且 s[i]<s[j],那么 j 对于 ...

  5. C#计算程序执行速度

    long t1 = DateTime.Now.Ticks; //执行程序,例如处理100个文件 long t2 = DateTime.Now.Ticks; Response.Write("执 ...

  6. sqlserver错误"试图扩大物理文件时,MODIFY FILE 遇到操作系统错误 112(磁盘空间不足。)。"处理

    正常还原的时候报错: Microsoft SQL-DMO (ODBC SQLState: 42000)---------------------------试图扩大物理文件时,MODIFY FILE  ...

  7. HDU 5296 Annoying problem (LCA,变形)

    题意: 给一棵n个节点的树,再给q个操作,初始集合S为空,每个操作要在一个集合S中删除或增加某些点,输出每次操作后:要使得集合中任意两点互可达所耗最小需要多少权值.(记住只能利用原来给的树边.给的树边 ...

  8. AngularJS 拦截器和应用例子(转)

    $httpAngularJS 的 $http 服务允许我们通过发送 HTTP 请求方式与后台进行通信.在某些情况下,我们希望可以俘获所有的请求,并且在将其发送到服务端之前进行操作.还有一些情况是,我们 ...

  9. BOM浏览器对象模型和API速查

    什么是BOMBOM是Browser Object Model的缩写,简称浏览器对象模型BOM提供了独立于内容而与浏览器窗口进行交互的对象由于BOM主要用于管理窗口与窗口之间的通讯,因此其核心对象是wi ...

  10. RMAN 备份详解

    一.数据库备份与RMAN备份的概念 1.数据库完全备份:按归档模式分为归档和非归档 归档模式 打开状态,属于非一致性备份        关闭状态,可以分为一致性和非一致性 非归档模式 打开状态,非一致 ...