Author: jdonnerstag
Date: Sat Feb 13 17:23:04 2010
New Revision: 909851
URL: http://svn.apache.org/viewvc?rev=909851&view=rev
Log:
fixed: provide hook to enforce fqn's leaking out from shared resources
Issue: WICKET-2731
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Application.java
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/SharedResources.java
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Application.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Application.java?rev=909851&r1=909850&r2=909851&view=diff
==============================================================================
---
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Application.java
(original)
+++
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/Application.java
Sat Feb 13 17:23:04 2010
@@ -272,7 +272,7 @@
name = Classes.simpleName(getClass());
// Create shared resources repository
- sharedResources = new SharedResources(this);
+ sharedResources = new SharedResources();
// Install default component instantiation listener that uses
// authorization strategy to check component instantiations.
@@ -349,8 +349,7 @@
getDebugSettings().setDevelopmentUtilitiesEnabled(true);
//
getDebugSettings().setOutputMarkupContainerClassName(true);
getResourceSettings().setJavascriptCompressor(null);
- getRequestCycleSettings().addResponseFilter(
- EmptySrcAttributeCheckFilter.INSTANCE);
+
getRequestCycleSettings().addResponseFilter(EmptySrcAttributeCheckFilter.INSTANCE);
}
else if (DEPLOYMENT.equalsIgnoreCase(configurationType))
{
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/SharedResources.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/SharedResources.java?rev=909851&r1=909850&r2=909851&view=diff
==============================================================================
---
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/SharedResources.java
(original)
+++
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/SharedResources.java
Sat Feb 13 17:23:04 2010
@@ -130,13 +130,13 @@
/** Map of shared resources states */
private final ConcurrentHashMap<String, Resource> resourceMap = new
ConcurrentHashMap<String, Resource>();
+ /** Throw an exception if class name has not alias, and thus the FQN is
exposed in the URL */
+ private boolean throwExceptionIfNotMapped = false;
+
/**
* Construct.
- *
- * @param application
- * The application
*/
- SharedResources(Application application)
+ SharedResources()
{
}
@@ -332,8 +332,35 @@
String alias = classAliasMap.get(scope);
if (alias == null)
{
+ if (isThrowExceptionIfNotMapped())
+ {
+ throw new WicketRuntimeException("FQN will be
exposed in the URL. " +
+ "See
Application.get().getSharedResources().putClassAlias(): " + "class: " +
+ scope.getName());
+ }
alias = scope.getName();
}
return alias + '/' + resourceKey(path, locale, style);
}
+
+ /**
+ *
+ * @return If true an exception is thrown if no alias has been defined
for the class and thus
+ * the fully-qualified-class-name is exposed in the URL.
+ */
+ public boolean isThrowExceptionIfNotMapped()
+ {
+ return throwExceptionIfNotMapped;
+ }
+
+ /**
+ * Set to true, if an exception shall be thrown if no alias has been
defined for the class and
+ * thus the fully-qualified-class name is exposed in the URL.
+ *
+ * @param throwExceptionIfNotMapped
+ */
+ public void setThrowExceptionIfNotMapped(boolean
throwExceptionIfNotMapped)
+ {
+ this.throwExceptionIfNotMapped = throwExceptionIfNotMapped;
+ }
}
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java?rev=909851&r1=909850&r2=909851&view=diff
==============================================================================
---
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
(original)
+++
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
Sat Feb 13 17:23:04 2010
@@ -389,7 +389,6 @@
mount(new SharedResourceRequestTargetUrlCodingStrategy(path,
resourceKey));
}
-
/**
* Partly unmounts/ignores a path that normally would map to another
mount path. Like
* mount("/mypage", MyPage.class); and then "/mypage/arealdir" should
be ignored. This can be
@@ -397,16 +396,15 @@
*
* @param path
* the path that should be ignored.
- *
*/
public final void addIgnoreMountPath(String path)
{
getRequestCycleProcessor().getRequestCodingStrategy().addIgnoreMountPath(path);
}
- /*
+ /**
* @see
org.apache.wicket.Application#newRequestCycle(org.apache.wicket.Request,
- * org.apache.wicket.Response)
+ * org.apache.wicket.Response)
*/
@Override
public RequestCycle newRequestCycle(final Request request, final
Response response)