All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jwall.apache.httpd.config.SecAction Maven / Gradle / Ivy

The newest version!
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *   Copyright (C) 2010-2014 Christian Bockermann 
 *    
 *   This file is part of the jwall.org apache-config library. The apache-config library is
 *   a parsing library to handle Apache HTTPD configuration files.
 *
 *   More information and documentation for the jwall-tools can be found at
 *   
 *                      http://www.jwall.org/apache-config
 *   
 *   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 3 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, see .
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package org.jwall.apache.httpd.config;

import java.io.File;
import java.util.LinkedList;
import java.util.List;

import com.thoughtworks.xstream.annotations.XStreamAlias;

/**
 * 

* Instance of this class represent any SecAction directive found * in the configuration tree. *

* * @author Christian Bockermann <[email protected]> * */ @XStreamAlias("SecAction") public class SecAction extends AbstractDirective { /** */ private static final long serialVersionUID = -1435563241845012179L; @XStreamAlias("Actions") LinkedList actions = new LinkedList(); /** * * * @param line * @param file * @param lineNum * @throws ParseException */ public SecAction(String line, File file, int lineNum) throws ParseException { super(line, file, lineNum); name = "SecAction"; String ln = line.trim(); // the trimmed line int idx = ln.indexOf(" "); if (idx < 1) { throw new ParseException( "Missing white-space to split 'SecAction' directive!"); } String dir = ln.substring(0, idx); String actions = ln.substring(idx + 1).trim(); // List args = QuotedStringTokenizer.splitRespectQuotes(actions, // ' '); // line.trim().split(" "); if (!dir.trim().equals("SecAction")) throw new ParseException("Not a SecAction-directive: " + line); parseActions(removeQuotes(actions)); } protected void parseActions(String actionString) { String unquoted = removeQuotes(actionString); for (String action : QuotedStringTokenizer.splitRespectQuotes(unquoted, ',')) { String act = removeQuotes(action.trim()); actions.add(act); } } public String getName() { return new String("SecAction"); } public String toXML() { // return SecRule.xs.toXML( this ); StringBuffer s = new StringBuffer(prefix() + "\n"); if (actions != null) { // s.append( prefix() + " "+actions+"\n"); for (String action : actions) { s.append(prefix() + " "); s.append(action); s.append("\n"); } } s.append(prefix() + ""); return s.toString(); } /** * * @return */ public List getActions() { return actions; } public String getProviderName() { return "mod_security.c"; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy