mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
6386: Fix for AR-1649 6387: Fix for AR-1645 6388: Updated Polish messages 6389: Updated security providers 6392: Add support to log in as guest with any password (if guest is allowed) 6393: AR-1562 : Cannot directly exit/disable Alfresco JavaScript Debugger window 6394: Allow creation of PropertyValue persisted properties without knowing the type QName 6397: Log Serializable properties don't cause infinte waits 6398: Build fix and tidy up for authentication chaining Resolved conflicted state of 'root\projects\repository\source\java\org\alfresco\repo\security\authentication\AuthenticationUtil.java' 6402: AR-1643 Web Script args object does not handle multi-value arguments 6407: Removed use of QName "{}silly" as a data type definition. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6728 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
242 lines
7.0 KiB
Java
242 lines
7.0 KiB
Java
/*
|
|
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* As a special exception to the terms and conditions of version 2.0 of
|
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
|
* FLOSS exception. You should have recieved a copy of the text describing
|
|
* the FLOSS exception, and it is also available here:
|
|
* http://www.alfresco.com/legal/licensing"
|
|
*/
|
|
package org.alfresco.web.scripts;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
|
|
/**
|
|
* Web Script Request implementation that acts upon a string representation
|
|
* of a URL
|
|
*
|
|
* @author davidc
|
|
*/
|
|
public abstract class WebScriptURLRequest extends WebScriptRequestImpl
|
|
{
|
|
/** Script Url components */
|
|
protected String contextPath;
|
|
protected String servletPath;
|
|
protected String pathInfo;
|
|
protected String queryString;
|
|
protected Map<String, String> queryArgs;
|
|
protected Map<String, List<String>> queryArgsMulti;
|
|
|
|
/** Service bound to this request */
|
|
protected WebScriptMatch serviceMatch;
|
|
|
|
|
|
/**
|
|
* Splits a Web Script Url into its component parts
|
|
*
|
|
* @param scriptUrl url e.g. /alfresco/service/mytasks?f=1
|
|
* @return url parts [0] = context (e.g. alfresco), [1] = servlet (e.g. service), [2] = script (e.g. mytasks), [3] = args (e.g. f=1)
|
|
*/
|
|
public static String[] splitURL(String scriptUrl)
|
|
{
|
|
String[] urlParts = new String[4];
|
|
String path;
|
|
String queryString;
|
|
|
|
int argsIndex = scriptUrl.indexOf("?");
|
|
if (argsIndex != -1)
|
|
{
|
|
path = scriptUrl.substring(0, argsIndex);
|
|
queryString = scriptUrl.substring(argsIndex + 1);
|
|
}
|
|
else
|
|
{
|
|
path = scriptUrl;
|
|
queryString = null;
|
|
}
|
|
|
|
String[] pathSegments = path.split("/");
|
|
String pathInfo = "";
|
|
for (int i = 3; i < pathSegments.length; i++)
|
|
{
|
|
pathInfo += "/" + pathSegments[i];
|
|
}
|
|
|
|
urlParts[0] = "/" + pathSegments[1]; // context path
|
|
urlParts[1] = "/" + pathSegments[2]; // servlet path
|
|
urlParts[2] = pathInfo; // path info
|
|
urlParts[3] = queryString; // query string
|
|
|
|
return urlParts;
|
|
}
|
|
|
|
/**
|
|
* Construct
|
|
*
|
|
* @param scriptUrl
|
|
* @param serviceMatch
|
|
*/
|
|
public WebScriptURLRequest(String scriptUrl, WebScriptMatch serviceMatch)
|
|
{
|
|
this(splitURL(scriptUrl), serviceMatch);
|
|
}
|
|
|
|
/**
|
|
* Construct
|
|
*
|
|
* @param scriptUrlParts
|
|
* @param serviceMatch
|
|
*/
|
|
public WebScriptURLRequest(String[] scriptUrlParts, WebScriptMatch serviceMatch)
|
|
{
|
|
this.contextPath = scriptUrlParts[0];
|
|
this.servletPath = scriptUrlParts[1];
|
|
this.pathInfo = scriptUrlParts[2];
|
|
this.queryString = scriptUrlParts[3];
|
|
this.queryArgs = new HashMap<String, String>();
|
|
this.queryArgsMulti = new HashMap<String, List<String>>();
|
|
if (this.queryString != null)
|
|
{
|
|
String[] args = this.queryString.split("&");
|
|
for (String arg : args)
|
|
{
|
|
String[] parts = arg.split("=");
|
|
if (this.queryArgs.containsKey(parts[0]))
|
|
{
|
|
List<String> values = this.queryArgsMulti.get(parts[0]);
|
|
if (values == null)
|
|
{
|
|
values = new ArrayList<String>();
|
|
this.queryArgsMulti.put(parts[0], values);
|
|
}
|
|
values.add(parts.length == 2 ? parts[1] : "");
|
|
}
|
|
else
|
|
{
|
|
this.queryArgs.put(parts[0], parts.length == 2 ? parts[1] : "");
|
|
}
|
|
}
|
|
}
|
|
this.serviceMatch = serviceMatch;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.alfresco.web.scripts.WebScriptRequest#getServiceMatch()
|
|
*/
|
|
public WebScriptMatch getServiceMatch()
|
|
{
|
|
return serviceMatch;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.alfresco.web.scripts.WebScriptRequest#getContextPath()
|
|
*/
|
|
public String getContextPath()
|
|
{
|
|
return contextPath;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.alfresco.web.scripts.WebScriptRequest#getServiceContextPath()
|
|
*/
|
|
public String getServiceContextPath()
|
|
{
|
|
return getContextPath() + servletPath;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.alfresco.web.scripts.WebScriptRequest#getServicePath()
|
|
*/
|
|
public String getServicePath()
|
|
{
|
|
return getServiceContextPath() + pathInfo;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.alfresco.web.scripts.WebScriptRequest#getURL()
|
|
*/
|
|
public String getURL()
|
|
{
|
|
return getServicePath() + (queryString != null ? "?" + queryString : "");
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.alfresco.web.scripts.WebScriptRequest#getPathInfo()
|
|
*/
|
|
public String getPathInfo()
|
|
{
|
|
return pathInfo;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.alfresco.web.scripts.WebScriptRequest#getQueryString()
|
|
*/
|
|
public String getQueryString()
|
|
{
|
|
return queryString;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.alfresco.web.scripts.WebScriptRequest#getParameterNames()
|
|
*/
|
|
public String[] getParameterNames()
|
|
{
|
|
Set<String> keys = queryArgs.keySet();
|
|
String[] names = new String[keys.size()];
|
|
keys.toArray(names);
|
|
return names;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.alfresco.web.scripts.WebScriptRequest#getParameter(java.lang.String)
|
|
*/
|
|
public String getParameter(String name)
|
|
{
|
|
return queryArgs.get(name);
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.alfresco.web.scripts.WebScriptRequest#getArrayParameter(java.lang.String)
|
|
*/
|
|
public String[] getParameterValues(String name)
|
|
{
|
|
List<String> values = queryArgsMulti.get(name);
|
|
if (values != null)
|
|
{
|
|
String[] array = new String[values.size()];
|
|
values.toArray(array);
|
|
return array;
|
|
}
|
|
else
|
|
{
|
|
String value = queryArgs.get(name);
|
|
if (value != null)
|
|
{
|
|
return new String[]{value};
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|