FileConnection permission messages in j2me midp 2.0? - java-me

I am using midp 2.0. Here, I am using FileConnection for read and write files on mobile memory. I am able to read and write files on mobiles successfully. But while I am trying to write file data on mobile, it asking message like below.
Application wants to read from the local file system
is it OK to read your files?
if I press yes, then it again shows
Application wants to write to the local file system
is it OK to update your files?
These message are continuously showing approximately 10 times.
Is there any way to prevent this repeating this more than one time?
I have included my fileWrite method for your reference also:
public String fileWrite(String root)
{
FileConnection fc = null;
String fName = "test.txt";
DataOutputStream dos=null;
try
{
fc = (FileConnection) Connector.open(root + fName, Connector.READ_WRITE);
if(!fc.exists())
{
fc.create();
}
else
{
System.out.println("File Exists part");
fc.delete();
fc.create();
}
dos = fc.openDataOutputStream();
dos.write("f".getBytes());
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
fc.close();
dos.close();
}
catch (IOException e) { }
}
return "Saved in "+root+fName;
//return "NULL";
}//filewrite ends here*/

This is not coding related issue. Basically this type of confirm alert asking for security purpose. Because you are using JSR-75.
In this purpose, You need to sign your application with atleast any 3rd party signature like one from Verisign or Thrawte and then go to the application settings - permissions - and set permission for "Access User Data" as "Ask only Once" or "Allow Always" (these settings might not be available for your unsiged app on the device.)
If you facing this Issue on the emulator, go to preferences and MIDP tab, set the application domain to Trusted and set permission as "Allow Always". For more info, see here...
Signing sites are,
Thawte
Verisign
Java Verified

If you go to 3rd party trusted certificate means its minimum cost is RS.10000 per year. For deploying your application in client (final stage). It will worth.
But for testing, validating input, developing stage the cost is high. So check if your mobile has support for self signed certificate. If it supports self signed certificate, then process with self signed certificate.
But keep in mind self signed certificate is only for testing / development purpose. For delivering the project to client you should go to trusted party certificates.

Related

OTA InitConnectionEx, Login -> Exception: ServerThread DB_TIME_COUNT=

I'm having a c# application which uses OTA-Com-Library to login to ALM. Every time I try to login I get the following exception:
{"<ServerThread DB_TIME_COUNT=\"0\" DB_TIME_MAX=\"0\" SERVER_MACHINE_NAME=\"GRZWINSV1371\" DB_TIME_MIN=\"0\" PROJECT=\"N/A\" THREAD_ID=\"62ED8023-E88C-4CCE-85C0-DFE7D0B108B7\" FS_TIME_MIN=\"0\" SERVER_START_TIME_MS=\"1462181946133\" SERVER_TOTAL_TIME=\"2\" FS_TIME_AVG=\"0\" THREAD_TYPE=\"Login\" SERVER_CPU_TIME=\"0\" FS_TIME_MAX=\"0\" USER_NAME=\"N/A\" FS_TIME_COUNT=\"0\" PROJECT_SESSION_ID=\"-1\" LOGIN_SESSION_ID=\"-1\" THREAD_CATEGORY=\"FREC_REQUEST_CALL\" SERVER_START_TIME=\"2016-05-02 11:39:06\" DB_TIME_AVG=\"0\" />"}
This is the c# code:
try
{
this.server = server;
this.username = user;
this.pwd = password;
tdConn.InitConnectionEx(server);
tdConn.Login(user, password);
}
catch (Exception exception)
{
ExceptionUtils.ReportHandledException(exception);
}
I registered the COM Components by using "Register HP ALM" of provided on this site:
https://centre.qualitat.solucions.gencat.cat/qcbin/CommonMode_index.html
Cheers,
Stefan
Ensure url spesified correctly.
URL to init OTA connection need to be specified in format: http://<server_host>:<server_port>/qcbin
The message you specified comes from server, but not looks like exception.
Please specify full exception with stack trace. Additional information could be obtained from WebGate log. To turn it on follow instruction:
Go to your server apps: https://centre.qualitat.solucions.gencat.cat/qcbin/Apps/
Click "Client Logs Configuration Tool"
When tool downloads run it
Go to the "WebGate" section
For "Log Level" choose "ALL - Log everything" and specify the path wehere log should write to.
Then reproduce the problem and observe WebGate log at path specified and look for text highlighted with red or just provide the output adter "Login Started:" and before "Login Ended:" in the log file.

Error creating a new workspace

I am trying to create a local workspace so I can map it to VisualStudio online account. Here is the command I am trying to run.
tf workspace -new -login:"Windows Live ID"\user,pass -collection:https://shaggyinjun.visualstudio.com/DefaultCollection
For some reason I am seeing an error. The command does have a domain/user,pass. What is this new username and password it is asking me for ?
Federated authentication to this server requires a username and password.
Apparantly this is issue is caused even when using java clients. Here is what Visual Studio Online has to say for it's questionable behavior.
Alternate authentication credentials
Some applications that work outside the browser (including Team Explorer Everywhere
command line client and the git-tf utility) require basic authentication credentials.
Other applications do not properly handle using an e-mail address for the user name
during authentication.
To work with these applications, you need to enable alternate credentials, set a
password, and optionally set a secondary user name not in the form of an e-mail address. > Please note that alternate credentials cannot be used to sign in to the service from a web
browser or outside of these applications.
Here is another question that I posted and was shot down. Just documenting here for future reference
I am able to login using my Visual Studio online credentials via the CLC, but When I try to do the same with a java program, I get an Authentication exception. Is there anything special that needs to be done for Java and / or Visual Studio Online ?
Java Code
public static final String NATIVE_LIBS_SYSTEM_PROPERTY = "com.microsoft.tfs.jni.native.base-directory";
public void connect() {
System.setProperty(NATIVE_LIBS_SYSTEM_PROPERTY, TFS_NATIVE_LIBS_HOME);
Credentials credentials = new UsernamePasswordCredentials("Windows Live ID\\user", "password");
TFSConnection connection = null;
try {
connection = new TFSConfigurationServer(new URI("https://shaggyinjun.visualstudio.com/DefaultCollection"), credentials);
connection.authenticate();
} catch (URISyntaxException ex) {
Exceptions.printStackTrace(ex);
}
}
}
Exception
com.microsoft.tfs.core.ws.runtime.exceptions.UnauthorizedException: Authorization failure connecting to 'https://shaggyinjun.visualstudio.com/DefaultCollection/TeamFoundation/Administration/v3.0/LocationService.asmx' (authenticating as Windows Live ID\user)
at com.microsoft.tfs.core.ws.runtime.client.SOAPService.executeSOAPRequestInternal(SOAPService.java:709)
at com.microsoft.tfs.core.ws.runtime.client.SOAPService.executeSOAPRequest(SOAPService.java:473)
at ms.ws._LocationWebServiceSoap12Service.connect(_LocationWebServiceSoap12Service.java:384)
at com.microsoft.tfs.core.clients.framework.location.internal.LocationWebServiceProxy.connect(LocationWebServiceProxy.java:70)
Caused: com.microsoft.tfs.core.exceptions.TFSUnauthorizedException: Access denied connecting to TFS server https://shaggyinjun.visualstudio.com/ (authenticating as Windows Live ID\venkatram.akkineni#gmail.com)
at com.microsoft.tfs.core.exceptions.mappers.TECoreExceptionMapper.map(TECoreExceptionMapper.java:75)
at com.microsoft.tfs.core.exceptions.mappers.LocationExceptionMapper.map(LocationExceptionMapper.java:32)
at com.microsoft.tfs.core.clients.framework.location.internal.LocationWebServiceProxy.connect(LocationWebServiceProxy.java:76)
at com.microsoft.tfs.core.clients.framework.location.LocationService.connect(LocationService.java:754)
at com.microsoft.tfs.core.clients.framework.location.LocationService.authenticate(LocationService.java:928)
at com.microsoft.tfs.core.TFSConnection.authenticate(TFSConnection.java:748)
at org.netbeans.modules.libswrapper.Installer.restored(Installer.java:54)
at org.netbeans.core.startup.NbInstaller.loadCode(NbInstaller.java:471)
[catch] at org.netbeans.core.startup.NbInstaller.loadImpl(NbInstaller.java:394)
at org.netbeans.core.startup.NbInstaller.access$000(NbInstaller.java:105)
at org.netbeans.core.startup.NbInstaller$1.run(NbInstaller.java:346)
at org.openide.filesystems.FileUtil$2.run(FileUtil.java:447)
at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:127)
at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:609)
at org.openide.filesystems.FileUtil.runAtomicAction(FileUtil.java:431)
at org.openide.filesystems.FileUtil.runAtomicAction(FileUtil.java:451)
at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:343)
at org.netbeans.ModuleManager.enable(ModuleManager.java:1194)
at org.netbeans.ModuleManager.enable(ModuleManager.java:1017)
at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:340)
at org.netbeans.core.startup.ModuleList.access$2400(ModuleList.java:118)
at org.netbeans.core.startup.ModuleList$Listener.stepEnable(ModuleList.java:1409)
at org.netbeans.core.startup.ModuleList$Listener.access$1400(ModuleList.java:1007)
at org.netbeans.core.startup.ModuleList$Listener$1.run(ModuleList.java:1231)
at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:127)
at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:609)
at org.netbeans.core.startup.ModuleList$Listener.run(ModuleList.java:1207)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1423)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
If you're connecting to visualstudio.com from the cross-platform command line client, you need to set up and use "alternate credentials".
You cannot use a Microsoft Account (Live ID) because - crazy as it sounds - that only works by supplying passwords to that web page and we cannot rely on a web browsers existence on many platforms.

JCIFS How to authenciate when folder is shared with Everyone?

we have a scenario in which we are sharing a folder with group Everyone (which I think includes all users from your domain)
when we are using \\server-ip\sharedFolder in Win+R we are able to connect to the folder and browse with out any password (my computer is logged in using a user on same domain)
when I code it in java application using File class like this
File f = new File(\\server-ip\sharedFolder );
it works then also, But I want to make my application work on mac/linux also so I am trying to use JCIFS for this purpose. But I am having issues while authenticating what should I use as username and password when guest account is also out of picture. I tried
package test;
import java.net.MalformedURLException;
import jcifs.smb.NtlmAuthenticator;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbException;
import jcifs.smb.SmbFile;
public class JCIFSTest {
public static void main(String args[]){
String user = "";
String pass ="";
String sharedFolder="sup";
String path="smb://server-ip/"+sharedFolder+"/";
//ntlm
// NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",user, pass);
try {
SmbFile smbFile = new SmbFile(path,NtlmPasswordAuthentication.ANONYMOUS);
if(smbFile.isDirectory()){
for(SmbFile f: smbFile.listFiles()){
System.out.println(f.getName());
if(f.isDirectory()){
for(SmbFile g: f.listFiles()){
System.out.println(g.getName());
}
}
}
}
//SmbFile.
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SmbException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
but this is also giving error "Account Disabled" I guess its trying to user guest which is disabled.
since when connecting with windows using simple \\server-ip\sharedFolder it works, I think there will be a way to do this.
I want to figure out how windows is authencating when we are doing this???
EDIT: Found the way to do it. You need not be added to the list of users who are allowed to login.
If you are in the Everyone List and the folder is shared with Everyone you need to give your username and password during NTLM authentication and the folders that are shared with everyone can be accessed after that
However this late reply, but as Matheiu pointed out I should probably write an answer here to help others.
There was no code change required. It was more of a conceptual thing.
Actually when you share your file with everyone it's actually shared with everyone on your DOMAIN or guest if the guest account is enabled.
You need some way to authenticate when someone is trying to access it. When you access it like this
\server-ip\sharedFolder using windows it authenticates itself using your logged-in user and if you are part of the same domain it gives you access.
You need to do the same when you are connecting via JCIFS using linux/mac. You need to give your username and password and if your user is part of that domain you will be authenticated and you can access things that are shared publically or shared with everyone.

Accepting self signed certificate programmatically from J2ME

I have created self-signed certificate and configured tomcat to use it (Port 443)
When i try to access it through j2me application i get CertificateException
public void run() {
String url = "https://192.168.1.40/test/index.jsf";
try {
HttpsConnection hc = (HttpsConnection)Connector.open(url);
int respCode= hc.getResponseCode();
}catch (IOException ioe) {
Alert a = new Alert(ioe.toString(), null, AlertType.INFO);
}
javax.microedition.pki.CertificateException:Certificate failed verification
I think emulator has options to import certificate but
is there any way to package the certificate with the j2me jar and make it to accept self-signed certificate in real mobile device.
A late answer: few phones have such feature (import root certs), I do not remember exactly, probably SE (sonyericsson) phones and Nokia Symbian (not all models). Majority of phones does not support this feature.
You may consider using SSL encryption in J2ME code such as bouncycastle, see here: Client side ssl in J2me?

SharePoint -custom sign-in page

I am running a CMS web site on WSS 3.0.
I would like to have a custom sign-in page for the publishers. Do I have any other alternative other than the Welcome control? (For example, could I use ASP.NET Login control?
Thank you for your help.
That would depend on the authentication mechanism that you use. If you're using Active Directory, you're pretty much tied to the Welcome control.
If however you're using Forms Based Authentication, you can control to login page more completely.
FBA can be tricky to configure and I'd recommend staying with AD if you can, but if you have to go FBA, here's a good guide:
http://technet.microsoft.com/en-us/library/cc262201(office.12).aspx
This is really not much difficult.
It can only be happen if you have Forms based authenticated site not windows based, then you must have to modify login.aspx page.
this relies in _layouts folder of 12 hive. so you have to modify it.
Best way to do is, fo to _layouts folder, make a copy of it and paste it in somewhere in the disk and then change the location in IIS properties for the site of the _layouts folder to your copied one. and make the changes of that login page.
Points to remember.: It uses a master page and there are 5 or 6 customplaceholders requires. so do have them in your new masterpage.
Next is about the code behing for login control to work.
If you are customizing your login code. then you have to modify
this is an example :
using System;
using System.Web.Security;
using System.Web.UI.WebControls;
namespace CustomLoginPage
{
public class Login :
Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase
{
protected System.Web.UI.WebControls.Login loginBox;
protected override bool AllowAnonymousAccess { get { return true; }
}
protected override bool AllowNullWeb { get { return true; } }
protected void Login_Click(object sender, EventArgs e)
{
if (AuthenticateUser(loginBox.UserName, loginBox.Password))
return;
}
protected bool AuthenticateUser(string emailAddr,
string password)
{
string userName = emailAddr;
MembershipUserCollection coll =
Membership.FindUsersByEmail(emailAddr);
if (coll != null && coll.Count == 1)
{
// We're doing this to force the enumerator to give us the
// one and only item because there is no by int indexer
foreach (MembershipUser user in coll)
{
userName = user.UserName;
}
}
if (Membership.ValidateUser(userName, password))
{
FormsAuthentication.RedirectFromLoginPage(userName, true);
return true;
}
return false;
}
}
}
so please do modify it.
The one Url which i follow to perform this is :
http://www.devx.com/enterprise/Article/35068/1954
Go ahead and if you face any issues. feel free to contact me : ankurmadaan2787#live.in
The answers below are really helpful -but I'm afraid my environment is limited (WSS 3.0, shared hosting).
So I simply added this link which opens up the authentication dialog:
Sign in
(Where the Source parameter indicates the URL to redirect to upon authentication.)
Thank you.

Resources