How to generate OTA SMS for SyncML configuration - sms
I need to generate and send SyncML OTA SMS. I have sms provider that can send binary sms. But I'm kind of stuck in OTA spec and will be really happy if you point me to any of these:
An open source tool that can generate OTA sms out of some properties provided.
A good overview or tutorial on how to make OTA SMS (OTA spec seems not readable at all)
Thanks in advance!
You need to Produce following OMA-DP XML document and submit it to your Service Provider Gateway. You must strictly follow the Format for the message to be identified as configuration message by the Phone. Also contact your Service provider and ask them if they can convert an XML submission to SMS on the fly. They will need to encode the XML into WBXML and then forward the message in PDU mode.
<?xml version="1.0" encoding="utf-8"?>
<wap-provisioningdoc>
<characteristic type="BOOTSTRAP">
<parm name="NAME" value="SYNCSETTINGS" />
</characteristic>
<characteristic type="APPLICATION">
<parm name="APPID" value="w5" />
<parm name="TO-NAPID" value="INTERNET" />
<parm name="NAME" value="SYNCSETTINGS" />
<parm name="ADDR" value="http://syncserver/sync" />
<characteristic type="RESOURCE">
<parm name="URI" value="pb" />
<parm name="NAME" value="Contacts DB" />
<parm name="AACCEPT" value="text/x-vcard" />
</characteristic>
<characteristic type="RESOURCE">
<parm name="URI" value="cal" />
<parm name="NAME" value="Calendar DB" />
<parm name="AACCEPT" value="text/x-vcalendar" />
</characteristic>
<characteristic type="RESOURCE">
<parm name="URI" value="notes" />
<parm name="NAME" value="Notes DB" />
<parm name="AACCEPT" value="text/plain" />
</characteristic>
<characteristic type="APPAUTH">
<parm name="AAUTHNAME" value="username" />
<parm name="AAUTHSECRET" value="password" />
</characteristic>
</characteristic>
</wap-provisioningdoc>
Here's the Function in C# to produce above mentioned XML Document.
public string CreateOTAXmlFile(string Username, string Password)
{
var ota = new XDocument(
new XElement("wap-provisioningdoc",
new XElement("characteristic", new XAttribute("type", "BOOTSTRAP"),
new XElement("parm", new XAttribute("name", "NAME"), new XAttribute("value", "SYNCSETTINGS"))
),
new XElement("characteristic", new XAttribute("type", "APPLICATION"),
new XElement("parm", new XAttribute("name", "APPID"), new XAttribute("value", "w5")),
new XElement("parm", new XAttribute("name", "TO-NAPID"), new XAttribute("value", "INTERNET")),
new XElement("parm", new XAttribute("name", "NAME"), new XAttribute("value", "SYNCSETTINGS")),
new XElement("parm", new XAttribute("name", "ADDR"), new XAttribute("value", "http://syncserver/sync")),
new XElement("characteristic", new XAttribute("type", "RESOURCE"),
new XElement("parm", new XAttribute("name", "URI"), new XAttribute("value", "pb")),
new XElement("parm", new XAttribute("name", "NAME"), new XAttribute("value", "Contacts DB")),
new XElement("parm", new XAttribute("name", "AACCEPT"), new XAttribute("value", "text/x-vcard"))
),
new XElement("characteristic", new XAttribute("type", "RESOURCE"),
new XElement("parm", new XAttribute("name", "URI"), new XAttribute("value", "cal")),
new XElement("parm", new XAttribute("name", "NAME"), new XAttribute("value", "Calendar DB")),
new XElement("parm", new XAttribute("name", "AACCEPT"), new XAttribute("value", "text/x-vcalendar"))
),
new XElement("characteristic", new XAttribute("type", "RESOURCE"),
new XElement("parm", new XAttribute("name", "URI"), new XAttribute("value", "notes")),
new XElement("parm", new XAttribute("name", "NAME"), new XAttribute("value", "Notes DB")),
new XElement("parm", new XAttribute("name", "AACCEPT"), new XAttribute("value", "text/plain"))
),
new XElement("characteristic", new XAttribute("type", "APPAUTH"),
new XElement("parm", new XAttribute("name", "AAUTHNAME"), new XAttribute("value", Username)),
new XElement("parm", new XAttribute("name", "AAUTHSECRET"), new XAttribute("value", Password))
)
)
)
);
ota.Save(Server.MapPath("~/OTA/") + Username + ".xml");
return (ota.ToString());
}
[PS: Believe me, this can be done via even
a GSM modem also!]
Have a look here. It's pretty old but I think the source code should show a little how to create and send OTA sms's.
Related
Open Telemetry with .Net 7 minimal api - AttachLogsToActivityEvent not working with 'IncludeFormattedMessage'
I am using 'OpenTelemetry.Contrib.Preview' package to attach ILogger standalone logs as Activity Events (aka Trace events) to co-relate the logs with trace & show at a single place like Jaeger. As part of the documentation if we want to attach the logs we need to call 'AttachLogsToActivityEvent' along with setting 'IncludeFormattedMessage' to true during the log setup at startup.cs. While I see the logs are successfully being attached to the activity but only the default 3 properties CategoryName, LogLevel & EventId are being added and the actual 'FormattedMessage' is not getting logged even though I have it enabled. Searched in their github repo where I found this below issue, but the same is not working here: https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/134 Any idea what's missing? csproj file <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net7.0</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0-*" /> <PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="7.0.0" /> <PackageReference Include="OpenTelemetry.Contrib.Preview" Version="1.0.0-beta2" /> <PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.4.0-rc.1" /> <PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.4.0-rc.1" /> <PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.4.0-rc.1" /> <PackageReference Include="OpenTelemetry.Exporter.Prometheus.HttpListener" Version="1.4.0-rc.1" /> <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.4.0-rc.1" /> <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol.Logs" Version="1.4.0-rc.1" /> <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.4.0-rc.1" /> <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.10" /> <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9.10" /> <PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.1.0-beta.2" /> </ItemGroup> </Project> Program.cs file (there are bunch of lines for swagger/versioning testing) using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using OpenTelemetry; using OpenTelemetry.Exporter; using OpenTelemetry.Instrumentation.AspNetCore; using OpenTelemetry.Logs; using OpenTelemetry.Resources; using OpenTelemetry.Trace; using System; var builder = WebApplication.CreateBuilder(args); var services = builder.Services; services.AddProblemDetails(); services.AddEndpointsApiExplorer(); services.AddApiVersioning(options => options.ReportApiVersions = true) .AddApiExplorer( options => { options.GroupNameFormat = "'v'VVV"; options.SubstituteApiVersionInUrl = true; }) .EnableApiVersionBinding(); services.AddSwaggerGen(); builder.Services.Configure<AspNetCoreInstrumentationOptions>(options => options.RecordException = true); var resource = ResourceBuilder.CreateDefault().AddService("MyService"); builder.Services .AddOpenTelemetry() .ConfigureResource(ConfigureResource) .WithTracing(o => { o.SetSampler(new TraceIdRatioBasedSampler(1.0)) .AddSource("MyService") .AddAspNetCoreInstrumentation(option => option.RecordException = true) .AddHttpClientInstrumentation(); o.AddConsoleExporter(o => o.Targets = ConsoleExporterOutputTargets.Console); }).StartWithHost(); builder.Logging.ClearProviders(); builder.Logging.Configure(o => o.ActivityTrackingOptions = ActivityTrackingOptions.SpanId | ActivityTrackingOptions.TraceId | ActivityTrackingOptions.ParentId); builder.Logging.AddFilter<OpenTelemetryLoggerProvider>("*", LogLevel.Information); builder.Logging .AddOpenTelemetry(loggerOptions => { loggerOptions.SetResourceBuilder(resource); loggerOptions.IncludeFormattedMessage = true; loggerOptions.IncludeScopes = true; loggerOptions.ParseStateValues = true; loggerOptions.AddConsoleExporter(); loggerOptions.AttachLogsToActivityEvent(); }); var app = builder.Build(); var common = app.NewVersionedApi("Common"); var commonV1 = common.MapGroup("/api/v{version:apiVersion}/common").HasApiVersion(1.0); commonV1.MapGet("/", (ILogger<Program> logger) => { logger.LogInformation("Calling hello world api!"); return Results.Ok("Hello World common v1!"); }); app.UseSwagger(); app.UseSwaggerUI( options => { var descriptions = app.DescribeApiVersions(); foreach (var description in descriptions) { var url = $"/swagger/{description.GroupName}/swagger.json"; var name = description.GroupName.ToUpperInvariant(); options.SwaggerEndpoint(url, name); } }); app.Run(); static void ConfigureResource(ResourceBuilder r) => r.AddService( serviceName: "MyService", serviceVersion: "1.0.0", serviceInstanceId: Environment.MachineName); Once I run the above program & execute the endpoint, I see the activity is getting logged with the additional 'log' even that I added as part of the endpoint execution, but it doesn't include the actual 'FromattedMessage' property though, like an example below... I have opened the same issue in github too: https://github.com/open-telemetry/opentelemetry-dotnet/issues/4052
Need help debugging exception error - Unable to get provider. Missing android.support.FILE_PROVIDER_PATHS
I am getting the exception error: 'Unable to get provider androidx.core.content.FileProvider: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data Here is a bit of my code: public void SendMMSMessage() { Android.Telephony.SmsManager smsMessage = Android.Telephony.SmsManager.Default; IList<string> divideContents = smsMessage.DivideMessage("I auto sent this message to you! No typing here!!!!!"); string filePath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures) + "/TestPic.jpg"; byte[] sendPDUData = GetMMSPDUData("11111111111", filePath, "Hey this image was sent from my phone using code! No typing here"); if (sendPDUData != null) { SendMMSData(sendPDUData); } } public byte[] GetMMSPDUData(string DestinationNumber, string AudioFilePath, string smsMessage) { byte[] pduData = null; try { SendReq sendReq = new SendReq(); sendReq.AddTo(new EncodedStringValue(DestinationNumber)); PduBody pduBody = new PduBody(); // Add text message data to message PduPart txtPart = new PduPart(); txtPart.SetData(Encoding.ASCII.GetBytes(smsMessage)); txtPart.SetContentType(new EncodedStringValue("text/plan").GetTextString()); txtPart.SetName(new EncodedStringValue("Message").GetTextString()); pduBody.AddPart(txtPart); // Add image data // TODO: Later, this will be audio file. But image file for testing PduPart imgPart = new PduPart(); byte[] sampleImageData = System.IO.File.ReadAllBytes(AudioFilePath); imgPart.SetData(sampleImageData); imgPart.SetContentType(new EncodedStringValue("image/jpg").GetTextString()); imgPart.SetFilename(new EncodedStringValue(System.IO.Path.GetFileName(AudioFilePath)).GetTextString()); pduBody.AddPart(imgPart); // Now create body of MMS sendReq.Body = pduBody; // Finally, generate the byte array to send to the MMS provider PduComposer composer = new PduComposer(sendReq); pduData = composer.Make(); } catch(Exception ex) { // TODO: Do something here } return pduData; } public bool SendMMSData(byte[] PDUData) { Context CTX = Android.App.Application.Context; Android.Telephony.SmsManager sm = Android.Telephony.SmsManager.Default; Random rnd = new Random(); try { string cacheFilePath = System.IO.Path.Combine(CTX.CacheDir.AbsolutePath, "send." + "sendMe" + ".dat"); System.IO.File.WriteAllBytes(cacheFilePath, PDUData); Java.IO.File testFile = new Java.IO.File(cacheFilePath); string authString = CTX.PackageName + ".fileprovider"; if (System.IO.File.Exists(cacheFilePath)) { Android.Net.Uri contentURI = AndroidX.Core.Content.FileProvider.GetUriForFile(CTX, CTX.PackageName + ".fileprovider", testFile); // Android.Net.Uri contentURI = Android.Net.Uri.FromFile(testFile).Au /* Android.Net.Uri contentURI = (new Android.Net.Uri.Builder()) .Authority(authString) .Path(cacheFilePath) .Scheme(ContentResolver.SchemeContent) .Build(); */ /* * = (new Android.Net.Uri.Builder()) .Authority(ctx.PackageName + ".fileprovider") .Path(cacheFilePath) .Scheme(ContentResolver.SchemeContent) .Build(); */ PendingIntent pendingIntent = PendingIntent.GetBroadcast(CTX, 0, new Intent(CTX.PackageName + ".WAP_PUSH_DELIVER"), 0); sm.SendMultimediaMessage(CTX, contentURI, null, null, null); } } catch(Exception ex) { String exString = ex.ToString(); return false; } return true; } Also, here is my Manifest file: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.janinesafety2" android:installLocation="auto"> <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" /> <application android:label="janinesafety2.Android"> <provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.suport.FILE_PROVIDER_PATHS" android:resource="#xml/provider_paths" /> </provider> </application> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_USER_DICTIONARY" /> <uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" /> </manifest> and my Provider_path <?xml version="1.0" encoding="utf-8" ?> <paths> <external-path name="external_file" path="./" /> </paths> I have used these as resources to assist me in debugging: androidx FILE_PROVIDER_PATHS Unable to get provider androidx.core.content.FileProvider: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data? And unfortuntaly, I am still having issues with the expection. From what I can tell I am doing the exact thing everyone is saying. Is there anyone there that can take a second a look at my code? Maybe I missed something. Thank you.
You could refer to the code below. 1.Add the following to your AndroidManifest.xml inside the tags. YOUR_APP_PACKAGE_NAME must be set to your app package name. <application> <provider android:name="android.support.v4.content.FileProvider" android:authorities="YOUR_APP_PACKAGE_NAME.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/file_paths"></meta-data> </provider> </application> 2.Add a new folder called xml into your Resources folder and add a new XML file called file_paths.xml. Add the following code: <?xml version="1.0" encoding="utf-8" ?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path name="external_files" path="." /> <external-path name="external" path="." /> <external-files-path name="external_files" path="." /> <cache-path name="cache" path="." /> <external-cache-path name="external_cache" path="." /> <files-path name="files" path="." /> </paths> I added all the tags. You could get from the link below. FileProvider - IllegalArgumentException: Failed to find configured root
Download NuGet from behind a proxy using inline MSBuild Task
I am using the NuGet.targets file from NuGet to automatically download NuGet.exe and then restore the packets in my project. This was working well, however at work we have a proxy and this method was failing due to a (407) Proxy Authentication Required Exception. I modified the targets file to use the proxy details and although this method works in an application it does not work in the MSBuild Task, the code is identical. If I hardcode the proxy and my login details it works, when I build my solution NuGet.exe is downloaded and the packages are restored correctly. The problem only appears to be the authentication in the MSBuild task, I have absolutely no idea why. I have attached my modified code. If anyone can help I'd appreciate it. Thanks <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> <ParameterGroup> <OutputFilename ParameterType="System.String" Required="true" /> </ParameterGroup> <Task> <Reference Include="System.Core" /> <Using Namespace="System" /> <Using Namespace="System.IO" /> <Using Namespace="System.Net" /> <Using Namespace="Microsoft.Build.Framework" /> <Using Namespace="Microsoft.Build.Utilities" /> <Code Type="Fragment" Language="cs"> <![CDATA[ try { OutputFilename = Path.GetFullPath(OutputFilename); Log.LogMessage("Downloading latest version of NuGet.exe..."); using(WebClient webClient = new WebClient()) { webClient.UseDefaultCredentials = true; webClient.Proxy = WebRequest.GetSystemWebProxy(); webClient.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials; webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename); return true; } } catch (Exception ex) { Log.LogErrorFromException(ex); return false; } ]]> </Code> </Task> </UsingTask>
Obfuscar tool ForceStringHiding
After hours finally got why my app crashes after obfuscating by Obfuscar. That is StringHiding in MyClass. So settings for module now is <SkipStringHiding type="Myspacename.MyClass" name="*" /> Now I need to hide only some of the strings inside MyClass. For example private const string TrialLicenseKey = "AEAF3-N4C7K-BWDTV-3CLZB-XXXXX"; I was trying some combinatons of settings, but strings are still visible in Reflector.
Is ForceStringHiding supported? What is for name parameter? String content, var name, etc.? <ForceStringHiding type="Myspacename.MyClass" name="???" />
Can't get why i see unobfuscated private static strings in Reflector static Debugging() { A = new object(); __public = "AOMRDQELD+0rFgbQxySAHrBpU3N8RF1i3rXkgSC79aXEgE="; D = "ActivationHardwareId"; d = "LicenseKey"; E = "ActivationKey"; ... } settings for Obfuscar <Var name="KeepPublicApi" value="true" /> <Var name="HidePrivateApi" value="true" /> <Var namr="HideStrings" value="true" />
Jasper Reports empty PDF report problem, using Spring ModelAndView
I am trying to generate PDF report with Jasper Reports using Spring. But report is always empty. I searched a lot and could not find problem. I tried to write byte[] pdfReport to OutputStream but result is same, report is always empty. I have 2 parameters one o them is testName and one of them is chart. Both can not display at pdf report. Thanks a lot for your help, Here is the code that generates report. //My class extends MultiActionController DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue(String.format("%s, %s", "pie1", "pie1"),20); dataset.setValue(String.format("%s, %s", "pie2", "pie2"),80); JFreeChart chart = ChartFactory.createPieChart("testPie", dataset, true, true, false); Map model = new HashMap(); model.put("chart", chart.createBufferedImage(200, 200)); model.put("testName", "test report"); model.put("format", "pdf"); AbstractJasperReportsView view = new JasperReportsMultiFormatView(); view.setUrl("/WEB-INF/classes/reports/"+"test1"+".jasper"); view.setApplicationContext(getApplicationContext()); view.setContentType("application/pdf"); Properties header = new Properties(); view.setHeaders(header); ModelAndView mv = new ModelAndView(view, model); JasperReport report = (JasperReport) JRLoader.loadObject(getServletContext().getResourceAsStream("/WEB-INF/classes/reports/"+"test1"+".jasper")); JasperPrint prt = JasperFillManager.fillReport(report, model); byte[] pdfReport = JasperExportManager.exportReportToPdf(prt); return mv; And here is jrxml file <?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="test1" language="groovy" pageWidth="700" pageHeight="842" columnWidth="660" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="2"/> <parameter name="testName" class="java.lang.String"/> <parameter name="chart" class="java.awt.Image" isForPrompting="false"/> <background> <band splitType="Stretch"/> </background> <title> <band height="48" splitType="Stretch"/> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="14" splitType="Stretch"/> </columnHeader> <detail> <band height="229" splitType="Stretch"> <image> <reportElement x="162" y="13" width="200" height="200"/> <imageExpression class="java.awt.Image"><![CDATA[$P{chart}]]></imageExpression> </image> <textField> <reportElement x="37" y="61" width="100" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$P{testName}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="112" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="76" splitType="Stretch"/> </pageFooter> <summary> <band height="42" splitType="Stretch"/> </summary> </jasperReport>
Why are you doing the following? ModelAndView mv = new ModelAndView(view, model); JasperReport report = (JasperReport) JRLoader.loadObject(getServletContext().getResourceAsStream("/WEB-INF/classes/reports/"+"test1"+".jasper")); JasperPrint prt = JasperFillManager.fillReport(report, model); byte[] pdfReport = JasperExportManager.exportReportToPdf(prt); return mv; Using JasperReportsMultiFormatView() already combines the filling and exporting of the report. No need for the following: JasperReport report = (JasperReport) JRLoader.loadObject(getServletContext().getResourceAsStream("/WEB-INF/classes/reports/"+"test1"+".jasper")); JasperPrint prt = JasperFillManager.fillReport(report, model); byte[] pdfReport = JasperExportManager.exportReportToPdf(prt); You must declare the JRXML file and report data key in a resource bundle. I suggest you check this guide I wrote for Spring 3 MVC - Jasper Integration Tutorial: http://krams915.blogspot.com/2010/12/spring-3-mvc-jasper-integration.html Just modify the views to use the JasperReportsMultiFormatView() instead. Check the Tutorials section for more. If I have time later, I'm gonna make a tutorial using JasperReportsMultiFormatView(). If not maybe tomorrow. Let me know if this helps you.
There is a property in jasper report called 'whenNoDataType'. Did you tried setting that to whenNoDataType="AllSectionsNoDetail" Also the report language is given as 'groovy'. Why?