当前位置: 首页>>代码示例>>Java>>正文


Java SecurityUtil类代码示例

本文整理汇总了Java中org.apache.catalina.security.SecurityUtil的典型用法代码示例。如果您正苦于以下问题:Java SecurityUtil类的具体用法?Java SecurityUtil怎么用?Java SecurityUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SecurityUtil类属于org.apache.catalina.security包,在下文中一共展示了SecurityUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
@Override
public void load() throws ClassNotFoundException, IOException {
    if (SecurityUtil.isPackageProtectionEnabled()){
        try{
            AccessController.doPrivileged( new PrivilegedDoLoad() );
        } catch (PrivilegedActionException ex){
            Exception exception = ex.getException();
            if (exception instanceof ClassNotFoundException) {
                throw (ClassNotFoundException)exception;
            } else if (exception instanceof IOException) {
                throw (IOException)exception;
            }
            if (log.isDebugEnabled()) {
                log.debug("Unreported exception in load() ", exception);
            }
        }
    } else {
        doLoad();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:StandardManager.java

示例2: removeSession

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
/**
 * Remove this Session from the active Sessions for this Manager,
 * and from the Store.
 *
 * @param id Session's id to be removed
 */    
protected void removeSession(String id){
    try {
        if (SecurityUtil.isPackageProtectionEnabled()){
            try{
                AccessController.doPrivileged(new PrivilegedStoreRemove(id));
            }catch(PrivilegedActionException ex){
                Exception exception = ex.getException();
                log.error("Exception in the Store during removeSession: "
                          + exception, exception);
            }
        } else {
             store.remove(id);
        }               
    } catch (IOException e) {
        log.error("Exception removing session  " + e.getMessage(), e);
    }        
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:PersistentManagerBase.java

示例3: getSession

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
/**
 * Return the <code>HttpSession</code> for which this object
 * is the facade.
 */
@Override
public HttpSession getSession() {

    if (facade == null){
        if (SecurityUtil.isPackageProtectionEnabled()){
            final StandardSession fsession = this;
            facade = AccessController.doPrivileged(
                    new PrivilegedAction<StandardSessionFacade>(){
                @Override
                public StandardSessionFacade run(){
                    return new StandardSessionFacade(fsession);
                }
            });
        } else {
            facade = new StandardSessionFacade(this);
        }
    }
    return (facade);

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:25,代码来源:StandardSession.java

示例4: clearStore

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
/**
 * Clear all sessions from the Store.
 */
public void clearStore() {

    if (store == null)
        return;

    try {     
        if (SecurityUtil.isPackageProtectionEnabled()){
            try{
                AccessController.doPrivileged(new PrivilegedStoreClear());
            }catch(PrivilegedActionException ex){
                Exception exception = ex.getException();
                log.error("Exception clearing the Store: " + exception,
                        exception);
            }
        } else {
            store.clear();
        }
    } catch (IOException e) {
        log.error("Exception clearing the Store: " + e, e);
    }

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:26,代码来源:PersistentManagerBase.java

示例5: generateCookieString

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
public StringBuffer generateCookieString(final Cookie cookie) {
    final StringBuffer sb = new StringBuffer();
    //web application code can receive a IllegalArgumentException
    //from the appendCookieValue invocation
    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run(){
                ServerCookie.appendCookieValue
                    (sb, cookie.getVersion(), cookie.getName(),
                     cookie.getValue(), cookie.getPath(),
                     cookie.getDomain(), cookie.getComment(),
                     cookie.getMaxAge(), cookie.getSecure(),
                     cookie.isHttpOnly());
                return null;
            }
        });
    } else {
        ServerCookie.appendCookieValue
            (sb, cookie.getVersion(), cookie.getName(), cookie.getValue(),
                 cookie.getPath(), cookie.getDomain(), cookie.getComment(),
                 cookie.getMaxAge(), cookie.getSecure(),
                 cookie.isHttpOnly());
    }
    return sb;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:27,代码来源:Response.java

示例6: doPrivileged

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked") // doPrivileged() returns the correct type
public <T extends Servlet> T createServlet(Class<T> c) throws ServletException {
	if (SecurityUtil.isPackageProtectionEnabled()) {
		try {
			return (T) invokeMethod(context, "createServlet", new Object[] { c });
		} catch (Throwable t) {
			ExceptionUtils.handleThrowable(t);
			if (t instanceof ServletException) {
				throw (ServletException) t;
			}
			return null;
		}
	} else {
		return context.createServlet(c);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:18,代码来源:ApplicationContextFacade.java

示例7: getServlet

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
/**
 * @deprecated As of Java Servlet API 2.1, with no direct replacement.
 */
@Override
@Deprecated
public Servlet getServlet(String name)
    throws ServletException {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
            return (Servlet) invokeMethod(context, "getServlet", 
                                          new Object[]{name});
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            if (t instanceof ServletException) {
                throw (ServletException) t;
            }
            return null;
        }
    } else {
        return context.getServlet(name);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:ApplicationContextFacade.java

示例8: getParameterValues

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
@Override
public String[] getParameterValues(String name) {

	if (request == null) {
		throw new IllegalStateException(sm.getString("requestFacade.nullRequest"));
	}

	String[] ret = null;

	/*
	 * Clone the returned array only if there is a security manager in
	 * place, so that performance won't suffer in the non-secure case
	 */
	if (SecurityUtil.isPackageProtectionEnabled()) {
		ret = AccessController.doPrivileged(new GetParameterValuePrivilegedAction(name));
		if (ret != null) {
			ret = ret.clone();
		}
	} else {
		ret = request.getParameterValues(name);
	}

	return ret;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:25,代码来源:RequestFacade.java

示例9: doPrivileged

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked") // doPrivileged() returns the correct type
public <T extends Servlet> T createServlet(Class<T> c)
throws ServletException {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
            return (T) invokeMethod(context, "createServlet", 
                                          new Object[]{c});
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            if (t instanceof ServletException) {
                throw (ServletException) t;
            }
            return null;
        }
    } else {
        return context.createServlet(c);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:20,代码来源:ApplicationContextFacade.java

示例10: doPrivileged

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked") // doPrivileged() returns the correct type
public <T extends Filter> T createFilter(Class<T> c)
throws ServletException {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
            return (T) invokeMethod(context, "createFilter", 
                                          new Object[]{c});
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            if (t instanceof ServletException) {
                throw (ServletException) t;
            }
            return null;
        }
    } else {
        return context.createFilter(c);
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:20,代码来源:ApplicationContextFacade.java

示例11: getCookies

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
@Override
public Cookie[] getCookies() {

    if (request == null) {
        throw new IllegalStateException(
                        sm.getString("requestFacade.nullRequest"));
    }

    Cookie[] ret = null;

    /*
     * Clone the returned array only if there is a security manager
     * in place, so that performance won't suffer in the non-secure case
     */
    if (SecurityUtil.isPackageProtectionEnabled()){
        ret = AccessController.doPrivileged(
            new GetCookiesPrivilegedAction());
        if (ret != null) {
            ret = ret.clone();
        }
    } else {
        ret = request.getCookies();
    }

    return ret;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:27,代码来源:RequestFacade.java

示例12: clearStore

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
/**
 * Clear all sessions from the Store.
 */
public void clearStore() {

	if (store == null)
		return;

	try {
		if (SecurityUtil.isPackageProtectionEnabled()) {
			try {
				AccessController.doPrivileged(new PrivilegedStoreClear());
			} catch (PrivilegedActionException ex) {
				Exception exception = ex.getException();
				log.error("Exception clearing the Store: " + exception, exception);
			}
		} else {
			store.clear();
		}
	} catch (IOException e) {
		log.error("Exception clearing the Store: " + e, e);
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:25,代码来源:PersistentManagerBase.java

示例13: removeSession

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
/**
 * Remove this Session from the active Sessions for this Manager,
 * and from the Store.
 *
 * @param id Session's id to be removed
 */    
protected void removeSession(String id){
    try {
        if (SecurityUtil.isPackageProtectionEnabled()){
            try{
                AccessController.doPrivileged(new PrivilegedStoreRemove(id));
            }catch(PrivilegedActionException ex){
                Exception exception = ex.getException();
                log.error("Exception in the Store during removeSession: "
                          + exception);
                exception.printStackTrace();                        
            }
        } else {
             store.remove(id);
        }               
    } catch (IOException e) {
        log.error("Exception removing session  " + e.getMessage());
        e.printStackTrace();
    }        
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:PersistentManagerBase.java

示例14: getSession

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
/**
 * Return the <code>HttpSession</code> for which this object
 * is the facade.
 */
public HttpSession getSession() {

    if (facade == null){
        if (SecurityUtil.isPackageProtectionEnabled()){
            final StandardSession fsession = this;
            facade = (StandardSessionFacade)AccessController.doPrivileged(new PrivilegedAction(){
                public Object run(){
                    return new StandardSessionFacade(fsession);
                }
            });
        } else {
            facade = new StandardSessionFacade(this);
        }
    }
    return (facade);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:StandardSession.java

示例15: release

import org.apache.catalina.security.SecurityUtil; //导入依赖的package包/类
/**
 * Release the Filter instance associated with this FilterConfig,
 * if there is one.
 */
void release() {

    if (this.filter != null)
    {
        if (Globals.IS_SECURITY_ENABLED) {
            try {
                SecurityUtil.doAsPrivilege("destroy", filter);
            } catch(java.lang.Exception ex){
                context.getLogger().error("ApplicationFilterConfig.doAsPrivilege", ex);
            }
            SecurityUtil.remove(filter);
        } else {
            filter.destroy();
        }
        if (!context.getIgnoreAnnotations()) {
            try {
                ((StandardContext) context).getInstanceManager().destroyInstance(this.filter);
            } catch (Exception e) {
                context.getLogger().error("ApplicationFilterConfig.preDestroy", e);
            }
        }
    }
    this.filter = null;

 }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:ApplicationFilterConfig.java


注:本文中的org.apache.catalina.security.SecurityUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。