⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialogsecuritywrapper.java

📁 First of all, the Applet-phone is a SIP User-Agent with audio and text messaging capabilities. But
💻 JAVA
字号:
/* * SecurityWrapperTest.java * * Created on June 17, 2003, 9:09 AM */package gov.nist.security.bcs.wrapper;import java.util.*;import javax.sip.message.*;import javax.sip.header.*;/** * Class that will be called from the bytecode. Each method will do a particular check * @author  DERUELLE Jean */public class DialogSecurityWrapper {     /**list keeping all the active dialogs of the service*/    Hashtable dialogList=null;    /** Creates a new instance of SecurityWrapper */    public DialogSecurityWrapper() {        dialogList=new Hashtable();    }            /** A method to check if the service tries to fork too much.     * @param request - the request from which the service create the dialog     */        public void checkDialog(Request request){        //Get the caller address from the request        String caller=(request.getHeader(FromHeader.NAME)).toString();        int indexOpeningParenthesisCaller=caller.indexOf("<");        int indexClosingParenthesisCaller=caller.indexOf(">");         caller=caller.substring(indexOpeningParenthesisCaller+1,indexClosingParenthesisCaller);                       caller=caller.substring("sip:".length());                //Get the callee address from the request        //String callee=(request.getHeader(ToHeader.NAME)).toString();        javax.sip.address.URI calleeURI=request.getRequestURI();                String callee=calleeURI.toString();        //int indexOpeningParenthesisCallee=callee.indexOf("<");        //int indexClosingParenthesisCallee=callee.indexOf(">");         //callee=callee.substring(indexOpeningParenthesisCallee+1,indexClosingParenthesisCallee);               callee=callee.substring("sip:".length());                //System.out.println(callee);           //System.out.println(caller);                   Object correspondingCallee=dialogList.get(caller);         ForkAssociation fork=(ForkAssociation)correspondingCallee;        if(correspondingCallee==null){                        fork=new ForkAssociation(callee);            dialogList.put(caller,fork);        }        else{            if(!fork.findCallee(callee))                fork.addFork(callee);        }        String numberOfForking=Integer.toString(fork.getNumberOfFork());                try{            java.security.AccessControlContext context=null;            SecurityManager securityManager=System.getSecurityManager();            if (securityManager != null)                 context = (java.security.AccessControlContext) securityManager.getSecurityContext();                      gov.nist.security.permissions.SipDialogPermission sipDialogPermission=new gov.nist.security.permissions.SipDialogPermission(numberOfForking,"create");            //System.out.println("Checking in your group policy file for the following DIALOG PERMISSION : "+ sipDialogPermission);            context.checkPermission(sipDialogPermission);              //System.out.println("Dialog created");                       }        catch(Exception e){            //e.printStackTrace();            System.out.println("You have already created "+ numberOfForking + " dialog(s), you cannot do more.");                           System.exit(1);        }        //return true;            }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -