盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

在jsp中作HTTP认证的方法

时间:2024/10/26作者:未知来源:盾怪网教程人气:

[摘要]c==''\t'') skip=true; ...
c==''\t'')
                                skip=true;
                                else
                                //could throw an exception here? it''s input we don''t understand.
                                ;
                        }
                        //once the array has boiled convert the bytes back into chars
                        if(!skip&&++j==4)
                        {
                                //shift the 6 bit bytes into a single 4 octet word
                                int res=(unenc[0]<<18)+(unenc[1]<<12)+(unenc[2]<<6)+unenc[3];
                                byte c;
                                int k=16;
                                //shift each octet down to read it as char and add to StringBuffer
                                while(k>=0)
                                {
                                        c=(byte)(res>>k);
                                        if ( c>0 )
                                        sb.append((char)c);
                                        k-=8;
                                }
                                //reset j and the unencode buffer
                                j=0;
                                unenc[0]=0;unenc[1]=0;unenc[2]=0;unenc[3]=0;
                        }
                }
                return sb.toString();
        }
        
        /** encode plaintext data to a base 64 string
          * @param plain the text to convert. If plain is longer than 76 characters this method
          *             returns null (see RFC2045).
          * @return the encoded text (or null if string was longer than 76 chars).
        */
        public static String encode(String plain)
        {
                if(plain.length()>76)
                return null;
                int maxturns;
                StringBuffer sb=new StringBuffer();
                //the encode buffer
                byte[] enc=new byte[3];
                boolean end=false;
                for(int i=0,j=0;!end;i++)
                {
                        char _ch=plain.charAt(i);
                        if(i==plain.length()-1)
                        end=true;
                        enc[j++]=(byte)plain.charAt(i);
                        if(j==3

关键词:在jsp中作HTTP认证的办法




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版