Skip to main content

[JXSE 2.6] Problems joining to a peergroup

12 replies [Last post]
jtanago
Offline
Joined: 2008-06-18
Points: 0

Hi!

Have there been changes when joining a group? I can't use the code that I wrote to join to a group, now the method isReadyForJoin always return false.

PeerGroup group = netpg.newGroup(id, impAdv, name, description);
AuthenticationCredential myAuthCred =
new AuthenticationCredential(group, null, null);
MembershipService membershipService = group.getMembershipService();
Authenticator myAuthenticator = membershipService.apply(myAuthCred);
if (!myAuthenticator.isReadyForJoin()) {
[....]
return false;
}

With JXSE 2.5 it works perfectly. Thanks!

My system:

ArchLinux - Kernel 2.6.33 (64bits)
Java 1.6.0_20 (64bits)
JXSE 2.6 Beta 2

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
shaikh_sharique
Offline
Joined: 2010-06-17
Points: 0

hi,
I created a peergroup using this given code.
but in this code following code is depricated.

StdPeerGroupParamAdv paramAdv = new StdPeerGroupParamAdv();

is there any alternative way to this ?

adamman71
Offline
Joined: 2007-01-31
Points: 0

Not yet, see the Javadoc for this class.

adamman71
Offline
Joined: 2007-01-31
Points: 0

Hi,

There has been some refactoring, but no functional changes. I have tried to replicate your issue with the code in attachment.

The authenticator I get is a DialogAuthenticator on top of a StringAuthenticator. The isReadyForJoin() method has not been modified by 2.6. It does return false with 2.6 though.

When I take a look at the code:

synchronized public boolean isReadyForJoin() {
if (null != seedCert) {
return null != PSEUtils.pkcs5_Decrypt_pbePrivateKey(key_password, seedCert.getPublicKey().getAlgorithm(), seedKey);
} else {
return source.pseStore.validPasswd(identity, store_password, key_password);
}
}

I am wondering whether this is a set-up issue... Are you using those features?

Jérôme (AdamMan71)

jtanago
Offline
Joined: 2008-06-18
Points: 0

I've run your code and it returns false with 2.6, but with 2.5 it returns true. It's rare...

jtanago
Offline
Joined: 2008-06-18
Points: 0

Any news? I think that it's an important bug that makes the 2.6 version useless. Thanks

adamman71
Offline
Joined: 2007-01-31
Points: 0

No worry, I have not forgotten.

jtanago
Offline
Joined: 2008-06-18
Points: 0

Ok, thank you very much!

adamman71
Offline
Joined: 2007-01-31
Points: 0

I have opened an issue: https://jxta-jxse.dev.java.net/issues/show_bug.cgi?id=373.

The bottom line is:

a) There is a regression at the NPG level where the membership should be free for everyone, the patch corrects this issue.

b) Application is working as designed when your create standard groups using the
getAllPurposePeerGroupImplAdvertisement(), since there had been an agreement to make the PSEMembership service the default for such groups after 2.5.

Now, if you need to create subgroups where access is free, you can create the corresponding module implementation advertisement as following:

...

ModuleImplAdvertisement implAdv =
CompatibilityUtils.createModuleImplAdvertisement(
MyPeerGroupID, PeerGroup.class.getName(), "My description");

// Build the param section (I know this is deprecated code, but we'll take care of this later).
StdPeerGroupParamAdv paramAdv = new StdPeerGroupParamAdv();

// "Core" Services
paramAdv.addService(PeerGroup.endpointClassID, PeerGroup.refEndpointSpecID);
paramAdv.addService(PeerGroup.resolverClassID, PeerGroup.refResolverSpecID);
paramAdv.addService(PeerGroup.membershipClassID, NoneMembershipService.noneMembershipSpecID);
paramAdv.addService(PeerGroup.accessClassID, PeerGroup.refAccessSpecID);

// "Standard" Services
paramAdv.addService(PeerGroup.discoveryClassID, PeerGroup.refDiscoverySpecID);
paramAdv.addService(PeerGroup.rendezvousClassID, PeerGroup.refRendezvousSpecID);
paramAdv.addService(PeerGroup.pipeClassID, PeerGroup.refPipeSpecID);
paramAdv.addService(PeerGroup.peerinfoClassID, PeerGroup.refPeerinfoSpecID);
paramAdv.addService(PeerGroup.contentClassID, ContentServiceImpl.MODULE_SPEC_ID);

// Pour newParamAdv in -> implAdv
XMLElement paramElement = (XMLElement) paramAdv.getDocument(MimeMediaType.XMLUTF8);

implAdv.setParam(paramElement);

return implAdv;

...

jtanago
Offline
Joined: 2008-06-18
Points: 0

Hi, this leaves me a question

Our application has its own authentication method to join a private group, would be safe to keep using NoneMembershipService or should we use PSEMembershipService?

Thanks

adamman71
Offline
Joined: 2007-01-31
Points: 0

If you have your own, then you probably don't need any extra method, so I would go for the nonemembership in your case. It would make things simpler.

jtanago
Offline
Joined: 2008-06-18
Points: 0

Hi, I've just come back to use 2.6 and I still have a problem when joining to a peergroup.

Here is the code:

{{{
PeerGroup group = MyNetPeerGroup.newGroup(advertisement);
AuthenticationCredential authCred =
new AuthenticationCredential(group, null, null);
MembershipService mService = group.getMembershipService();
Authenticator myAuthenticator = mService.apply(miAuthCre);
if (!myAuthenticator.isReadyForJoin()) {
System.out.println("Authenticator incomplete");
return;
}
}}}

If I join a group just after I had created it there is no problem because I use the PeerGroup object returned by newGroup(PGID, ImplAdv, Name, Description) but if I want to join to a new group (using discoveryservice), I need to use the method newGroup(Advertisement). In 2.5 it worked perfectly but now it always returns false in isReadyForJoin()

adamman71
Offline
Joined: 2007-01-31
Points: 0

> but if I want to join to a new group (using discoveryservice)
You mean the membership service I guess?!?
When you create your new AuthenticationCredential(group, null, null) object, you don't provide any value for the 2nd parameter (i.e., the "method"). The meaning of this value depends on the corresponding membership service implementation. If it is the PSEMembershipService, the returned authenticator type is DialogAuthenticator (by default), which is based on StringAuthenticator. The latter implements isReadyForJoin() as following:
synchronized public boolean isReadyForJoin() {
if (null != seedCert) {
Logging.logCheckedFine(LOG, "seed certificate:\n", seedCert.toString());
return null != PSEUtils.pkcs5_Decrypt_pbePrivateKey(key_password, seedCert.getPublicKey().getAlgorithm(), seedKey);
} else {
Logging.logCheckedFine(LOG, "null seed certificate");
return source.getPSEConfig().validPasswd(identity, store_password, key_password);
}
}
This may give you some idead about what is happening.
If you are using the NoneMembershipService, the returned object is a none authenticator, which implements isReadyToJoin() as following:
synchronized public boolean isReadyForJoin() {
Logging.logCheckedFine(LOG, "Always ready to join");
// always ready.
return true;
}
If you use the PasswdMembershipService, the returned authenticator is of type PasswdAuthenticator, which implements isReadyToJoin() as following:
synchronized public boolean isReadyForJoin() {
if ( null == password )
Logging.logCheckedFine(LOG, "null password");
if ( null == password )
Logging.logCheckedFine(LOG, "null whoami");
return ((null != password) && (null != whoami));
}
I don't exactly know what could cause the different behavior between 2.5 and 2.6. However, I do remember (on top of my head) that the PSE Membership was made the default membership group for both the NetPeerGroup and any 'standard' newGroup shortly after 2.5 release. This may have had an impact on your code. You could check this by calling getClass() on the returned membership service object in 2.5 and 2.6 and see if there is a difference...