You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by "Shreyes Seshasai (JIRA)" <ji...@apache.org> on 2006/07/10 23:26:29 UTC
[jira] Created: (WSCOMMONS-57) SecurityException thrown in
OMAbstractFactory when run from an applet
SecurityException thrown in OMAbstractFactory when run from an applet
---------------------------------------------------------------------
Key: WSCOMMONS-57
URL: http://issues.apache.org/jira/browse/WSCOMMONS-57
Project: WS-Commons
Type: Bug
Components: AXIOM
Reporter: Shreyes Seshasai
This problem appears when creating AXIOM objects in a java applet. In my specific case, the applet is acting as an Axis2 web service client without data binding. Prior to creating the OMElement to send to the service, the applet calls OMAbstractFactory.getOMFactory(). This method calls System.getProperty(OM_FACTORY_NAME_PROPERTY), but because java applets aren't given this permission by default, it immediately throws a SecurityException. This can be avoided by placing the call in a try/catch and using the default value if it hits the exception. The same problem/solution applies to the other 2 methods in the class as well.
----- Original -----
public static OMFactory getOMFactory() {
try {
String omFactory = System.getProperty(OM_FACTORY_NAME_PROPERTY);
if (omFactory == null || "".equals(omFactory)) {
omFactory = DEFAULT_OM_FACTORY_CLASS_NAME;
}
return (OMFactory) Class.forName(omFactory).newInstance();
} catch (InstantiationException e) {
throw new OMException(e);
} catch (IllegalAccessException e) {
throw new OMException(e);
} catch (ClassNotFoundException e) {
throw new OMException(e);
}
}
----- Suggested Fix -----
public static OMFactory getOMFactory() {
String omFactory;
try {
omFactory = System.getProperty(OM_FACTORY_NAME_PROPERTY);
} catch (SecurityException e) {
omFactory = DEFAULT_OM_FACTORY_CLASS_NAME;
}
try {
if (omFactory == null || "".equals(omFactory)) {
omFactory = DEFAULT_OM_FACTORY_CLASS_NAME;
}
return (OMFactory) Class.forName(omFactory).newInstance();
} catch (InstantiationException e) {
throw new OMException(e);
} catch (IllegalAccessException e) {
throw new OMException(e);
} catch (ClassNotFoundException e) {
throw new OMException(e);
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org
[jira] Resolved: (WSCOMMONS-57) SecurityException thrown in
OMAbstractFactory when run from an applet
Posted by "Eran Chinthaka (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/WSCOMMONS-57?page=all ]
Eran Chinthaka resolved WSCOMMONS-57.
-------------------------------------
Resolution: Fixed
Assignee: Eran Chinthaka
Fixed in latest svn. Thanks Shreyes.
> SecurityException thrown in OMAbstractFactory when run from an applet
> ---------------------------------------------------------------------
>
> Key: WSCOMMONS-57
> URL: http://issues.apache.org/jira/browse/WSCOMMONS-57
> Project: WS-Commons
> Issue Type: Bug
> Components: AXIOM
> Reporter: Shreyes Seshasai
> Assigned To: Eran Chinthaka
>
> This problem appears when creating AXIOM objects in a java applet. In my specific case, the applet is acting as an Axis2 web service client without data binding. Prior to creating the OMElement to send to the service, the applet calls OMAbstractFactory.getOMFactory(). This method calls System.getProperty(OM_FACTORY_NAME_PROPERTY), but because java applets aren't given this permission by default, it immediately throws a SecurityException. This can be avoided by placing the call in a try/catch and using the default value if it hits the exception. The same problem/solution applies to the other 2 methods in the class as well.
> ----- Original -----
> public static OMFactory getOMFactory() {
> try {
> String omFactory = System.getProperty(OM_FACTORY_NAME_PROPERTY);
> if (omFactory == null || "".equals(omFactory)) {
> omFactory = DEFAULT_OM_FACTORY_CLASS_NAME;
> }
> return (OMFactory) Class.forName(omFactory).newInstance();
> } catch (InstantiationException e) {
> throw new OMException(e);
> } catch (IllegalAccessException e) {
> throw new OMException(e);
> } catch (ClassNotFoundException e) {
> throw new OMException(e);
> }
> }
> ----- Suggested Fix -----
> public static OMFactory getOMFactory() {
> String omFactory;
> try {
> omFactory = System.getProperty(OM_FACTORY_NAME_PROPERTY);
> } catch (SecurityException e) {
> omFactory = DEFAULT_OM_FACTORY_CLASS_NAME;
> }
> try {
> if (omFactory == null || "".equals(omFactory)) {
> omFactory = DEFAULT_OM_FACTORY_CLASS_NAME;
> }
> return (OMFactory) Class.forName(omFactory).newInstance();
> } catch (InstantiationException e) {
> throw new OMException(e);
> } catch (IllegalAccessException e) {
> throw new OMException(e);
> } catch (ClassNotFoundException e) {
> throw new OMException(e);
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org