<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    asdtiang的博客 感謝blogjava提供的博客交流平臺
    閑話不多說,直接上代碼吧:
    第一:如何更改acegi的源碼:在STS 中工程視圖改為project explorer ,在工程上點(diǎn)擊右擊,有個(gè)grails tools,里面刷新下依賴,在工程下就應(yīng)該出現(xiàn)所有插件的源碼了,這樣就可以改了。
    找到了下類:

    改為如何下代碼:我也記不清怎么改的了:

    /* Copyright 2006-2009 the original author or authors.
     *
     * 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 org.codehaus.groovy.grails.plugins.springsecurity;

    import java.io.IOException;

    import javax.servlet.FilterChain;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;

    import org.springframework.security.Authentication;
    import org.springframework.security.AuthenticationException;
    import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
    import org.springframework.security.ui.webapp.AuthenticationProcessingFilter;
    import org.springframework.security.util.TextUtils;
    import org.springframework.util.StringUtils;

    /**
     * Extends the default {
    @link AuthenticationProcessingFilter} to override the
     * <code>sendRedirect()</code> logic and always send absolute redirects.
     * 
     * 
    @author Tsuyoshi Yamamoto
     
    */
    public class GrailsAuthenticationProcessingFilter extends
            AuthenticationProcessingFilter {

        
    private String _ajaxAuthenticationFailureUrl;

        
    /**
         * {
    @inheritDoc}
         * 
         * 
    @see org.springframework.security.ui.AbstractProcessingFilter#doFilterHttp(javax.servlet.http.HttpServletRequest,
         *      javax.servlet.http.HttpServletResponse, javax.servlet.FilterChain)
         
    */
        @Override
        
    public void doFilterHttp(final HttpServletRequest request,
                
    final HttpServletResponse response, final FilterChain chain)
                
    throws IOException, ServletException {
            SecurityRequestHolder.set(request, response);
            
    try {
                
    super.doFilterHttp(request, response, chain);
            } 
    finally {
                SecurityRequestHolder.reset();
            }
        }

        
    /**
         * {
    @inheritDoc}
         * 
         * 
    @see org.springframework.security.ui.AbstractProcessingFilter#sendRedirect(javax.servlet.http.HttpServletRequest,
         *      javax.servlet.http.HttpServletResponse, java.lang.String)
         
    */
        @Override
        
    protected void sendRedirect(final HttpServletRequest request,
                
    final HttpServletResponse response, final String url)
                
    throws IOException {
            RedirectUtils.sendRedirect(request, response, url);
        }

        
    /**
         * {
    @inheritDoc}
         * 
         * 
    @see org.springframework.security.ui.AbstractProcessingFilter#determineFailureUrl(javax.servlet.http.HttpServletRequest,
         *      org.springframework.security.AuthenticationException)
         
    */
        @Override
        
    protected String determineFailureUrl(final HttpServletRequest request,
                
    final AuthenticationException failed) {
            String url 
    = super.determineFailureUrl(request, failed);
            
    if (getAuthenticationFailureUrl().equals(url)
                    
    && AuthorizeTools.isAjax(request)) {
                url 
    = StringUtils.hasLength(_ajaxAuthenticationFailureUrl) ? _ajaxAuthenticationFailureUrl
                        : getAuthenticationFailureUrl();
            }
            
    return url;
        }

        
    /**
         * Dependency injection for the Ajax auth fail url.
         * 
         * 
    @param url
         *            the url
         
    */
        
    public void setAjaxAuthenticationFailureUrl(final String url) {
            _ajaxAuthenticationFailureUrl 
    = url;
        }

        
    public Authentication attemptAuthentication(HttpServletRequest request)
                
    throws AuthenticationException {
            String inputValidationCode 
    = request.getParameter( "captcha" );
            
    //從Session中取出驗(yàn)證碼
            String ssnValidationCode = (String)request.getSession().getAttribute( "captcha" );

            
    if( ssnValidationCode != null && !ssnValidationCode.equals( inputValidationCode.toUpperCase() ) ){
                
    //用戶輸入的值與看到的不一致,拋出異常
                throw new ValidationCodeException( "驗(yàn)證碼輸入錯(cuò)誤!");
            } 
            String username 
    = obtainUsername(request);
            String password 
    = obtainPassword(request);
            System.out.println(
    "testestesetsetestest:"+inputValidationCode);
            
    if (username == null) {
                username 
    = "";
            }

            
    if (password == null) {
                password 
    = "";
            }

            username 
    = username.trim();

            UsernamePasswordAuthenticationToken authRequest 
    = new UsernamePasswordAuthenticationToken(
                    username, password);

            
    // Place the last username attempted into HttpSession for views
            HttpSession session = request.getSession(false);

            
    if (session != null || getAllowSessionCreation()) {
                request.getSession().setAttribute(
                        SPRING_SECURITY_LAST_USERNAME_KEY,
                        TextUtils.escapeEntities(username));
            }

            
    // Allow subclasses to set the "details" property
            setDetails(request, authRequest);

            
    return this.getAuthenticationManager().authenticate(authRequest);
        }
    }

    然后再在這外包下面加一個(gè)類,其實(shí)就是拋出的一個(gè)異常類
    package org.codehaus.groovy.grails.plugins.springsecurity;
    import org.springframework.security.AuthenticationException;
    /**
    *
    */
    public class ValidationCodeException extends AuthenticationException {
        
    public ValidationCodeException(String s) {
            
    super(s);
        }
    }
    這樣就可以了,前臺加上代碼就行了。
    不過,這樣還不算玩,如果重做系統(tǒng)之類的,還得改,因?yàn)楦牡拇a保存是在C盤。這也讓我郁悶啊。這幾天換機(jī)子,機(jī)子壞,改了好幾遍了。
    記得FCKeditor有上傳圖片顯示不能顯示的問題,今天重先發(fā)布工程時(shí),網(wǎng)上下載的fckeditor,沒改源碼也能正常使用了,有點(diǎn)因禍得福的感覺。

    天蒼蒼,野茫茫,風(fēng)吹草底見牛羊

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     

    posts - 80, comments - 24, trackbacks - 0, articles - 32

    Copyright © asdtiang

    asdtiang的博客 PaidMailz
    點(diǎn)擊廣告網(wǎng)賺A(每天4個(gè)廣告,每個(gè)0.0025美元,一個(gè)搜索廣告0.03美元)
    主站蜘蛛池模板: 亚洲中文字幕无码一去台湾 | 久久久高清日本道免费观看| 亚洲人成在线影院| 久久WWW色情成人免费观看| 青青草97国产精品免费观看 | 亚洲一区二区三区在线| 夜色阁亚洲一区二区三区| 久久国产乱子伦精品免费一| 亚洲欧美日韩久久精品| 亚洲AV无码一区二区乱孑伦AS| 好吊妞在线新免费视频| 3344在线看片免费| 黄网站在线播放视频免费观看| 亚洲宅男永久在线| 亚洲国产成人影院播放| 国产精品视频免费| 91成人免费福利网站在线| 亚洲AV香蕉一区区二区三区| 久久精品视频亚洲| 亚洲精品无码日韩国产不卡?V| 美女视频黄的全免费视频网站| 久久国产免费直播| 亚洲AV无码一区二区三区网址 | 亚洲日韩区在线电影| 国产一区二区三区免费视频| 国产四虎免费精品视频| 中文字幕无码一区二区免费| 久久精品国产亚洲av品善| 亚洲国产成人久久综合一区| 日韩亚洲变态另类中文| 国产免费131美女视频| 色se01短视频永久免费| 88xx成人永久免费观看| 99视频免费在线观看| 一级毛片免费播放男男| 亚洲精品无码久久久久久| 亚洲av无码专区在线| 亚洲精品无码久久毛片波多野吉衣| 亚洲熟妇无码八AV在线播放| 亚洲A∨精品一区二区三区| 嫩草视频在线免费观看|