ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexGeneral DiscussionMQCSP for Perl

Post new topicReply to topic
MQCSP for Perl View previous topic :: View next topic
Author Message
garbagedook
PostPosted: Mon Mar 23, 2009 1:48 pm Post subject: MQCSP for Perl Reply with quote

Novice

Joined: 15 May 2006
Posts: 11

Hi folks,

I am able to send the MQCSP (MQConnectionSecurityParameters) using a MQSecurityExit in Java.

Does anyone know how I would do this in Perl? I tried specifying a SecurityParms hash in the ConnectOpts and used that in MQCONNX but it doesn't seem to be sending it over...

Thanks,
Duke
Back to top
View user's profile Send private message
gbaddeley
PostPosted: Mon Mar 23, 2009 5:40 pm Post subject: Re: MQCSP for Perl Reply with quote

Jedi

Joined: 25 Mar 2003
Posts: 2026
Location: Melbourne, Australia

garbagedook wrote:
Hi folks,

I am able to send the MQCSP (MQConnectionSecurityParameters) using a MQSecurityExit in Java.

Does anyone know how I would do this in Perl? I tried specifying a SecurityParms hash in the ConnectOpts and used that in MQCONNX but it doesn't seem to be sending it over...

Thanks,
Duke


Did you sent the ConnectOpts to at least version 5 ?
_________________
Glenn
Back to top
View user's profile Send private message
garbagedook
PostPosted: Tue Mar 24, 2009 11:06 am Post subject: Reply with quote

Novice

Joined: 15 May 2006
Posts: 11

hi,

Thanks for the reply.

I set it to MQCNO_CURRENT_VERSION. There doesn't seem to be a version 5 in perl.

This is what my ConnectOpts structure looks like:

my $ConnectOpts =
{
ClientConn =>
{
Version => MQCD_VERSION_6,
ChannelName => $channel,
TransportType => 'TCP',
ConnectionName => $host . "(" . $port . ")",
},
StrucId => MQCNO_STRUC_ID,
Version => MQCNO_CURRENT_VERSION,
Options => MQCNO_STANDARD_BINDING,
SecurityParms =>
{
AuthenticationType => 1, # there is no MQCSP_AUTH_USER_ID_AND_PWD in perl?
CSPUserId => 'user',
CSPPassword => 'pass',
}
};


Have you ever sent the MQCSP to the OAM using Perl? If you had some sample code that would be great.
Back to top
View user's profile Send private message
gbaddeley
PostPosted: Tue Mar 24, 2009 5:49 pm Post subject: Reply with quote

Jedi

Joined: 25 Mar 2003
Posts: 2026
Location: Melbourne, Australia

garbagedook wrote:
..
I set it to MQCNO_CURRENT_VERSION. There doesn't seem to be a version 5 in perl.


What does MQCNO_CURRENT_VERSION equate to?

Quote:
Have you ever sent the MQCSP to the OAM using Perl? If you had some sample code that would be great.


No, I'm not a Perl programmer, so I don't really understand your code. You could try just setting the CNO Version field to 5.

What version of MQ are you using? The CSP fields first appeared in V6.0.

In C the code looks like this:

Code:
MQCNO    MyConnOpt = { MQCNO_DEFAULT };  /* connection options    */
MQCD     MyChlDef = { MQCD_DEFAULT };    /* channel definition    */
MQCSP    MySecParm = { MQCSP_DEFAULT };  /* security parameters   */

....

      MyConnOpt.Version = MQCNO_VERSION_5;
      MyConnOpt.SecurityParmsPtr = &MySecParm;
      MyConnOpt.ClientConnPtr = &MyChlDef;

      strncpy( MyChlDef.ChannelName, ClntChan, sizeof(MyChlDef.ChannelName) );
      MyChlDef.ChannelType = MQCHT_CLNTCONN;
      MyChlDef.TransportType = MQXPT_TCP;
      strncpy( MyChlDef.QMgrName, QMgrName, sizeof(MyChlDef.QMgrName) );
      strncpy( MyChlDef.ConnectionName, ClntHostPort, sizeof(MyChlDef.ConnectionName) );

      MySecParm.CSPUserIdPtr = CspUserId;
      MySecParm.CSPUserIdLength = strlen(CspUserId);
      MySecParm.CSPPasswordPtr = CspPassword;
      MySecParm.CSPPasswordLength = strlen(CspPassword);


MQCONNX( QMgrName, &MyConnOpt, &Hcon, &CompCode, &ReasonCode );

HTH,
_________________
Glenn
Back to top
View user's profile Send private message
garbagedook
PostPosted: Wed Mar 25, 2009 8:18 am Post subject: Reply with quote

Novice

Joined: 15 May 2006
Posts: 11

Hi folks,

As I suspected, this is not supported in the Perl MQ API. Right now you cannot pass the MQCSP structure using Perl.

The author of ther Api, Hildo Biersma, was nice enough to let me know that.

Thanks,
Duke
Back to top
View user's profile Send private message
garbagedook
PostPosted: Mon Apr 20, 2009 8:49 am Post subject: Reply with quote

Novice

Joined: 15 May 2006
Posts: 11

hello folks,

Surprisingly, I got this to work by hacking/patching the latest source for the MQ perl api (version 1.28b)

I modified 31MQCONNX-v5 in the MQClient/MQSeries.xs.in directory in the tarball.

Here are the key changes in bold

#ifdef MQCNO_VERSION_4
MQSCO SSLConfigOpts = { MQSCO_DEFAULT };
#endif
#ifdef MQCNO_VERSION_5
MQCSP SecurityParms = { MQCSP_DEFAULT };
#endif



#endif /* MQCNO_VERSION_4 */
#ifdef MQCNO_VERSION_5
/*
SecurityParms represents the hash entry for ConnectOpts
(Contributed by Duke Nguyen)
*/
if (hv_exists((HV*)SvRV(ST(1)),"SecurityParms",13)) {
SV **cvp, **elem;
HV *options;
int FieldSize;
STRLEN UserLength;
STRLEN PassLength;
char *user;
char *pass;

/* warn("Using SecurityParms options to set MQCSP"); */
ConnectOpts.SecurityParmsOffset = 0;
ConnectOpts.SecurityParmsPtr = &SecurityParms;
ConnectOpts.Version = MQCNO_VERSION_5;
cvp = hv_fetch((HV*)SvRV(ST(1)),"SecurityParms",13, FALSE);
if ( !SvROK(*cvp) || ( SvROK(*cvp) &&
SvTYPE(SvRV(*cvp)) != SVt_PVHV ) ) {
warn("Invalid data for SecurityParms, not a HASH reference\n");
XSRETURN_EMPTY;
}
options = (HV*)SvRV(*cvp);

/* Version */
elem = hv_fetch(options, "Version", 7, FALSE);
if (elem) {
SecurityParms.Version = SvIV(*elem);
}

/* AuthenticationType */
elem = hv_fetch(options, "AuthenticationType", 18, FALSE);
if (elem) {
SecurityParms.AuthenticationType = SvIV(*elem);
}

/* CSPUserId */
elem = hv_fetch(options, "CSPUserId", 9, FALSE);
if (elem) {
user = SvPV(*elem, UserLength);
SecurityParms.CSPUserIdPtr = user;
SecurityParms.CSPUserIdOffset = 0;
SecurityParms.CSPUserIdLength = strlen(user);
}
/* CSPPassword */
elem = hv_fetch(options, "CSPPassword", 11, FALSE);
if (elem) {
pass = SvPV(*elem, PassLength);
SecurityParms.CSPPasswordPtr = pass;
SecurityParms.CSPPasswordOffset = 0;
SecurityParms.CSPPasswordLength = strlen(pass);
}
} else {
/* warn("SecurityParms options not present"); */
}
#endif /* MQCNO_VERSION_5 */


MQCONNX(Name,&ConnectOpts,&RETVAL,&CompCode,&Reason);
}

Then just rebuild and you can pass the MQCSP.

I will probably contribute this back to the author. Just waiting on confirmation from my company.
Back to top
View user's profile Send private message
garbagedook
PostPosted: Fri Jun 26, 2009 8:27 am Post subject: Reply with quote

Novice

Joined: 15 May 2006
Posts: 11

hi folks,

FYI, I worked w/ the author Hildo Biersma on this and he released a new 1.29 version of the Perl MQ libraries on CPAN.

It now includes support for the MQCSP, as well as a slew of other new features.

Check it out on CPAN.

Thanks,
Duke
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexGeneral DiscussionMQCSP for Perl
Jump to:



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.