XMPP implementation in silverlight authentication returns failure - silverlight

I am trying to implement Xmpp protocol in silverlight and trying to connect to Facebook, here I am getting everything correct until <challenge .. > obtained from server.
I am using X Facebook platform authentication.
I have done this with following code:
byte[] ch = Convert.FromBase64String(message.challenge);
string challenge = System.Text.Encoding.UTF8.GetString(ch, 0, ch.Length);
string response = "";
long callId = DateTime.UtcNow.Ticks;
MD5 md = new MD5();
String signature1 = "api_key=203366556348506"
+ "call_id=" + callId
+ "method=auth.xmpp_login"
+ param[2]
+ "session_key=" + messageClient.SessionKey
+ "v=1.0"
+ messageClient.AppSecret;
md.Value = signature1;
response = "method=auth.xmpp_login&api_key=203366556348506&session_key=bc6d6e00462cc2bb73a824bd.4-100001565408667&call_id=" + callId + "&sig=c47d741cb8f18c4e78b990f48e2f63aa&v=1.0&" + param[2];
message.Request = "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(response)) + "</response>";
this.messageClient.SendMessageAsync(message);
But I am getting following message from server:
<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>
Please let me know where I am going wrong.

Try following code:
String signature1 = "api_key=" + messageClient.ApiKey
+ "call_id=" + callId
+ "method=auth.xmpp_login"
+ param[2]
+ "session_key=" + messageClient.SessionKey
+ "v=1.0"
+ messageClient.AppSecret;
md.Value = signature1;
response = "method=auth.xmpp_login&api_key=" + messageClient.ApiKey + "&session_key=" + messageClient.SessionKey + "&call_id=" + callId + "&sig=" + md.FingerPrint.ToLower() + "&v=1.0&" + param[2];
I have changed response string to the one above.
This has returned success for me. Hope this will help you.

Related

Why my R seems take forever to run a Mixed effects logistic regression

I indeed got a relatively big dataset and my mixed effects logistic regression is like below. Is that normal to take that long to run? or I made some mistakes?
library(lme4)
glmer_EBRD_undersample_1 <- glmer(leave_happened ~
performance_rating_2016 + performance_rating_2017 + performance_rating_2018 + performance_rating_2019 + performance_rating_2020
+ gender
+ target_group
+ target_pmf_band
+ target_hq_or_ro
+ target_office_location_country_distilled
+ target_org_unit_cost_centre_code_distilled
+ target_ebrd_region_distilled
+ target_contract_group_distilled
+ target_position_tenure_group
+ target_length_of_service_group_distilled
+ leaves_to_date
+ moves_to_date
+ joins_to_date
+ applied_count_to_date
+ line_reviewed_to_date
+ interviewed_to_date
+ offered_to_date
+ hired_to_date
+ (1 | person_id)
,
data = train_undersample_1,
family = binomial,
control = glmerControl(optimizer = "bobyqa"),
nAGQ = 10
)
summary(glmer_EBRD_undersample_1)
Also gave a warning like this: Warning in commonArgs(par, fn, control, environment()) :
maxfun < 10 * length(par)^2 is not recommended.

Image require with variable path not working

Actually trying to check if file(image) exists to add it to render.
Confused that this code works
let i = 2;
let s = require('../../public' + this.cardData.image.optional_path + '-' + i + '.jpg');
and as a result s = Module
And this one produce an error
let i = 2;
let path = '../../public' + this.cardData.image.optional_path + '-' + i + '.jpg';
let z = require(path);
Error message:
Uncaught Error: Cannot find module '../../public/images/catgory1/images-2.jpg'
Did i missed something ?

How to create azure file storage SAS url(without azure libraries)?

My main target is to create a SAS url (without azure libraries)for file.
I tried to create azure storage SAS with blob and everything worked correctly. When I try to do the same in File i got an error. This is my code:
string azAccName = "AccountName";
string resource = "/upgfile/prt.png";
string endPoint = "https://" + azAccName + ".file.core.windows.net";
string uri = endPoint + resource;
string _now = DateTime.UtcNow.ToString("s") + "Z";
string _noww = DateTime.UtcNow.AddHours(3).AddMinutes(5).ToString("s") + "Z";
string StorageKey = "xxx";
string signedpermissions = "r";
string signedstart = _now;//"2017-02-14"; //yyyy-mm--dd
string signedexpiry = _noww;// "2017-02-14";
string canonicalizedresource = "/file/" + azAccName + resource; //"/blob/myaccount/music/intro.mp3"
string signedidentifier = ""; //YWJjZGVmZw==
string signedIP = "";
string signedProtocol = "https";
string signedversion = "2015-02-21";
string rscc = ""; //Cache-Control
string rscd = "file; attachment"; //Content-Disposition
string rsce = ""; //Content-Encoding
string rscl = ""; //Content-Language
string rsct = "binary"; //Content-Type binary
string StringToSign = signedpermissions + "\n" +
signedstart + "\n" +
signedexpiry + "\n" +
canonicalizedresource + "\n" +
signedidentifier + "\n" +
signedversion + "\n" +
rscc + "\n" +
rscd + "\n" +
rsce + "\n" +
rscl + "\n" +
rsct;
HMACSHA256 hmac = new HMACSHA256(Convert.FromBase64String(StorageKey));
string signature = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(StringToSign)));
string link = String.Format("{0}?sv={1}&st={2}&se={3}&sr={4}&sp={5}&rscd={8}&rsct={9}&spr={6}&sig={7}",
uri,
signedversion,
signedstart,
signedexpiry,
"c", //b for blob
signedpermissions,
"https",
signature.Replace("/", "%2"),
rscd,///////////////
rsct);
I am getting this error.
<Error>
<Code>AuthenticationFailed</Code>
<Message>
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:92eda75a-001a-0072-501d-1bb6fd000000 Time:2017-08-22T08:03:58.6115733Z
</Message>
<AuthenticationErrorDetail>Signature fields not well formed.</AuthenticationErrorDetail>
</Error>
I have almost the same code for blob(small differences) and it works correctly.
Any suggestions?
I believe the issue is missing parameters in your stringToSign. You must include all parameters as specified here:
StringToSign = signedpermissions + "\n" +
signedstart + "\n" +
signedexpiry + "\n" +
canonicalizedresource + "\n" +
signedidentifier + "\n" +
signedIP + "\n" +
signedProtocol + "\n" +
signedversion + "\n" +
rscc + "\n" +
rscd + "\n" +
rsce + "\n" +
rscl + "\n" +
rsct
If you're not using a parameter (for example signedIP in your case), you must specify an empty line.
Based on this, your StringToSign should be:
string StringToSign = signedpermissions + "\n" +
signedstart + "\n" +
signedexpiry + "\n" +
canonicalizedresource + "\n" +
signedidentifier + "\n" +
"\n" + //For signed IP
"\n" + //For signed Protocol
signedversion + "\n" +
rscc + "\n" +
rscd + "\n" +
rsce + "\n" +
rscl + "\n" +
rsct;
Furthermore sr (signed resource type) in the link should be f (for file) instead of c that you're using.

Apache camel route from kafka to another kafka topic on error

I am using Apache Camel to consume messages from kafka topic and then process the message, while processing if an exception occurs, I redirect that message to another kafka topic and process that in separate route. so I have a route something like below.
from ("kafka1").process("someProcessor").end();
onException(Throwable.class).process(exchange->{exchange.getIn().setBody("Message with error details")}).to("kafka2");
Above code is actually sending the error message in same kafka (kafka1).
I solved this by setting exchange.getIn().setHeader(KafkaConstants.TOPIC,"kafka2")) in onException process. Is this expected behavior? why would it ignore kafka2 and use kafka1 instead?
Version of camel used - 2.14.0
Kafka endpoint URLs:
Consumer:
from("kafka:" + ("kafka.broker") + "?topic="
+ ("offer.kafka.topic")
+ "&zookeeperHost=" + ("kafka.zookeeper.host")
+ "&zookeeperPort=" + ("kafka.zookeeper.port")
+ "&groupId=" + ("offer.kafka.group.id")
+ "&consumerStreams=" + ("kafka.streams")
+ "&autoCommitIntervalMs=" + ("product.kafka.consumer.auto.commit.intervals")
+ "&zookeeperConnectionTimeoutMs=" + ("zookeeper.connection.timeout")
+ "&rebalanceMaxRetries=" + ("kafka.rebalance.max.retries")
+ "&rebalanceBackoffMs=" + ("kafka.rebalance.backoffs.ms")
+ "&zookeeperSessionTimeoutMs=" + ("zookeeper.session.timeout")
+ "&autoOffsetReset=" + ("kafka.auto.offset.reset")
+ "&fetchMessageMaxBytes=" + ("kafka.fetch.message.max.bytes")
+ "&socketReceiveBufferBytes=" + ("receive.buffer.bytes"))
.routeId("offerEventRoute").to("direct:offerEventRoute");
Producer:
to("kafka:" + ("error.kafka.broker") + "?topic="
+ ("error.kafka.topic")
+ "&zookeeperHost=" + ("error.kafka.zookeeper.host")
+ "&zookeeperPort=" + ("error.kafka.zookeeper.port")
+ "&groupId=" + ("error.kafka.group.id")
+ "&zookeeperConnectionTimeoutMs=" + ("error.zookeeper.connection.timeout")
+ "&rebalanceMaxRetries=" + ("rebalance.max.retries")
+ "&rebalanceBackoffMs=" + ("rebalance.backoffs.ms")
+ "&zookeeperSessionTimeoutMs=" + ("zookeeper.session.timeout")
+ "&autoOffsetReset=" + ("auto.offset.reset")
+ "&messageSendMaxRetries=" + ("error.max.retries")
+ "&serializerClass=kafka.serializer.StringEncoder"
);
You need to set the bridgeEndPoint to true in your producer kafka end point. Otherwise it looks for the topic name in the exchange headers and uses that as the topic name for the producer also.
By default it is false.
Can you please provide few more details about the code like,
1) Version of camel used
2) Your Kafka endpoint URL.
By any chance are you using 'bridgeEndpoint' attribute in your endpoint URL..

How to read msExchMailboxSecurityDescriptor attribute in C#

I am trying to read all the user attributes in AD.
How to read msExchMailboxSecurityDescriptor attribute in C# ?
I used the following code but I got a cast error. Any suggestions would be welcome.
DirectoryObjectSecurity oSec = new ActiveDirectorySecurity();
oSec.SetSecurityDescriptorBinaryForm((byte[])val);
String m_Value = oSec.GetSecurityDescriptorSddlForm(AccessControlSections.All);
return m_Value;
Ok. I was able to figure it out. The code is given below for anyone interested. I wish Microsoft had put out some code samples so that people do not have to break their heads.
SecurityDescriptor sd = (SecurityDescriptor) p_InputValue;
AccessControlList acl = (AccessControlList)sd.DiscretionaryAcl;
String m_Trustee = "";
String m_AccessMask = "";
String m_AceType = "";
String m_ReturnValue="";
foreach (AccessControlEntry ace in (IEnumerable)acl)
{
m_Trustee = m_Trustee + "," + ace.Trustee;
m_AccessMask = m_AccessMask + "," + ace.AccessMask.ToString();
m_AceType = m_AceType + "," +ace.AceType.ToString();
}
m_ReturnValue="Trustee: " + m_Trustee + " " + "AccessMask: " + m_AccessMask + "AceType: " + m_AceType;
return m_ReturnValue

Resources