org.apache.jasper.security.SecurityUtil Java Examples

The following examples show how to use org.apache.jasper.security.SecurityUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PageContextImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void removeAttribute(final String name, final int scope) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }
    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doRemoveAttribute(name, scope);
                return null;
            }
        });
    } else {
        doRemoveAttribute(name, scope);
    }
}
 
Example #2
Source File: PageContextImpl.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public void removeAttribute(final String name) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doRemoveAttribute(name);
                return null;
            }
        });
    } else {
        doRemoveAttribute(name);
    }
}
 
Example #3
Source File: PageContextImpl.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public void include(final String relativeUrlPath, final boolean flush)
        throws ServletException, IOException {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
            AccessController.doPrivileged(
                    new PrivilegedExceptionAction<Void>() {
                @Override
                public Void run() throws Exception {
                    doInclude(relativeUrlPath, flush);
                    return null;
                }
            });
        } catch (PrivilegedActionException e) {
            Exception ex = e.getException();
            if (ex instanceof IOException) {
                throw (IOException) ex;
            } else {
                throw (ServletException) ex;
            }
        }
    } else {
        doInclude(relativeUrlPath, flush);
    }
}
 
Example #4
Source File: PageContextImpl.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public void forward(final String relativeUrlPath) throws ServletException,
        IOException {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
            AccessController.doPrivileged(
                    new PrivilegedExceptionAction<Void>() {
                @Override
                public Void run() throws Exception {
                    doForward(relativeUrlPath);
                    return null;
                }
            });
        } catch (PrivilegedActionException e) {
            Exception ex = e.getException();
            if (ex instanceof IOException) {
                throw (IOException) ex;
            } else {
                throw (ServletException) ex;
            }
        }
    } else {
        doForward(relativeUrlPath);
    }
}
 
Example #5
Source File: PageContextImpl.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public int getAttributesScope(final String name) {

        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            return (AccessController.doPrivileged(new PrivilegedAction<Integer>(){
                public Integer run(){
                    return Integer.valueOf(doGetAttributeScope(name));
                }
            })).intValue();
        } else {
            return doGetAttributeScope(name);
        }
    }
 
Example #6
Source File: JspServlet.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
private void handleMissingResource(HttpServletRequest request,
        HttpServletResponse response, String jspUri)
        throws ServletException, IOException {

    String includeRequestUri =
        (String)request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);

    if (includeRequestUri != null) {
        // This file was included. Throw an exception as
        // a response.sendError() will be ignored
        String msg =
            Localizer.getMessage("jsp.error.file.not.found",jspUri);
        // Strictly, filtering this is an application
        // responsibility but just in case...
        throw new ServletException(SecurityUtil.filter(msg));
    } else {
        try {
            response.sendError(HttpServletResponse.SC_NOT_FOUND,
                    request.getRequestURI());
        } catch (IllegalStateException ise) {
            log.error(Localizer.getMessage("jsp.error.file.not.found",
                    jspUri));
        }
    }
    return;
}
 
Example #7
Source File: PageContextImpl.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public void removeAttribute(final String name, final int scope) {

        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }
        if (SecurityUtil.isPackageProtectionEnabled()){
            AccessController.doPrivileged(new PrivilegedAction<Object>(){
                public Object run(){
                    doRemoveAttribute(name, scope);
                    return null;
                }
            });
        } else {
            doRemoveAttribute(name, scope);
        }
    }
 
Example #8
Source File: PageContextImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public Object getAttribute(final String name) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        return AccessController.doPrivileged(
                new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                return doGetAttribute(name);
            }
        });
    } else {
        return doGetAttribute(name);
    }

}
 
Example #9
Source File: PageContextImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public Object getAttribute(final String name, final int scope) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        return AccessController.doPrivileged(
                new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                return doGetAttribute(name, scope);
            }
        });
    } else {
        return doGetAttribute(name, scope);
    }

}
 
Example #10
Source File: PageContextImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void setAttribute(final String name, final Object attribute) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doSetAttribute(name, attribute);
                return null;
            }
        });
    } else {
        doSetAttribute(name, attribute);
    }
}
 
Example #11
Source File: PageContextImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void setAttribute(final String name, final Object o, final int scope) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doSetAttribute(name, o, scope);
                return null;
            }
        });
    } else {
        doSetAttribute(name, o, scope);
    }

}
 
Example #12
Source File: PageContextImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public Object getAttribute(final String name) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        return AccessController.doPrivileged(
                new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                return doGetAttribute(name);
            }
        });
    } else {
        return doGetAttribute(name);
    }

}
 
Example #13
Source File: PageContextImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public int getAttributesScope(final String name) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        return (AccessController
                .doPrivileged(new PrivilegedAction<Integer>() {
                    @Override
                    public Integer run() {
                        return Integer.valueOf(doGetAttributeScope(name));
                    }
                })).intValue();
    } else {
        return doGetAttributeScope(name);
    }
}
 
Example #14
Source File: PageContextImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public Object findAttribute(final String name) {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        return AccessController.doPrivileged(
                new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                if (name == null) {
                    throw new NullPointerException(Localizer
                            .getMessage("jsp.error.attribute.null_name"));
                }

                return doFindAttribute(name);
            }
        });
    } else {
        if (name == null) {
            throw new NullPointerException(Localizer
                    .getMessage("jsp.error.attribute.null_name"));
        }

        return doFindAttribute(name);
    }
}
 
Example #15
Source File: PageContextImpl.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public void setAttribute(final String name, final Object o, final int scope) {

        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            AccessController.doPrivileged(new PrivilegedAction<Object>(){
                public Object run(){
                    doSetAttribute(name, o, scope);
                    return null;
                }
            });
        } else {
            doSetAttribute(name, o, scope);
        }

    }
 
Example #16
Source File: PageContextImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void removeAttribute(final String name) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doRemoveAttribute(name);
                return null;
            }
        });
    } else {
        doRemoveAttribute(name);
    }
}
 
Example #17
Source File: PageContextImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void include(final String relativeUrlPath, final boolean flush)
        throws ServletException, IOException {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
            AccessController.doPrivileged(
                    new PrivilegedExceptionAction<Void>() {
                @Override
                public Void run() throws Exception {
                    doInclude(relativeUrlPath, flush);
                    return null;
                }
            });
        } catch (PrivilegedActionException e) {
            Exception ex = e.getException();
            if (ex instanceof IOException) {
                throw (IOException) ex;
            } else {
                throw (ServletException) ex;
            }
        }
    } else {
        doInclude(relativeUrlPath, flush);
    }
}
 
Example #18
Source File: PageContextImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void forward(final String relativeUrlPath) throws ServletException,
        IOException {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
            AccessController.doPrivileged(
                    new PrivilegedExceptionAction<Void>() {
                @Override
                public Void run() throws Exception {
                    doForward(relativeUrlPath);
                    return null;
                }
            });
        } catch (PrivilegedActionException e) {
            Exception ex = e.getException();
            if (ex instanceof IOException) {
                throw (IOException) ex;
            } else {
                throw (ServletException) ex;
            }
        }
    } else {
        doForward(relativeUrlPath);
    }
}
 
Example #19
Source File: PageContextImpl.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public void setAttribute(final String name, final Object attribute) {

        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            AccessController.doPrivileged(new PrivilegedAction<Object>(){
                public Object run(){
                    doSetAttribute(name, attribute);
                    return null;
                }
            });
        } else {
            doSetAttribute(name, attribute);
        }
    }
 
Example #20
Source File: PageContextImpl.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public Object getAttribute(final String name, final int scope) {

        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            return AccessController.doPrivileged(new PrivilegedAction<Object>(){
                public Object run(){
                    return doGetAttribute(name, scope);
                }
            });
        } else {
            return doGetAttribute(name, scope);
        }

    }
 
Example #21
Source File: ProtectedFunctionMapper.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
/**
    * Generated Servlet and Tag Handler implementations call this
    * method to retrieve an instance of the ProtectedFunctionMapper.
    * This is necessary since generated code does not have access to
    * create instances of classes in this package.
    *
    * @return A new protected function mapper.
    */
   public static ProtectedFunctionMapper getInstance() {
       ProtectedFunctionMapper funcMapper;
if (SecurityUtil.isPackageProtectionEnabled()) {
    funcMapper = AccessController.doPrivileged(
	new PrivilegedAction<ProtectedFunctionMapper>() {
	public ProtectedFunctionMapper run() {
	    return new ProtectedFunctionMapper();
	}
    } );
} else {
    funcMapper = new ProtectedFunctionMapper();
}
funcMapper.fnmap = new java.util.HashMap<String, Method>();
return funcMapper;
   }
 
Example #22
Source File: PageContextImpl.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public Object getAttribute(final String name) {

        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            return AccessController.doPrivileged(new PrivilegedAction<Object>(){
                public Object run(){
                    return doGetAttribute(name);
                }
            });
        } else {
            return doGetAttribute(name);
        }

    }
 
Example #23
Source File: PageContextImpl.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public Object findAttribute(final String name) {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        return AccessController.doPrivileged(
                new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                if (name == null) {
                    throw new NullPointerException(Localizer
                            .getMessage("jsp.error.attribute.null_name"));
                }

                return doFindAttribute(name);
            }
        });
    } else {
        if (name == null) {
            throw new NullPointerException(Localizer
                    .getMessage("jsp.error.attribute.null_name"));
        }

        return doFindAttribute(name);
    }
}
 
Example #24
Source File: PageContextImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public Object getAttribute(final String name, final int scope) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        return AccessController.doPrivileged(
                new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                return doGetAttribute(name, scope);
            }
        });
    } else {
        return doGetAttribute(name, scope);
    }

}
 
Example #25
Source File: PageContextImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void setAttribute(final String name, final Object attribute) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doSetAttribute(name, attribute);
                return null;
            }
        });
    } else {
        doSetAttribute(name, attribute);
    }
}
 
Example #26
Source File: PageContextImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void setAttribute(final String name, final Object o, final int scope) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doSetAttribute(name, o, scope);
                return null;
            }
        });
    } else {
        doSetAttribute(name, o, scope);
    }

}
 
Example #27
Source File: PageContextImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void removeAttribute(final String name, final int scope) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }
    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doRemoveAttribute(name, scope);
                return null;
            }
        });
    } else {
        doRemoveAttribute(name, scope);
    }
}
 
Example #28
Source File: PageContextImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public int getAttributesScope(final String name) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        return (AccessController
                .doPrivileged(new PrivilegedAction<Integer>() {
                    @Override
                    public Integer run() {
                        return Integer.valueOf(doGetAttributeScope(name));
                    }
                })).intValue();
    } else {
        return doGetAttributeScope(name);
    }
}
 
Example #29
Source File: PageContextImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public Object findAttribute(final String name) {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        return AccessController.doPrivileged(
                new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                if (name == null) {
                    throw new NullPointerException(Localizer
                            .getMessage("jsp.error.attribute.null_name"));
                }

                return doFindAttribute(name);
            }
        });
    } else {
        if (name == null) {
            throw new NullPointerException(Localizer
                    .getMessage("jsp.error.attribute.null_name"));
        }

        return doFindAttribute(name);
    }
}
 
Example #30
Source File: PageContextImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void removeAttribute(final String name) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doRemoveAttribute(name);
                return null;
            }
        });
    } else {
        doRemoveAttribute(name);
    }
}