Implementing the URL Interface

You can implement the URL Interface feature by using the sample code in this section:

Adding Hyperlinks to Junos Scope Operations in External Web Applications

You can add hyperlinks to Junos Scope operations in your application by using the following sample code:

<a href='https://hostname:port-number/jtk/ noauth-auth?username=<username>&password=
<password>&redirectLoc=ui/index/looking-glass'> Looking Glass
</a>

This sample code adds a hyperlink to Looking Glass in your application, allowing you to access Looking Glass without logging in using the Junos Scope sever.

Launching Junos Scope Operations in a New Window

You can launch Junos Scope operations in a new window by using the following sample code:

<a href="#"  onclick="launchInNewWindow('ui/index/looking-glass')">Looking-glass</a>
                                    <script language="JavaScript"type="text/javascript">
                                     var Junos ScopeLink= 
"https://<Junos Scope Server>:<Port>/jtk/
noauth-auth?username=<username>&password=<password>&redirectLoc="
                                      function launchInNewWindow(link ) {
                     var newWin = open(Junos ScopeLink + link);
                    return false;
                 }              
 </script>

Launching Junos Scope Operations in a Pop-Up Window

You can launch Junos Scope operations in a new pop-up window by using the following sample code:

<a href="#"  onclick="openInPopUp('ui/index/looking-glass')">Looking-glass</a>
                <script language="JavaScript" type="text/javascript">
                 var Junos ScopeLink = 
"https://<Junos Scope Server>:<Port>/jtk/noauth-auth?username=<username>&password=<password>&redirectLoc="
             function openInPopUp( link ) {
                    var newWin = open(Junos ScopeLink + link, "Junos ScopeURL",              
                   "location=1,status=1,menubar=1,scrollbars=1,resizable=1,height=600,width=700");
                   return false;
                 }               
 </script>

Launching Junos Scope Operations in a Frame

You can launch Junos Scope operations in a frame in the current window by using the following sample code:

<a href="#"  onclick="openInFrame('ui/index/looking-glass')">Looking-glass</a>
               <script language="JavaScript" type="text/javascript">
                   var Junos ScopeLink = 
"https://<Junos Scope Server>:<Port>/jtk/noauth-auth?username=<username>&password=<password>&redirectLoc="
                   function openInFrame( link ) {
                      parent.right.location = Junos ScopeLink + link;                 
                      // replace "right" with the frame name         
                       return false;
                     }                  
        </script>

Note: You cannot launch the Configuration> Current >Edit operation in a frame.

Note: When Junos Scope is launched for the first time, a session is created. Subsequent launches of Junos Scope operations using the URL interface do not require the username and password in the URL until the session expires. However, if you wish to log in using a different user profile, then you will have to log out first. Otherwise, the current login ID and user session are used. Use the following link to logout: https://hostname:port-number/jtk/logout

Concealing the Username and Password in a URL

You can provide URLs to Junos Scope operations in your Web application with the username and password added to the URL. You will be directed to the Junos Scope operation without having to log in using the Junos Scope server login page. (See Figure 20.) However you can choose to conceal the username and password in the URL. (See Figure 21.)

Figure 20: Data Flow with Junos Scope Credentials

Image g016816.gif

Figure 21: Data Flow with Junos Scope Credentials Concealed via HTTP Redirect

Image g016815.gif

To conceal the username and the password in the URL, the HTTP request by the client browser, for the external Web application page with hyperlinks to Junos Scope opertaions should be returned to the client browser with redirect hyperlinks.

You can use the following sample client HTML code to return the HTTP request to the client browser with redirect hyperlinks:

<html>
            <body bgcolor="white">
               <a href='http://<yourServer>:<Port>/redirect?redirectLoc=ui/index/looking-glass'>
Looking Glass</a>
                 <!--
                     replace above <yourServer> with the server name/IP  and <port> with
the port where     the redirect jsp is available.                
                  -->                
             </body>        
       </html>

You can use the sample JSP code below to return the page that will redirect the client browser to Junos Scope, with credentials:

<html>            
          <body bgcolor="white" onLoad="goToJunos Scope();">
             Redirecting to Junos Scope.             </body>    
          <Script language="javascript">               
           var logoutRequired= <%=request.getParameter("logoutRequired")%>;
                function goToJunos Scope() {        
                  if( logoutRequired ) {     
    document.all.logoutFrame.src="<%=urlInterface.RedirectHelper.getJunos ScopeServer()%>"+"/jtk/logout";
                }      
                var server = "https://Junos ScopeServer:8443/";
       var userName = 'username';      
       var password = 'password';
      var redirectLoc = '<%=request.getParameter("redirectLoc")%>';
      var fullURL = server+"/jtk/noauth-auth?username="+userName+"&password;="+password+"&redirectLoc;="+redirectLoc;
      window.location = fullURL;
      return false;
     }      
          </Script>
      </html>