Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 240 Big Data Appliance
- 1.9K Data Science
- 450.4K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 546 SQLcl
- 4K SQL Developer Data Modeler
- 187.1K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 443 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
signed applet get access denied java.net.SocketPermision smtp.gmail.com

821042
Member Posts: 11
Hi, i have a signed applet which send emails. It works fine on netbeans, but when i run it in browsers(ie,mozila,crome,opera) i get this error: java.security.AccessControlException access denied java.net.SocketPermission smtp.gmail.com
This is the code but i'm sure is not the problem:
//start code_____________________________________________________________________________
public class ABC {
public String to="";
public String file="";
static GMailAuthenticator auth=new GMailAuthenticator("myemail", "mypassword");
public ABC(String to_,String file_)
{
this.to=to_;
file=file_;
}
public boolean send()
{ boolean ok=true;
try {
Properties props = System.getProperties();
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "587"); // smtp port
Session session = Session.getInstance(props,auth );
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("[email protected]"));
msg.setSubject(file+" attachment");
msg.setRecipient(RecipientType.TO, new InternetAddress(to));
//add atleast simple body
MimeBodyPart body = new MimeBodyPart();
body.setText("on-xml " + file + " file saved attachment");
//do attachment
MimeBodyPart attachMent = new MimeBodyPart();
FileDataSource dataSource = new FileDataSource(new File(file));
attachMent.setDataHandler(new DataHandler(dataSource));
attachMent.setFileName(file);
attachMent.setDisposition(MimeBodyPart.ATTACHMENT);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(body);
multipart.addBodyPart(attachMent);
msg.setContent(multipart);
Transport.send(msg);
} catch (Exception ex)
{ok=false;JOptionPane.showMessageDialog(null, "Failed to send: "+ex.toString() , "Failed to send: "+ex.toString(), JOptionPane.INFORMATION_MESSAGE);}
return ok;
}
}
//end code______________________________________________________________________________
PS: i also signed mail.jar and activation.jar but make no difference
Thx
This is the code but i'm sure is not the problem:
//start code_____________________________________________________________________________
public class ABC {
public String to="";
public String file="";
static GMailAuthenticator auth=new GMailAuthenticator("myemail", "mypassword");
public ABC(String to_,String file_)
{
this.to=to_;
file=file_;
}
public boolean send()
{ boolean ok=true;
try {
Properties props = System.getProperties();
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "587"); // smtp port
Session session = Session.getInstance(props,auth );
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("[email protected]"));
msg.setSubject(file+" attachment");
msg.setRecipient(RecipientType.TO, new InternetAddress(to));
//add atleast simple body
MimeBodyPart body = new MimeBodyPart();
body.setText("on-xml " + file + " file saved attachment");
//do attachment
MimeBodyPart attachMent = new MimeBodyPart();
FileDataSource dataSource = new FileDataSource(new File(file));
attachMent.setDataHandler(new DataHandler(dataSource));
attachMent.setFileName(file);
attachMent.setDisposition(MimeBodyPart.ATTACHMENT);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(body);
multipart.addBodyPart(attachMent);
msg.setContent(multipart);
Transport.send(msg);
} catch (Exception ex)
{ok=false;JOptionPane.showMessageDialog(null, "Failed to send: "+ex.toString() , "Failed to send: "+ex.toString(), JOptionPane.INFORMATION_MESSAGE);}
return ok;
}
}
//end code______________________________________________________________________________
PS: i also signed mail.jar and activation.jar but make no difference

Thx
Best Answer
-
Did it go past the previous issue? Is it a bit better, or it fails now even earlier?
Answers
-
user13415120 wrote:That comes from the VM and not your code.
Hi, i have a signed applet which send emails. It works fine on netbeans, but when i run it in browsers(ie,mozila,crome,opera) i get this error: java.security.AccessControlException access denied java.net.SocketPermission smtp.gmail.com
So probably something wrong with your jar - like it isn't actually signed.
Although, as only a guess, what happens if the firewall denies access to that server - what error would one see? (Again just guessing.) -
When you go to the page, do you get a prompt about the certificate?
If not, it's not properly signed.
Do you use javascript in the page? Do you call the applet from javascript?
If yes, signing is not enough.
The exception has nothing to do with firewalls. It would have been some IOException.
Edit: Posting the exact exception stack trace would help.
It might also be that some classes that are on the stack leading to the fatal call may still originate from unsigned jars.
Edited by: baftos on Dec 3, 2010 4:53 PM -
My applet and other jar (mail.jar) are signed because i get a prompt about the certificate and i can open,save file in my main project .
I found and i tried this but with no hope,
AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
{
try {
Transport.send(msg);// THIS GENERATE MY EXCEPTION
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "0 Failed to send: "+ex.toString() , "0 Failed to send: "+ex.toString(), JOptionPane.INFORMATION_MESSAGE);
}
return null;
}
});
PS: i will post the trace later because i don't have the time right now
Thx for your answers -
and i don't use javascript...:)
-
oki i'm back with the trace
java.security.AccessControlException: access denied (java.net.SocketPermission smtp.gmail.com resolve)
access denied (java.net.SocketPermission smtp.gmail.com resolve)
TRACE________________________________________________________________________________________________________________________________________________
CLASS METHOD STRING
class: java.security.AccessControlContext method: checkPermission string: java.security.AccessControlContext.checkPermission(Unknown Source)
class: java.security.AccessController method: checkPermission string: java.security.AccessController.checkPermission(Unknown Source)
class: java.lang.SecurityManager method: checkPermission string: java.lang.SecurityManager.checkPermission(Unknown Source)
class: java.lang.SecurityManager method: checkConnect string: java.lang.SecurityManager.checkConnect(Unknown Source)
class: sun.plugin2.applet.Applet2SecurityManager method: checkConnect string: sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source)
class: java.net.InetAddress method: getAllByName0 string: java.net.InetAddress.getAllByName0(Unknown Source)
class: java.net.InetAddress method: getAllByName string: java.net.InetAddress.getAllByName(Unknown Source)
class: java.net.InetAddress method: getAllByName string: java.net.InetAddress.getAllByName(Unknown Source)
class: java.net.InetAddress method: getByName string: java.net.InetAddress.getByName(Unknown Source)
class: javax.mail.URLName method: getHostAddress string: javax.mail.URLName.getHostAddress(URLName.java:473)
class: javax.mail.URLName method: hashCode string: javax.mail.URLName.hashCode(URLName.java:449)
class: java.util.Hashtable method: get string: java.util.Hashtable.get(Unknown Source)
class: javax.mail.Session method: getPasswordAuthentication string: javax.mail.Session.getPasswordAuthentication(Session.java:811)
class: javax.mail.Service method: connect string: javax.mail.Service.connect(Service.java:258)
class: javax.mail.Service method: connect string: javax.mail.Service.connect(Service.java:156)
class: javax.mail.Service method: connect string: javax.mail.Service.connect(Service.java:105)
class: javax.mail.Transport method: send0 string: javax.mail.Transport.send0(Transport.java:168)
class: javax.mail.Transport method: send string: javax.mail.Transport.send(Transport.java:98)
class: A.ABC method: send string: A.ABC.send(ABC.java:83)
class: A.onxml_1$1 method: actionPerformed string: A.onxml_1$1.actionPerformed(onxml_1.java:329)
class: javax.swing.AbstractButton method: fireActionPerformed string: javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
class: javax.swing.AbstractButton$Handler method: actionPerformed string: javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
class: javax.swing.DefaultButtonModel method: fireActionPerformed string: javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
class: javax.swing.DefaultButtonModel method: setPressed string: javax.swing.DefaultButtonModel.setPressed(Unknown Source)
class: javax.swing.plaf.basic.BasicButtonListener method: mouseReleased string: javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
class: java.awt.AWTEventMulticaster method: mouseReleased string: java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
class: java.awt.Component method: processMouseEvent string: java.awt.Component.processMouseEvent(Unknown Source)
class: javax.swing.JComponent method: processMouseEvent string: javax.swing.JComponent.processMouseEvent(Unknown Source)
class: java.awt.Component method: processEvent string: java.awt.Component.processEvent(Unknown Source)
class: java.awt.Container method: processEvent string: java.awt.Container.processEvent(Unknown Source)
class: java.awt.Component method: dispatchEventImpl string: java.awt.Component.dispatchEventImpl(Unknown Source)
class: java.awt.Container method: dispatchEventImpl string: java.awt.Container.dispatchEventImpl(Unknown Source)
class: java.awt.Component method: dispatchEvent string: java.awt.Component.dispatchEvent(Unknown Source)
class: java.awt.LightweightDispatcher method: retargetMouseEvent string: java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
class: java.awt.LightweightDispatcher method: processMouseEvent string: java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
class: java.awt.LightweightDispatcher method: dispatchEvent string: java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
class: java.awt.Container method: dispatchEventImpl string: java.awt.Container.dispatchEventImpl(Unknown Source)
class: java.awt.Component method: dispatchEvent string: java.awt.Component.dispatchEvent(Unknown Source)
class: java.awt.EventQueue method: dispatchEvent string: java.awt.EventQueue.dispatchEvent(Unknown Source)
class: UndoCopy.U1 method: dispatchEvent string: UndoCopy.U1.dispatchEvent(U1.java:47)
class: java.awt.EventDispatchThread method: pumpOneEventForFilters string: java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
class: java.awt.EventDispatchThread method: pumpEventsForFilter string: java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
class: java.awt.EventDispatchThread method: pumpEventsForHierarchy string: java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
class: java.awt.EventDispatchThread method: pumpEvents string: java.awt.EventDispatchThread.pumpEvents(Unknown Source)
class: java.awt.EventDispatchThread method: pumpEvents string: java.awt.EventDispatchThread.pumpEvents(Unknown Source)
class: java.awt.EventDispatchThread method: run string: java.awt.EventDispatchThread.run(Unknown Source) -
I don't know:(
All I can suggest is to check every line in the stack trace for classes that are not part of the JRE, like A.ABC, A.onxml_1$1 and make sure they originate from your signed jars and not from class files on your disk. By the way, how does the applet tag look like? -
I checked that
Tag look like this:
<applet code="A/onxml_1.class" archive="GONXML.jar" align="absmiddle" width="100%" height="100%">
<param name="java_arguments" value="-Xmx1024m"/>
<?php echo'<PARAM name="a" '; echo 'value="'; echo $k; echo '"'; ?> />
<?php echo'<PARAM name="email" '; echo 'value="'; echo $_COOKIE['email']; echo '"';?> />
</applet>
I searched on other forums and the problem is with security of java.net.InetAddress.getAllByName() , but i don't know what to do ...they suggest not to use javascript and sign all my jars which i've done...
I will try without PARAM php code... -
nope...same story without PARAM php code
I don't know what to do with java.net.InetAddress.getAllByName security -
<applet code="A/onxml_1.class" archive="GONXML.jar" align="absmiddle" width="100%" height="100%">Not that I can see any relation to your problem, but:
<applet code="A.onxml_1" ....
-
If there was a problem with applet tag or with signed applet my main project(GONXML.jar) couldn't open, save, copy paste files on the client pc...but it can......so i don't know i'm stuck:)
This discussion has been closed.