TLV Parameters in Kannel - smpp

My SMS service provider asked me to set the below TLV parameters while connecting to him over SMPP:
PRICEPOINT (0x1400)
PRODUCT (0x1401)
PARTNER ROLE ID (0x1402)
How to configure the same in Kannel as it is the first time for me using this SMPP client app, I set the below data in Kannel.conf file, but when I pushed/sent a message, the gateway didn't feel the TLV which I have set.
group = smpp-tlv
name = PRICEPOINT
tag = 0x1400
type = integer
length = 4
smsc-id = SMSC01
group = smpp-tlv
name = PRODUCT
tag = 0x1401
type = integer
length = 4
smsc-id = SMSC01
group = smpp-tlv
name = PARTNERROLEID
tag = 0x1402
type = integer
length = 4
smsc-id = SMSC01
But in the live TCP trace, I didn't find it:

You did the right thing with the configuration but what it does is that it simply informs Kannel as to what possible TLV parameters exist for the SMSC.
To actually use them, you have to set the values in the sendsms call in a meta-data parameter formatted like this ?smsc-type?key1=value1&key2=value2&key3=value3... You must take into account that when constructing this string, the smsc-type, the keys and the values must be urlencoded, and then the whole resulting string has to be urlencoded again.
In your case it would look something like this: http://host:port/cgi-bin/sendsms?username=user&password=password&to=recipientphone&from=senderphone&text=content&smsc=smsc&meta-data=%3Fsmpp%3FPRICEPOINT%3D1%26PRODUCT%3D2%26PARTNERROLEID%3D3.
The %3Fsmpp%3FPRICEPOINT%3D1%26PRODUCT%3D2%26PARTNERROLEID%3D3 in the example is urlencoded ?smpp?PRICEPOINT=1&PRODUCT=2&PARTNERROLEID=3.
Here's the relevant section in the documentation: http://kannel.org/download/1.4.4/userguide-1.4.4/userguide.html#AEN6370

Related

Rest Assured Java : How to obtain id in the response not in json format

I need to obtain the response of an endpoint that returns a number but not in json format, only a number returns. When I try to do response.prettyprint() I didnt see nothing in the console. Is there any way to obtain that number in the response? Thanks!
To print that information, just use:
Response res = ...
res.print();
To get Infor, save Response as String then convert type to int
String res = ...asString();
int number = Integer.valueOf(res);

pingfederate as a adfs claim provider

I'm trying to setup PingFederate as a claim provider in ADFS with the intention that I federate from a PF realm through ADFS to an ADFS RP. I want ADFS to add attributes from Active Directory to the assertion before sending it to the RP. PingFederate is only sending the user's Windows login ID. On the Claim Provider side I'm passing through Name ID. Just for testing, I have tried adding an attribute like this:
c:[Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"]
=> add(Type = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", Value = "myemail#test.com");
I added this on the CP side both above and then below my pass through rule and nothing was added to my assertion. I also tried this on the RP side with no luck.
I guess my question is whether this is possible in ADFS. Ultimately I would like PingFed to send the user's login ID as the name ID, have ADFS lookup the user in Active Directory and add the email address as a claim then send the assertion to the RP. As for adding the attribute from Active Directory, I found this post technet.microsoft.com/en-us/library/ff678048.aspx. Problem is I can't even add a manual value.
For a manual value, use something like:
=> issue(type = "http://contoso.com/partner", value = "Adatum");
For the query, use something like:
Use the normal LDAP rule to produce a loginID claim and then
c:[Type == "http://company.com/claims/loginID", Issuer == "AD AUTHORITY"]
=> issue(store = "Active Directory", types = ("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"), query = ";email;{0}", param = c.Value);
I figured this out. My first use case is to ensure that the AD account exists.
Essentially what is required are 3 claim rules on the CP side:
1 - perform the lookup based on the name ID. I created a custom rule to
c:[Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"]
=> add(store = "Active Directory", types = ("http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid"), query = "sAMAccountName={0};objectSID;{1}", param = c.Value, param = "MYDOMAI\" + c.Value);
The parameters required in for the query are:
LDAP query to locate the user
Attribute(s) to extract
User's login ID in the format DOMAIN\userid
2 - a claim rule to simply pass the name ID through
3 - a claim rule to simply pass the SID through
On the RP side, I have 2 claim rules to pass the name ID and the SID through. Then I have an Issuance Authorization Rule to ensure that the SID is present as a claim. This is a custom rules with the following:
EXISTS([Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid"])
=> issue(Type = "http://schemas.microsoft.com/authorization/claims/permit", Value = "PermitUsersWithClaim");
Seems convoluted but this is what I have. My second use case is to ensure the account is enabled, but I'm not sure if this is possible because the disabled attribute is stored as a bit in the userAccountControl attribute.

What kind of values can "Duration" accept in Rally?

I am using the RallyRestAPI and ideally I want to pass to a test case I am creating through the API a duration time in this format "MM:SS". I am passing for example, "9:45" (9 minutes, 45 seconds), but I get an error that .."9:45 cannot convert to a double". Does the duration field in Rally only accept double values or what other type of values can it accept? Thanks.
My code is something like this:
DynamicJsonObject tcresults = new DynamicJsonObject();
// ...
tcresults["Duration"] = "9:45";
I get the error when doing this line below:
CreateResult cr = _RallyApi.Create(_workspace, "TestCaseResults", tcresults);
According to the web service docs here it has to be a double. So "9:45" would be 9.75 instead.

How to get http response code from suds client when using faults

I'm using suds to call a Windows/WCF service like so:
# Setting up my client
client = Client(wsdl, transport = my_transport, location = url, faults = True, headers = my_soap_action_header, cache = None, wsse = my_http_security)
And, I'm getting a response something like this:
(Link){ Id = 12345 Type = "SomeType" }
I know from talking to the developer of the web service that the return value is the ID and type of the object returned, or it will throw an exception.
That said, I'm wondering how to interrogate the suds client for a normal http response code (e.g. 200).
I relise this is an old question but in case anyone else stumbles upon this i'll provide an answer.
you can setup the client with faults = False this then does not throw webFaults when error occur (so you'll have to implement your own error handeling) instead it returns a tuple with
(<status>, <returned-value>)
so for instance (taken from suds documentation)
client = client(url, faults=False)
result = client.service.addPerson(person)
print result
( 200, person ...)
hope that helps(if you ever look back here)

How can I generate date-dependent passwords?

I'm looking for a simple way to generate passwords that will only work once for a limited amount of time, e.g. 1 day, 1 week, 1 month. This has to be implemented in an application that has no connectivity so a server isn't possible. The use case is something like:
1. Generate password for a specific date and length of time.
2. Send to user (email, phone, etc).
3. User enters in application.
4. Application is enabled for a specific time.
5. Password cannot be reused, even on another PC.
I'm assuming the only way to do this is to generate passwords that only work between a specific set of dates. Can anyone recommend an algorithm that can do this? It doesn't have to be incredibly secure, and I know you can crack this by resetting the time on the PC!
Thanks.
I know I'm late but I'll provide my advice anyway in case someone else who needs it found their way here.
To prevent it being used on another PC, you could probably use the MAC address or hardware address. However, this is subject to the network hardware being still available when checking the password. Please make sure you use the hardware address of the machine where the password will be checked.
private string GetBase64Mac()
{
System.Net.NetworkInformation.NetworkInterface[] interfaces = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
if (interfaces.Length == 0)
{
System.Net.NetworkInformation.PhysicalAddress add = interfaces[0].GetPhysicalAddress();
if (add != null)
return System.Convert.ToBase64String(add.GetAddressBytes());
}
return "";
}
To limit it by some expiry date simply use the text string of the expiry date.
private string GetExpiryDate(DateTime expiryDate)
{
return expiryDate.ToString("yyyyMMdd");
}
Simply use a hash function to hash the combine expiry date, hardware address and a secret key. Prefix or suffix the hash output with the expiry date.
private void GeneratePassword(string prefix)
{
string secretKey = "MySecretKey";
System.Security.Cryptography.SHA1 sha = System.Security.Cryptography.SHA1.Create();
byte[] preHash = System.Text.Encoding.UTF32.GetBytes(prefix + secretKey + GetBase64Mac());
byte[] hash = sha.ComputeHash(preHash);
string password = prefix + System.Convert.ToBase64String(hash);
return password;
}
In the case above, i prefix the hash with the expiry date. So, when we check the password, we simply extract the expiry date from the password, use the same function to generate the same password. If the generated password match the provided password, then you have green light.
private void TestPassword()
{
int duration = 15; // in days
string prefix = GetExpiryDate(DateTime.Today.AddDays(duration));
string generated = GeneratePassword(prefix);
// Positive test
string testPrefix = generated.Substring(0, 8);
string testPassword = GeneratePassword(testPrefix);
if (generated != TestPassword)
return false;
// Negative test
generated[2] = '2';
generated[12] = 'b';
testPrefix = generated.Substring(0, 8);
testPassword = GeneratePassword(testPrefix);
if (generated != TestPassword)
return true;
return false;
}
Sample output password:
20110318k3X3GEDvP0LkBN6zCrkijIE+sNc=
If you can't get the hardware address, then simply use the customer's name. It won't prevent the password from being used in multiple machines, but it will ensure that the same person is using it.
Your application should have a attribute like validity for the password something like this
username password_hash validity_from Validity_end
xyz a73839$56 11-Nov-2010 12-Nov-2010
and then in your application you can validate that your password has expired or not
Generate passwords by any method you'd like (a word list, random letters, etc). Put them into some data structure, like an associative array, where you can associate a date with each password. Then you consult this data structure in the program that hands out passwords to give one out with the proper expiration date. The client program has the same list of passwords and dates, so when it gets a password, it just looks up the associated expiration date there.