/xservices/trunk/src/java/net/brutex/xservices/ws/rs/FileInfo.java |
---|
42,7 → 42,6 |
public abstract interface FileInfo { |
public final static String BASE_PATH = "/FileService/"; |
public final static String SERVICE_NAME = "FileInfoService"; |
/** |
* Get the file/ directory listing. |
/xservices/trunk/src/java/net/brutex/xservices/ws/rs/FileInfoImpl.java |
---|
73,14 → 73,12 |
*/ |
public Response getFiles(HttpHeaders h, UriInfo uriInfo, String dir, boolean withDir, boolean withFiles, int level, String search, int count, int page, boolean useCache) |
{ |
if(dir==null) { |
dir = "c:/"; |
logger.warn("No directory specified. Default is 'c:/'."); |
} |
isPermitted(dir); |
URI baseuri = URI.create(uriInfo.getBaseUri()+FileInfo.BASE_PATH+"getFile?file="); |
if(dir==null) {dir = "c:/"; System.out.println("No directory specified.");} |
logger.info(String.format("Listing directory '%s'.", dir)); |
if (level <= 0) level = 1; |
111,8 → 109,9 |
logger.info(String.format("Returning items %s to %s from total of %s items in the list.", fromIndex, toIndex, list.size())); |
return Response.ok(sublist).build(); |
} catch (CacheException e) { |
return Response.serverError().build(); |
Response.serverError().build(); |
} |
return null; |
} |
/** |
255,14 → 254,4 |
} |
return true; |
} |
//http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java |
private static String humanReadableByteCount(long bytes, boolean si) { |
int unit = si ? 1000 : 1024; |
if (bytes < unit) return bytes + " B"; |
int exp = (int) (Math.log(bytes) / Math.log(unit)); |
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp-1) + (si ? "" : "i"); |
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre); |
} |
} |
/xservices/trunk/src/java/net/brutex/xservices/ws/rs/ResultType.java |
---|
1,19 → 1,3 |
/* |
* Copyright 2014 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
package net.brutex.xservices.ws.rs; |
import net.brutex.xservices.types.scm.ItemType; |
/xservices/trunk/src/java/net/brutex/xservices/ws/rs/FileListType.java |
---|
1,19 → 1,3 |
/* |
* Copyright 2014 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
package net.brutex.xservices.ws.rs; |
import javax.xml.bind.annotation.XmlElement; |
/xservices/trunk/src/java/net/brutex/xservices/ws/impl/XmlServiceImpl.java |
---|
61,7 → 61,6 |
import org.apache.log4j.Logger; |
import org.apache.shiro.SecurityUtils; |
import org.apache.shiro.authz.UnauthorizedException; |
import org.apache.shiro.authz.annotation.RequiresPermissions; |
import org.jaxen.JaxenException; |
import org.jaxen.SimpleNamespaceContext; |
195,7 → 194,6 |
} |
} |
@RequiresPermissions("insertNodes") |
public String insertNodes(String source, String encoding, NamespaceListType nsList, String xpath, String xmlFragment) throws XServicesFault { |
encoding = validateEncoding(encoding); |
try { |
/xservices/trunk/src/java/net/brutex/xservices/ws/impl/StringServiceImpl.java |
---|
20,15 → 20,12 |
import java.util.StringTokenizer; |
import java.util.regex.Matcher; |
import java.util.regex.Pattern; |
import javax.jws.WebService; |
import net.brutex.xservices.types.StringMatchType; |
import net.brutex.xservices.types.StringReplaceType; |
import net.brutex.xservices.types.StringSplitType; |
import net.brutex.xservices.ws.StringService; |
import net.brutex.xservices.ws.XServicesFault; |
import org.apache.commons.lang3.StringEscapeUtils; |
import org.apache.commons.lang3.text.translate.CharSequenceTranslator; |
import org.apache.commons.lang3.text.translate.NumericEntityEscaper; |
100,12 → 97,6 |
return result; |
} |
@Override |
public String removeCRLF(String paramString) throws XServicesFault { |
String value = paramString.replaceAll("[\r\n]", ""); |
return value; |
} |
private int getFlags(String flags) { |
int allflags = 0; |
if (flags.contains("i")) { |
/xservices/trunk/src/java/net/brutex/xservices/ws/impl/ExecuteServiceImpl.java |
---|
17,6 → 17,8 |
package net.brutex.xservices.ws.impl; |
import java.io.File; |
import java.util.UUID; |
import javax.jws.WebMethod; |
import javax.jws.WebParam; |
import javax.jws.WebService; |
23,6 → 25,7 |
import net.brutex.xservices.types.HostConnection; |
import net.brutex.xservices.types.ReturnCode; |
import net.brutex.xservices.util.BrutexNamespaces; |
import net.brutex.xservices.util.JobWrapper; |
import net.brutex.xservices.util.RunTask; |
import net.brutex.xservices.ws.ExecuteService; |
import net.brutex.xservices.ws.XServicesFault; |
34,6 → 37,16 |
import org.apache.tools.ant.types.Commandline; |
import org.mozilla.javascript.Context; |
import org.mozilla.javascript.Scriptable; |
import org.quartz.JobBuilder; |
import org.quartz.JobDetail; |
import org.quartz.Scheduler; |
import org.quartz.SchedulerException; |
import org.quartz.Trigger; |
import static org.quartz.TriggerBuilder.*; |
import static org.quartz.SimpleScheduleBuilder.*; |
import org.quartz.TriggerUtils; |
import org.quartz.impl.StdSchedulerFactory; |
import org.quartz.impl.triggers.SimpleTriggerImpl; |
/** |
* |
/xservices/trunk/src/java/net/brutex/xservices/ws/XmlService.java |
---|
27,7 → 27,6 |
import net.brutex.xservices.types.ant.FileResource; |
import org.apache.cxf.annotations.WSDLDocumentation; |
import org.apache.shiro.authz.annotation.RequiresPermissions; |
/** |
* @author Brian Rosenberger, bru(at)brutex.de |
42,7 → 41,6 |
public static final String PARAM_XPATH = "xpath"; |
public static final String PARAM_XML = "xmldata"; |
@RequiresPermissions("insertNodes") |
@WebMethod(operationName="insertNodes") |
@WSDLDocumentation("Insert an XML fragment into an XML document given as string.") |
public abstract String insertNodes( |
/xservices/trunk/src/java/net/brutex/xservices/ws/StringService.java |
---|
75,10 → 75,4 |
@WebParam(name="delimiter") @XmlElement(required=true) String delimiter) |
throws XServicesFault; |
@WebMethod(operationName="removeCRLF") |
@WSDLDocumentation("Remove any line feed and/ or carriage return characters") |
public abstract String removeCRLF( |
@WebParam(name="string") @XmlElement(required=true) String paramString) |
throws XServicesFault; |
} |
/xservices/trunk/src/java/net/brutex/xservices/ws/ArchiveService.java |
---|
1,5 → 1,5 |
/* |
g * Copyright 2010 Brian Rosenberger (Brutex Network) |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
/xservices/trunk/src/java/net/brutex/xservices/security/XmlServicePermission.java |
---|
File deleted |
Property changes: |
Deleted: svn:mime-type |
-text/plain |
\ No newline at end of property |
/xservices/trunk/src/java/net/brutex/xservices/security/PermissionResolver.java |
---|
16,12 → 16,8 |
package net.brutex.xservices.security; |
import net.brutex.xservices.ws.XmlService; |
import net.brutex.xservices.ws.rs.FileInfo; |
import org.apache.log4j.Logger; |
import org.apache.shiro.authz.Permission; |
import org.apache.shiro.authz.permission.InvalidPermissionStringException; |
/** |
* @author Brian Rosenberger, bru(at)brutex.de |
30,31 → 26,10 |
public class PermissionResolver implements org.apache.shiro.authz.permission.PermissionResolver { |
final Logger logger = Logger.getLogger(PermissionResolver.class); |
private final String DELIMITER = "||"; |
@Override |
public Permission resolvePermission(String permissionString) { |
logger.debug(String.format("Trying to examine new Permission '%s'", permissionString)); |
if(! permissionString.contains(DELIMITER)) { |
logger.error(String.format("Permission '%s' is missing permission class.", permissionString)); |
throw new InvalidPermissionStringException(String.format("Permission '%s' is missing permission class.", permissionString), permissionString); |
logger.debug(String.format("Creating new Permission '%s'", permissionString)); |
return new DirectoryPermission(permissionString); |
} |
int delimiterIndex = permissionString.indexOf(DELIMITER); |
String value = permissionString.substring(0, delimiterIndex); |
delimiterIndex = delimiterIndex + DELIMITER.length(); |
switch (value) { |
case XmlService.SERVICE_NAME: |
logger.debug(String.format("Found '%s' as permission class.", value)); |
return new XmlServicePermission(permissionString.substring( delimiterIndex )); |
case FileInfo.SERVICE_NAME: |
logger.debug(String.format("Found '%s' as permission class.", value)); |
return new DirectoryPermission(permissionString.substring( delimiterIndex )); |
default: |
logger.warn(String.format("Permission class '%s' is not defined.", value)); |
throw new InvalidPermissionStringException(String.format("Permission class '%s' is not defined.", value), permissionString); |
} |
} |
} |
/xservices/trunk/src/java/net/brutex/xservices/security/DirectoryPermission.java |
---|
30,7 → 30,6 |
private final String path; |
public DirectoryPermission(String antlikepath) { |
logger.debug(String.format("Creating permission for path '%s'", antlikepath)); |
path = antlikepath; |
} |