User Tools

Site Tools


web-integration:java-example

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
web-integration:java-example [2019/08/15 06:09]
740803864 [Web Application Configuration File]
web-integration:java-example [2019/08/15 06:49]
740803864 [Web Application Configuration File]
Line 157: Line 157:
 Some notes to source code: Some notes to source code:
   * way to get ''wsUrl'' is described in [[web-integration:java-example#web_application_configuration_file|Web Application Configuration File]] chapter   * way to get ''wsUrl'' is described in [[web-integration:java-example#web_application_configuration_file|Web Application Configuration File]] chapter
-==== Web Application Configuration File ==== + 
-This file is required by Servlet API. This file provides to application ''wsUrl'' configuration value:+===== Web Integration ===== 
 + 
 +==== Start Page ==== 
 + 
 +Servlets described earlier are used in ''index.jsp'' page: 
 + 
 +<code javascript> 
 +<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> 
 + 
 +<head> 
 +<script type="text/javascript" src="js/jquery.min.js"></script> 
 +<script type="text/javascript" src="js/aducid-api.js"></script> 
 + 
 +<script type="text/javascript"> 
 + var aducid = new ADUCID(); 
 + $(document).ready(function() { 
 + aducid.setAuthentication(); 
 + 
 + aducid.setStartOperationUrl("open"); 
 + aducid.setResultOperationUrl("openCheck"); 
 + aducid.setProxyUrl("proxy"); 
 + 
 + aducid.processResult = function(result) { 
 + if (result.status == "OK") { 
 + alert("Success - status: " + result.status); 
 + location.href = result.redirect; 
 + } else { 
 + alert("Error - status: " + result.status + ", message: " + result.data.message); 
 + location.href = result.redirect; 
 +
 +
 + 
 + // handle PEIG not installed error 
 + aducid.showPeigError = function() { 
 + alert("PEIG not found or other error"); 
 +
 + 
 + // handle communication or other error 
 + aducid.handleError = function(e) { 
 + alert(e.data.message); 
 +
 + 
 + aducid.showQRHint = function(param) { 
 + $('#qr-code-hint').html("Scan QR or click button to authenticate"); 
 +
 + 
 + aducid.showRunningHint = function(param) { 
 + $('#qr-code-hint').html("Operation is running"); 
 + }; 
 +  
 + aducid.startAnimation = function() { 
 +            $("#qr-code").attr("src", "img/running.gif"); 
 +        }; 
 + 
 +        aducid.stopRunningAnimation = function() { 
 + $("#qr-code").hide(); 
 + }; 
 + 
 + // GUI mapping 
 + aducid.setButton($("#main-button")); 
 + aducid.setQrCode($("#qr-code")); 
 + aducid.setQrHint($("#qr-code-hint")); 
 + 
 + // start 
 + aducid.init(); 
 + }); 
 +</script> 
 +</head> 
 +<body> 
 + 
 + <h1>LOGIN PAGE</h1> 
 + <div> 
 + <button id="main-button">Login using local PEIG</button> 
 + </div> 
 + <img id="qr-code" alt=""></img> 
 + <div id="qr-code-hint"></div> 
 + 
 +</body> 
 +</html> 
 +</code> 
 + 
 +==== Result Page ==== 
 + 
 +After successful authentication, ''UDI'' value is printed at ''result.jsp'' page: 
 + 
 +<code javascript> 
 +<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> 
 + 
 +<head> 
 +</head> 
 +<body> 
 + 
 + <h1>SECURE PAGE</h1> 
 + UDI: ${result.userDatabaseIndex} 
 + <br></br> 
 + <a href="index.jsp">Try again</a> 
 + 
 +</body> 
 +</html> 
 +</code> 
 +===== Web Application Configuration File ===== 
 +This file is required by Servlet API. File provides ''wsUrl'' configuration value:
  
 <code xml> <code xml>
Line 181: Line 282:
  
 Value ''${ws.url}'' is replaced at application building phase. See [[web-integration:java-example#building_application|Building Application]] chapter. Value ''${ws.url}'' is replaced at application building phase. See [[web-integration:java-example#building_application|Building Application]] chapter.
 +
 +===== Maven Configuration File =====
 +
 +Maven configuration file contents definition of plugin to generate WS classes and instruction to filter ''${ws.url}'' value:
 +
 +<code xml>
 +<?xml version="1.0" encoding="UTF-8"?>
 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 +    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 +    <modelVersion>4.0.0</modelVersion>
 +    <groupId>com.aducid</groupId>
 +    <version>1.DEV-SNAPSHOT</version>
 +    <packaging>war</packaging>
 +    <artifactId>example_ws</artifactId>
 +    <name>demo: example ws</name>
 +    <build>
 +        <finalName>example-ws</finalName>
 +        <plugins>
 +            <plugin>
 +                <groupId>org.apache.maven.plugins</groupId>
 +                <artifactId>maven-compiler-plugin</artifactId>
 +                <version>3.8.1</version>
 +                <configuration>
 +                    <source>1.8</source>
 +                    <target>1.8</target>
 +                    <encoding>UTF-8</encoding>
 +                    <debug>true</debug>
 +                    <showWarnings>true</showWarnings>
 +                </configuration>
 +            </plugin>
 +            <plugin>
 +                <groupId>org.jvnet.jax-ws-commons</groupId>
 +                <artifactId>jaxws-maven-plugin</artifactId>
 +                <version>2.3</version>
 +                <executions>
 +                    <execution>
 +                        <id>client</id>
 +                        <configuration>
 +                            <wsdlUrls>
 +                                <wsdlUrl>${ws.url}/aducid-client-api-ws/wsa?wsdl</wsdlUrl>
 +                            </wsdlUrls>
 +                            <vmArgs>
 +                                <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
 +                            </vmArgs>
 +                            <encoding>UTF-8</encoding>
 +                        </configuration>
 +                        <goals>
 +                            <goal>wsimport</goal>
 +                        </goals>
 +                    </execution>
 +                </executions>
 +            </plugin>
 +            <plugin>
 +                <groupId>org.apache.maven.plugins</groupId>
 +                <artifactId>maven-war-plugin</artifactId>
 +                <version>3.2.2</version>
 +                <configuration>
 +                    <webResources>
 +                        <resource>
 +                            <filtering>true</filtering>
 +                            <directory>src/main/webapp</directory>
 +                            <includes>
 +                                <include>WEB-INF/web.xml</include>
 +                            </includes>
 +                        </resource>
 +                        <resource>
 +                            <directory>${project.build.sourceDirectory}</directory>
 +                            <targetPath>sources</targetPath>
 +                        </resource>
 +                    </webResources>
 +                </configuration>
 +            </plugin>
 +        </plugins>
 +    </build>
 +    <dependencies>
 +        <dependency>
 +            <groupId>javax.servlet</groupId>
 +            <artifactId>javax.servlet-api</artifactId>
 +            <version>3.0.1</version>
 +            <scope>provided</scope>
 +        </dependency>
 +    </dependencies>
 +</project>
 +</code>
 +===== Building Application =====
 +
 +There is prepared batch file ''build.bat'' to build application. It is neccessary to define right ''ws.url'' value as an address to AIM server:
 +
 +<code>
 +set MAVEN_OPTS="-Xmx512m"
 +mvn -Dws.url=https://myaim.aducid.com -Dfile.encoding=UTF-8 clean install
 +</code>
  
web-integration/java-example.txt · Last modified: 2020/02/29 10:52 by mpospisek