FIXT.1.1:135->PSE, error> (Rejecting invalid message: quickfix.IncorrectTagValue: Value is incorrect (out of range) for this tag, field=528 field=528 - quickfix

We get the 528 tag error,
FIXT.1.1:135->PSE, error> (Rejecting invalid message: quickfix.IncorrectTagValue: Value is incorrect (out of range) for this tag, field=528 field=528:
FIXT.1.1:135->PSE, error> (Reject sent for Message 183: Value is incorrect (out of range) for this tag, field=528:528)
this is my configuration quickFix- BeginString=FIXT.1.1 DefaultApplVerID=9 StartTime=09:00:00 Asia/Manila EndTime=16:30:01 Asia/Manila HeartBtInt=30 ReconnectInterval=30 ResetOnLogon=Y ResetOnLogout=Y ResetOnDisconnect=Y CheckLatency=N MaxLatency=120**
when i'm getting incoming request from PSE, got the 528=L which is not exist in QuickFix class- public static final int FIELD = 528;public static final char AGENCY = 'A';public static final char PROPRIETARY = 'G';public static final char INDIVIDUAL = 'I';public static final char PRINCIPAL = 'P';public static final char RISKLESS_PRINCIPAL = 'R';public static final char AGENT_FOR_OTHER_MEMBER = 'W';
only these are the fields used in QuickFix class how can handle "L" Please help me. Thanks!

Obviously, your counterparty has added some custom values to the 528 enum.
You need to customize your DataDictionary xml file to match your counterparty's expectations. Ask them if they have an xml file they can give you, or else you'll need to use their interface spec as a guide and create your own.

Related

iText 7.1.14 'SymbolEncoding' is not a supported encoding name [duplicate]

I have a method in our software that pulls the text from a PDF, from a scan or text generated.
I usually try the GetTextFromPage() method first. If it doesn't return text, then I move onto OCR'ing the page.
I have a particular 6 page PDF with the first three pages being a scanned document, and the last two being a form.
On this PDF I'm getting an error that I can't figure out how to resolve.
'StandardEncoding' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
at System.Globalization.EncodingTable.internalGetCodePageFromName(String name)
at System.Globalization.EncodingTable.GetCodePageFromName(String name)
at iText.IO.Util.IanaEncodings.GetEncodingEncoding(String name)
at iText.IO.Util.EncodingUtil.ConvertToBytes(Char[] chars, String encoding)
at iText.IO.Font.PdfEncodings.ConvertToBytes(String text, String encoding)
at iText.IO.Font.FontEncoding.FillNamedEncoding()
at iText.IO.Font.FontEncoding.CreateFontEncoding(String baseEncoding)
at iText.Kernel.Font.PdfType1Font..ctor(PdfDictionary fontDictionary)
at iText.Kernel.Font.PdfFontFactory.CreateFont(PdfDictionary fontDictionary)
at iText.Kernel.Pdf.Canvas.Parser.PdfCanvasProcessor.GetFont(PdfDictionary fontDict)
at iText.Kernel.Pdf.Canvas.Parser.PdfCanvasProcessor.SetTextFontOperator.Invoke(PdfCanvasProcessor processor, PdfLiteral operator, IList`1 operands)
at iText.Kernel.Pdf.Canvas.Parser.PdfCanvasProcessor.InvokeOperator(PdfLiteral operator, IList`1 operands)
at iText.Kernel.Pdf.Canvas.Parser.PdfCanvasProcessor.ProcessContent(Byte[] contentBytes, PdfResources resources)
at iText.Kernel.Pdf.Canvas.Parser.PdfTextExtractor.GetTextFromPage(PdfPage page, ITextExtractionStrategy strategy, IDictionary`2 additionalContentOperators)
at iText.Kernel.Pdf.Canvas.Parser.PdfTextExtractor.GetTextFromPage(PdfPage page)
at EFR.OCR.OCR.ExtractTextFromPDF(FileInfo fileInfo, Int32 StartingPage, Int32 NumberOfPages) in P:\Cloud\Dropbox\EF Recovery\OCRTest\EFR.OCR\OCR.vb:line 113
I've processed many PDFs through my code, some text, some scans, some mixed together. Some had forms... This is the first time that I've had this error.
Here's a snippet of my code...
Using reader As New iText.Kernel.Pdf.PdfReader(fileInfo.FullName)
reader.SetUnethicalReading(True)
Using sourceDoc As New iText.Kernel.Pdf.PdfDocument(reader)
If NumberOfPages = 0 Then NumberOfPages = sourceDoc.GetNumberOfPages
For i As Integer = StartingPage To StartingPage + NumberOfPages - 1
Dim pageText As String = ""
Try
pageText = iText.Kernel.Pdf.Canvas.Parser.PdfTextExtractor.GetTextFromPage(sourceDoc.GetPage(i))
Catch ex As Exception
OCRLog.Log($"Error attempting to extract text from page {i}. {ex.ToString}")
End Try
If pageText = "" Then
'extract this page
Dim results As OCRResults = ExtractTextFromPDFImagePage(fileInfo.FullName, i)
pageText = results.Text
pageItems.Add(New OCRResults.PagesClass(results.Accuracy, True, pageText))
Else
pageItems.Add(New OCRResults.PagesClass(100, False, pageText))
End If
stringBuilder.Append(pageText)
Next
Return New OCRResults(stringBuilder.ToString, pageItems)
End Using
End Using
Any ideas?
There is an error in the PDF, just as indicated by the error text "'StandardEncoding' is not a supported encoding name.".
The fonts on the page you shared use the name StandardEncoding in their Encoding entries. This is not a valid name here. According to the specification ISO 32000-1 the only valid values here are MacRomanEncoding, MacExpertEncoding, and WinAnsiEncoding, see Table 111 – Entries in a Type 1 font dictionary – and Table 114 – Entries in an encoding dictionary.
Adobe Preflight also complains about these names when checking for syntax errors:
An unexpected value is associated with the key
Key: BaseEncoding
Value: /StandardEncoding
Type: CosName
Formal Representation: Encoding
Cos ID: 38
Traversal Path: ->Pages->Kids->[0]->Resources->Font->WARSP->Encoding
An unexpected value is associated with the key
Key: Encoding
Value: /StandardEncoding
Type: CosName
Formal Representation: Font.FontType1
Cos ID: 27
Traversal Path: ->Pages->Kids->[0]->Resources->Font->Arial,Bold
An unexpected value is associated with the key
Key: BaseEncoding
Value: /StandardEncoding
Type: CosName
Formal Representation: Encoding
Cos ID: 22
Traversal Path: ->Pages->Kids->[0]->Resources->Font->Arial->Encoding
An unexpected value is associated with the key
Key: BaseEncoding
Value: /StandardEncoding
Type: CosName
Formal Representation: Encoding
Cos ID: 19
Traversal Path: ->Pages->Kids->[0]->Resources->Font->ARROW->Encoding
(Excerpt from a preflight report for your shared PDF)
In spite of StandardEncoding not being a valid name here, the PDF specification knows a "Standard Encoding", see Annex D of ISO 32000-1. Most likely your document attempts to refer to that encoding at the locations outlined above.
If you need to extract text from the document in question, therefore, you may want to follow the recommendation of the error message:
For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
The Encoding class here is the one in System.Text.
To extract the text from your PDF, therefore, it should suffice to implement an EncodingProvider that for the name StandardEncoding provides an Encoding instance according to the information from the STD column of the table in Annex D.2 – Latin Character Set and Encodings – of ISO 32000-1.

How to - SHA1 hash of plaintext using SHA1CryptoServiceProvider in C++/CLI?

I want to hash a string but looking at the example on MSDN I got stuck on the DATA_SIZE. What is this? and how do I know ahead of time what the size of the array is if the plaintext can vary in length?
Also I need to return the result as a vector (consuming method expects this)
Code from MSDN
array<Byte>^ data = gcnew array<Byte>( DATA_SIZE );
array<Byte>^ result;
SHA1^ sha = gcnew SHA1CryptoServiceProvider;
// This is one implementation of the abstract class SHA1.
result = sha->ComputeHash( data );
My method so far looks like
std::vector<byte> sha1(const std::string& plaintext)
{
//#define SHA1_BUFFER_SIZE ????
//array<System::Byte>^ data = gcnew array<System::Byte>(DATA_SIZE);
//convert plaintext string to byte array
array<System::Byte>^ result;
SHA1^ sha = gcnew SHA1CryptoServiceProvider;
result = sha->ComputeHash(data);
//return result as a vector<byte>
}
First, answering your questions:
On the referred MSDN page, it was stated before the example:
This example assumes that there is a predefined constant DATA_SIZE.
So, it was assumed that there was a #define or a enum constant predefined
Of course you don't know the size of the plaintext. But you'll see that in this approach you don't need the DATA_SIZE constant
If you want your function to receive as input a std:string and to output a std::vector, there are a lot of steps to be done. It would look something like that:
std::vector<unsigned char> sha1(const std::string& message)
{
// Steps #1 and #2: convert from std::string to managed string
// and convert from a string to bytes (UTF-8 as example)
array<Byte>^data = Encoding::UTF8->GetBytes(gcnew String(message.c_str() ));
// Steps #3 and #4: perform hash operation
// and store result in a byte array
SHA1^ sha = gcnew SHA1CryptoServiceProvider;
array<Byte>^ array_result = sha->ComputeHash(data);
// Step #5: convert from a managed array
// to unmanaged vector
std::vector<unsigned char> vector_return(array_result->Length);
Marshal::Copy(array_result, 0, IntPtr(&vector_return[0]), array_result->Length);
return vector_return;
}
don't forget to declare the namespaces you're using:
using namespace System;
using namespace System::Text;
using namespace System::Security::Cryptography;
using namespace System::Runtime::InteropServices;
int main(array<System::String ^> ^args)
{
std::string str_test("This is just a test.");
std::vector<unsigned char> vec_digest( sha1(str_test) );
return 0;
}
Final thoughts:
It's a bit misleading to name the string you want to hash as plaintext. More accurate terms would be message (for the input data) and digest (for the hash value)
Avoid mixing the use of std::string and managed String^ if you can.

How do I avoid truncation of message subjects at 255 chars with the EWS managed API?

I have an email messge on an Exchange server (2010 SP1) with a Subject header that is 272 characters long. Both Outlook and OWA show it truncated to the first 252 characters followed by "...". EWSEditor shows it the same way. I know, however, that the full Subject is stored somewhere, because when I look at the headers in Message Options dialog Outlook or in the Message Details in OWA, all 272 characters are there.
My code is only gettting the truncated Subject, and I need a way to get the full string.
My code is using SyncFolderItems to get a ChangeCollection of ItemChange objects. I have two code branches for this. One retrieves FirstClassProperties, and one retrieves IdOnly. I have a function called getItemStringProp(), and depending on the branch, I either call it directly with the Item that I get from the ItemChange, or with the Item that I get by binding to the ItemChange.Item.Id. In both cases, my getItemStringProp() uses Item.TryGetProperty() and returns a max of 255 characters for the Subject. If the actual subject is longer, then I get 252 chars followed by "...".
Here's my code from the branch doing SyncFolderItems with FirstClassProperties:
useIdOnly = false;
icc = exchange.SyncFolderItems(folderId, PropertySet.FirstClassProperties, null, syncFolderItemsBatchSize, SyncFolderItemsScope.NormalItems, result.getSyncState());
and from the other branch:
useIdOnly = true;
icc = exchange.SyncFolderItems(folderId, PropertySet.IdOnly, null, syncFolderItemsBatchSize, SyncFolderItemsScope.NormalItems, result.getSyncState());
Following this, I drill down to get the Subject:
foreach (ItemChange ic in icc)
{
if (!useIdOnly)
{
icSubject = getItemStringProp(ic.Item, EmailMessageSchema.Subject,"Subject", folderName,"");
}
else
{
PropertySet itemProps = new PropertySet(BasePropertySet.IdOnly);
itemProps.Add(EmailMessageSchema.Subject);
itemProps.Add(EmailMessageSchema.DateTimeSent);
itemProps.Add(EmailMessageSchema.ItemClass);
Item item = Item.Bind(exchange, ic.Item.Id, itemProps);
icSubject = getItemStringProp(item, EmailMessageSchema.Subject, "Subject", folderName, "");
}
}
And here's the function that gets the Subject:
private String getItemStringProp(Item item, PropertyDefinition propDef, String propName, String fName, String defaultValue)
{
// some debug logging code and error checks omitted
object prop = null;
String value = "";
try
{
if (item.TryGetProperty(propDef, out prop) && prop != null)
{
value = prop.ToString();
}
if (prop == null || value == null)
{
value = defaultValue;
}
}
return value;
}
By the way, I'm aware that neither Outlook (at least the 2007 version) nor OWA allows creation of a message with a Subject longer than 255 characters. The message in question came into Exchange via SMTP, and a Subject far longer than 255 characters is legal according to the RFCs.
Don't rely on Item.Bind(), sync, search, or any other operation in EWS to load up all of the properties you're looking for. Have you tried getting the item, then doing a .load(PropertySet) or ExchangeService.loadPropertiesForItems()? Some properties won't come through in various retrieval actions even if you specifically request them. Some may come through, but get truncated. What makes it more fun is that I don't think there's any documentation telling you exactly which operations will return which properties, so you get to guess and check. You have to load the property set after you retrieve the Item(s), so it's usually best to get the Item with the ID only, then load the property set.

Firebreath plugin, how to read <param > values

I want to read the <param> values of custom plugin
I could not find answer on the internet, what I found was:
https://github.com/firebreath/FireBreath/blob/master/src/NpapiCore/NpapiPlugin.cpp#L76
I see params are stored in pluginMain->setParams(paramList);
Can you point how can I access this paramList later? or pluginMain
Is there pluginMain->getParams()? I could not find reference
Nor I could locate the source for setParams().
The question is, how do I get that parameters from PluginWindowXXX or FB::NpapiPluginXXX ?
I exported m_npHost to PluginWindowXXX, set breakpoint in it with gdb but still no success.
All I can think of was:
(gdb) p ((FB::Npapi::NpapiBrowserHost)this->m_npHost)->GetValue
$17 = {NPError (const FB::Npapi::NpapiBrowserHost * const, NPNVariable, void *)} 0x7fe435adeff8 <FB::Npapi::NpapiBrowserHost::GetValue(NPNVariable, void*) const>
Obviously what I do is wrong but I am stuck,
I am passing this host from NpapiPluginX11.cpp
pluginWin->setHost(m_npHost);
taxilian's answer is the most correct one as always but I'll give a try. I'm reading params in my MyPluginAPI constructor.
MyPluginAPI::MyPluginAPI(const MyPluginPtr& plugin, const FB::BrowserHostPtr& host) : m_plugin(plugin), m_host(host)
{
string settings; //<param name="settings" value="{'foo':'bar'}">
settings = plugin->getParam("settings");
}
Inside your PluginCore-derived class, you can use either the getParam method or the getParamVariant method.
From the FireBreath Source:
boost::optional<std::string> PluginCore::getParam(const std::string& key) {
boost::optional<std::string> rval;
FB::VariantMap::const_iterator fnd = m_params.find(key.c_str());
if (fnd != m_params.end())
rval.reset(fnd->second.convert_cast<std::string>());
return rval;
}
FB::variant FB::PluginCore::getParamVariant( const std::string& key )
{
FB::VariantMap::const_iterator fnd = m_params.find(key.c_str());
if (fnd != m_params.end())
return fnd->second;
return FB::variant();
}
So if it's for sure a string (which it pretty much is, unless it starts with on, in which case it might have been converted to a referenced function), you can use:
boost::optional<std::string> mystr = getParam("mystr");
if (mystr) {
call_fn_with_string(*mystr);
}
Alternately, you can get it as a variant and convert it:
FB::variant mystrVal = getParamVariant("mystr");
try {
call_fn_with_string(mystrVal.convert_cast<std::string>());
} catch (FB::bad_variant_cast &err) {
// What to do if the cast to string fails
}

IWebExplorer2 Navigate fails with Error reading characters of string

IWebExplorer2::Navigate(..) (or Navigate2) is failing to navigate some urls. Like while navigating following url: *https://www.facebook.com/dialog/oauth/?api_key=<MyKey>&redirect_uri=<MyUri>&state=NONE* , I am getting the error **Error reading characters of string** in **DISPID_NAVIGATEERROR**.
......
wchar_t ws[MAX_PATH];
TCharToWide(url,ws,MAX_PATH);
VARIANT v; v.vt=VT_I4; v.lVal=0; //v.lVal=navNoHistory;
ibrowser->Navigate(ws,&v,NULL,NULL,NULL);
......
void TCharToWide(const wchar_t *src,wchar_t *dst,int dst_size_in_wchars){wcscpy(dst,src);}
Please could any one tell me what I am missing?
Thanks in advance.
Following Navigate2 method URL Type is Variant, and for Navigate method url type is BSTR; If you have ATL support you can use CComVariant with Navigate2, or CComBSTR with Navigate;
NavToURL( L"www.google.com", FALSE);
BOOL NavToURL(const wchar_t* url, BOOL isnewtab){
CComVariant vEmpty;
CComVariant vURL(url);
CComVariant flag=isnewtab ? 0x0800 : vEmpty;
ibrowser->Navigate2(&vURL, &flag, &vEmpty, &vEmpty, &vEmpty);
return TRUE;
}