BLOGS

ServiceNow connector deployment guide 1.0.0.0

Java 8 – Functional Programming And Much More

Java 8 Features
Oracle released a new version of Java as Java 8 in March 18, 2014. It was a revolutionary release of the Java for software development platform. It includes various upgrades to the Java programming, JVM, Tools and libraries.
Java 8 Programming Language Enhancements
Java 8 provides following features for Java Programming:
• Lambda expressions,
• Functional interfaces,
• Method references,
• Stream API,
• Default methods,
• Static methods in interface,
• Date/Time API
• ForEach() method,
• Base64 Encode Decode,
• Parallel array sorting,
• Nashorn JavaScript Engine,
• Optional class,
• StringJoiner class
• JDBC Enhancements etc.

 Java Lambda Expressions
1. What is a lambda expression in Java?
Lambda expression is a new and important feature of Java which was included in Java SE 8.
In programming, a Lambda expression (or function) is just an anonymous function, i.e., a function with no name and without being bounded to an identifier.
In other words, lambda expressions are nameless functions given as constant values, and written exactly in the place where it’s needed, typically as a parameter to some other function.
It provides a clear and concise way to represent one method interface using an expression. It is very useful in the collection library. It helps to iterate, filter and extract data from the collection.
The Lambda expression is used to provide the implementation of an interface which has a functional interface. It saves a lot of code. In case of lambda expression, we don’t need to define the method again for providing the implementation. Here, we just write the implementation code.

1.1 Why use Lambda Expression
1. To provide the implementation of Functional interface.
2. Less coding.

1.2 Java Lambda Expression Syntax
1. (argument-list) -> {body}
Java lambda expression is consisted of three components.
1) Argument-list: It can be empty or non-empty as well.
2) Arrow-token: It is used to link arguments-list and body of expression.
3) Body: It contains expressions and statements for lambda expression.

A typical lambda expression syntax will be like this:
(x, y) -> x + y // This function takes two parameters and return their sum.
Now based on type of x and y, method may be used in multiple places. Parameters can match to int, or Integer or simply String also. Based on context, it will either add two integers or concat two strings.
Syntax:
The other possible syntaxes of a lambda expression are:
1. (parameters) -> expression
2. (parameters) -> { statements; }
3. () -> expression

1.3 Features of Lambda Expressions
Let’s identify some features of lambda expression:
1. A lambda expression can have zero, one or more parameters.
2. The type of the parameters can be explicitly declared or it can be inferred from the context.
3. Multiple parameters are enclosed in mandatory parentheses and separated by commas. Empty parentheses are used to represent an empty set of parameters.
4. When there is a single parameter, if its type is inferred, it is not mandatory to use parentheses. e.g. a -> return a*a.
5. The body of the lambda expressions can contain zero, one or more statements.
6. If body of lambda expression has single statement curly brackets are not mandatory and the return type of the anonymous function is the same as that of the body expression. When there is more than one statement in body than these must be enclosed in curly brackets.

1.4 Java Lambda Expression Examples:

Example 1: Java Lambda Expression with no parameter
interface Sayable
{
public String say();
}
public class LambdaExpressionExample
{
public static void main(String[] args)
{
Sayable s = () -> { return “Hello”; };
System.out.println(s.say());
}
}
Output :- Hello
Example 2: Java Lambda Expression with single parameter
interface MyFunctionalInterface
{
public int incrementByFive(int a);
}
public class LambdaExpressionExample
{
public static void main(String args[])
{
MyFunctionalInterface f = (num) -> num+5;
System.out.println(f.incrementByFive(22));
}
}
Output :- 27
Example 3: Java Lambda Expression with Multiple Parameters
interface Addable
{
int add(int a,int b);
}

public class LambdaExpressionExample
{
public static void main(String[] args)
{

Addable a = (x,y)->(x+y);
System.out.println(a.add(10,20));

}
}
Output :- 30

Example 4: Iterating collections using foreach loop
import java.util.ArrayList;
import java.util.List;

public class Demo
{
public static void main(String[] args)
{
List list=new ArrayList();
list.add(“Rick”);
list.add(“Negan”);
list.add(“Daryl”);
list.add(“Glenn”);
list.add(“Carl”);
list.forEach(

(names)->System.out.println(names)
);
}
}

Before going deep in relation between lambda expressions and java programming, you must know about functional interfaces as well. It is just too important.

 Java Functional Interfaces
An Interface that contains exactly one abstract method is known as functional interface. It can have any number of default, static methods but can contain only one abstract method. It can also declare methods of object class.
Functional Interface is also known as Single Abstract Method Interfaces or SAM Interfaces. It is a new feature in Java, which helps to achieve functional programming approach.
Java 8, enforces the rule of single responsibility by marking these interfaces with a new annotation i.e. @FunctionalInterface.

Example 1: Creating our own Functional Interface
interface SampleInterface
{
void msg(String msg);
}
public class Test implements SampleInterface
{
public void msg(String msg)
{
System.out.println(msg);
}
public static void main(String[] args) {
Test test = new Test();
test.msg(“Hello World”);
}
}

Example 2: Using predefined functional interface
Java provides predefined functional interfaces to deal with functional programming by using lambda and method references.
Predicate :-
Predicate is a functional interface which represents a predicate (boolean-valued function) of one argument. It is defined in the java.util.function package and contains test() a functional method.
import java.util.function.Predicate;
public class PredicateInterfaceExample
{
public static void main(String[] args)
{
Predicate pr = a -> (a > 18); // Creating predicate
System.out.println(pr.test(10)); // Calling Predicate method
}
}

Function:-
It is a functional interface. It is used to refer method by specifying type of parameter. It returns a result back to the referred function.

import java.util.function.Function;
public class FunctionInterfaceExample {

public static void main(String[] args)
{
Function<Integer, Integer> function = i ->i*i;
// Function interface referring to a method

System.out.println(function.apply(4)); // Calling Function interface method
}
}

Consumer :- It is a functional interface defined in java.util.function package. It contains an abstract accept() method.
The Consumer Interface accepts a single argument and does not return any result.
import java.util.function.Consumer;

public class Demo
{

public static void main(String[] args)
{

Consumer consumer1 = str -> System.out.println(str);
// Referring method to String type Consumer interface

consumer1.accept(“John”); // Calling Consumer method

}

 Java Method References
Java provides a new feature called method reference in Java 8. Method reference is used to refer method of functional interface. It is compact and easy form of lambda expression. Each time when you are using lambda expression to just referring a method, we can replace our lambda expression with method reference.

Types of Method References
There are following types of method references in java:
1. Reference to a static method.
2. Reference to an instance method.
3. Reference to a constructor.

1) Reference to a Static Method
We can refer to static method defined in the class. Following is the syntax and example which describe the process of referring static method in Java.
Syntax:
ContainingClass::staticMethodName
Example:
In the following example, we have defined a functional interface and referring a static method to it’s functional method add().
import java.util.function.BiFunction;

class Arithmetic
{
public static int add(int a, int b)
{
return a+b;
}
}
public class MethodReference
{
public static void main(String[] args)
{
BiFunction<Integer, Integer, Integer> adder = Arithmetic::add;
int result = adder.apply(10, 20);
System.out.println(result);
}
}
2) Reference to an Instance Method
like static methods, we can refer instance methods also. In the following example, we are describing the process of referring the instance method.
Syntax:
containingObject::instanceMethodName

Example:
import java.util.function.BiFunction;

class Arithmetic
{
public int add(int a, int b)
{
return a+b;
}
}
public class InstanceMethodReference
{
public static void main(String[] args)
{
BiFunction<Integer, Integer, Integer>adder = new Arithmetic()::add;
int result = adder.apply(10, 20);
System.out.println(result);
}
}

3) Reference to a Constructor
We can refer a constructor by using the new keyword. Here, we are referring constructor with the help of functional interface.
Syntax:
ClassName::new

Example:
interface Messageable
{
Message getMessage(String msg);
}
class Message
{
Message(String msg)
{
System.out.print(msg);
}

}
public class Demo
{
public static void main(String[] args)
{
Messageable hello = Message::new;
hello.getMessage(“Hello”);
}
}

 Java Stream API
Java provides a new additional package in Java 8 called java.util.stream. This package consists of classes, interfaces and enum to allows functional-style operations on the elements. We can use stream by importing java.util.stream package.
By using streams we can perform various aggregate operations on the data returned from collections, arrays, Input/Output operations.
Stream provides following features:
• Stream does not store elements. It simply conveys elements from a source such as a data structure, an array, or an I/O channel, through a pipeline of computational operations.
• Stream is functional in nature. Operations performed on a stream does not modify it’s source. For example, filtering a Stream obtained from a collection produces a new Stream without the filtered elements, rather than removing elements from the source collection.
• The elements of a stream are only visited once during the life of a stream. Like an Iterator, a new stream must be generated to revisit the same elements of the source.

Java Stream Example
To understand how stream works, lets take an example without using stream and then we will see the same example with streams.
Finding certain strings without using Stream
import java.util.ArrayList;
import java.util.List;
public class Example{
public static void main(String[] args) {
List names = new ArrayList();
names.add(“Ajeet”);
names.add(“Negan”);
names.add(“Aditya”);
names.add(“Steve”);
int count = 0;
for (String str : names) {
if (str.length() < 6)
count++;
}
System.out.println(“There are “+count+” strings with length less than 6″);
}
}

Output:
There are 3 strings with length less than 6

Same example using Stream
import java.util.ArrayList;
import java.util.List;
public class Example
{
public static void main(String[] args)
{
List names = new ArrayList();
names.add(“Ajeet”);
names.add(“Negan”);
names.add(“Aditya”);
names.add(“Steve”);

//Using Stream and Lambda expression
long count = names.stream().filter(str->str.length()<6).count();
System.out.println(“There are “+count+” strings with length less than 6″);

}
}
Output:
There are 3 strings with length less than 6

How to work with Stream in Java
As we have seen in the above example, the working of stream can be explained in three stages:
1. Create a stream
2. Perform intermediate operations on the initial stream to transform it into another stream and so on on further intermediate operations. In the above example, the filter() operation is intermediate operation, there can be more than one intermediate operations.
3. Perform terminal operation on the final stream to get the result. In the above example, the count() operation is terminal operation.

Examples of Intermediate operartions
Intermediate operations return the stream itself
1. Stream.filter()
Filter accepts a predicate to filter all elements of the stream. This operation is intermediate which enables us to call another stream operation (e.g. forEach) on the result.
public class Demo
{
public static void main(String[] args)
{
List memberNames = new ArrayList<>();
memberNames.add(“Amitabh”);
memberNames.add(“Shekhar”);
memberNames.add(“Aman”);
memberNames.add(“Rahul”);
memberNames.add(“Shahrukh”);
memberNames.add(“Salman”);
memberNames.add(“Yana”);
memberNames.add(“Lokesh”);

memberNames.stream().filter((s) -> s.startsWith(“A”))
.forEach(System.out::println);
}
}
Output:-
Amitabh
Aman

2. Stream.map()
The intermediate operation map converts each element into another object via the given function. The following example converts each string into an upper-cased string. But you can also use map to transform each object into another type.
For above same list
memberNames.stream().filter((s) -> s.startsWith(“A”))
.map(String::toUpperCase)
.forEach(System.out::println);

Output:
AMITABH
AMAN

3. Stream.sorted()
Sorted is an intermediate operation which returns a sorted view of the stream. The elements are sorted in natural order unless you pass a custom Comparator.
memberNames.stream().sorted()
.map(String::toUpperCase)
.forEach(System.out::println);
Output:

AMAN
AMITABH
LOKESH
RAHUL
SALMAN
SHAHRUKH
SHEKHAR
YANA

Terminal Operartions:
Terminal operations return a result of a certain type instead of again a Stream.

4. Stream.forEach()
This method helps in iterating over all elements of a stream and perform some operation on each of them. The operation is passed as lambda expression parameter.
memberNames.forEach(System.out::println);

5. Stream.collect()
collect() method used to recieve elements from a sream and store them in a collection and metioned in parameter funcion.
List memNamesInUppercase = memberNames.stream().sorted()
.map(String::toUpperCase)
.collect(Collectors.toList());

System.out.print(memNamesInUppercase);

Outpout: [AMAN, AMITABH, LOKESH, RAHUL, SALMAN, SHAHRUKH, SHEKHAR, YANA]
6. Stream.count()
Count is a terminal operation returning the number of elements in the stream as a long.
long totalMatched = memberNames.stream()
.filter((s) -> s.startsWith(“A”))
.count();

System.out.println(totalMatched);

Output: 2

 Java Default Methods
Java provides a facility to create default methods inside the interface. Methods which are defined inside the interface and tagged with default are known as default methods. These methods are non-abstract methods.
Default method Example:
In the following example, Sayable is a functional interface that contains a default and an abstract method. The concept of default method is used to define a method with default implementation. We can override default method also to provide more specific implementation for the method.

Example:-

interface Sayable
{
// Default method
default void say()
{
System.out.println(“Hello, this is default method”);
}

}
public class DefaultMethods implements Sayable{

public static void main(String[] args)
{
DefaultMethods dm = new DefaultMethods();

dm.say(); // calling default method

}
}

 Static Methods Interface
We can also define static methods inside the interface. Static methods are used to define utility methods. The following example explain, how to implement static method in interface.
interface Printable
{
static void print(String msg)
{
System.out.println(msg);
}
}
public class DefaultMethods implements Printable
{

public static void main(String[] args)
{
DefaultMethods dm = new DefaultMethods();

Printable.print(“Helloooo…”); // calling static method
}
}

 Java 8 – New Date/Time API

With Java 8, a new Date-Time API is introduced to cover the following drawbacks of old date-time API.
• Not thread safe − java.util.Date is not thread safe, thus developers have to deal with concurrency issue while using date. The new date-time API is immutable and does not have setter methods.
• Poor design − Default Date starts from 1900, month starts from 1, and day starts from 0, so no uniformity. The old API had less direct methods for date operations. The new API provides numerous utility methods for such operations.
• Difficult time zone handling − Developers had to write a lot of code to deal with timezone issues. The new API has been developed keeping domain-specific design in mind.
Java 8 introduces a new date-time API under the package java.time. Following are some of the important classes introduced in java.time package.
• Local − Simplified date-time API with no complexity of timezone handling.
• Zoned − Specialized date-time API to deal with various timezones.

1. Local Date-Time API
LocalDate/LocalTime and LocalDateTime classes simplify the development where timezones are not required.

The new classes intended to replace Date class are LocalDate, LocalTime and LocalDateTime
LocalDate
The LocalDate class represents a date. There is no representation of a time or time-zone.
LocalDate localDate = LocalDate.now();
System.out.println(localDate.toString()); //2013-05-15
System.out.println(localDate.getDayOfWeek().toString()); //WEDNESDAY
System.out.println(localDate.getDayOfMonth()); //15
System.out.println(localDate.getDayOfYear()); //135
System.out.println(localDate.isLeapYear()); //false
System.out.println(localDate.plusDays(12).toString()); //2013-05-27

LocalTime
The LocalTime class represents a time. There is no representation of a date or time-zone.

LocalTime localTime = LocalTime.of(12, 20);
System.out.println(localTime.toString()); //12:20
System.out.println(localTime.getHour()); //12
System.out.println(localTime.getMinute()); //20
System.out.println(localTime.getSecond()); //0
System.out.println(localTime.MIDNIGHT); //00:00
System.out.println(localTime.NOON); //12:00

LocalDateTime
The LocalDateTime class represents a date-time. There is no representation of a time-zone.
LocalDateTime localDateTime = LocalDateTime.now();
System.out.println(localDateTime.toString()); //2013-05-15T10:01:14.911
System.out.println(localDateTime.getDayOfMonth()); //15
System.out.println(localDateTime.getHour()); //10
System.out.println(localDateTime.getNano()); //911000000

2. Zoned Date-Time API
Zoned date-time API is to be used when time zone is to be considered.
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class DateExample
{
public static void main(String[] args)
{
DateExample dateExample = new DateExample ();
dateExample.testZonedDateTime();
}

public void testZonedDateTime() {

ZonedDateTime date1 = ZonedDateTime.parse(“2018-11-12T10:15:30+05:30[Asia/Karachi]”);
System.out.println(“date1: ” + date1);

ZoneId id = ZoneId.of(“Europe/Paris”);
System.out.println(“ZoneId: ” + id);

ZoneId currentZone = ZoneId.systemDefault();
System.out.println(“CurrentZone: ” + currentZone);
}
}
 Java forEach()
Java provides a new method forEach() to iterate the elements. It is defined in Iterable and Stream interface. It is a default method defined in the Iterable interface. Collection classes which extends Iterable interface can use forEach loop to iterate elements.
Example 1 – forEach to iterate a List
import java.util.ArrayList;
import java.util.List;
public class ForEachExample
{
public static void main(String[] args)
{
List gamesList = new ArrayList();
gamesList.add(“Football”);
gamesList.add(“Cricket”);
gamesList.add(“Chess”);
gamesList.add(“Hocky”);

gamesList.forEach(games -> System.out.println(games));

}
}

Example 2 – forEach to iterate a Stream
import java.util.List;
import java.util.ArrayList;

public class Example
{
public static void main(String[] args)
{
List names = new ArrayList();
names.add(“Maggie”);
names.add(“Michonne”);
names.add(“Rick”);
names.add(“Merle”);
names.add(“Governor”);
names.stream()
.filter(f->f.startsWith(“M”))
.forEach(System.out::println);
}
}

 Java Base64 Encode and Decode
Java provides a class Base64 to deal with encryption. We can encrypt and decrypt your data by using provided methods. We need to import java.util.Base64 in our source file to use its methods.
This class provides three different encoders and decoders to encrypt information at each level. We can use these methods at the following levels.
Basic Encoding and Decoding
It uses the Base64 alphabet specified by Java in RFC 4648 and RFC 2045 for encoding and decoding operations. The encoder does not add any line separator character. The decoder rejects data that contains characters outside the base64 alphabet.
1) Encoding String to base64:
import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class Demo
{
public static void main(String[] args)
{

Base64.Encoder encoder = Base64.getEncoder();
String normalString = “VilMinds”;
String encodedString = encoder.encodeToString(normalString.getBytes(StandardCharsets.UTF_8) );
System.out.println(encodedString);
}
}

2) Decoding a base64 encoded String :
import java.util.Base64;

public class Demo
{

public static void main(String[] args)
{
String encodedString = “VmlsTWluZHM=”;
Base64.Decoder decoder = Base64.getDecoder();
byte[] decodedByteArray = decoder.decode(encodedString);

System.out.println(new String(decodedByteArray));

}
}

Output : VilMinds
 Java Parallel Array Sorting
Java provides a new additional feature in Array class which is used to sort array elements parallel.New methods has added to java.util.Arrays package that use the JSR 166 Fork/Join parallelism common pool to provide sorting of arrays in parallel.The methods are called parallelSort() and are overloaded for all the primitive data types and Comparable objects.
Advantage of Parallel Sort Over Simple Sort:
The parallelSort() method uses the concept of multithreading which makes it much faster compared to the normal sort when there are lot of elements.

Example:-

import java.util.Arrays;

public class ParallelArraySorting
{
public static void main(String[] args)
{
int[] arr = {5,8,1,0,6,9};

for (int i : arr)
{
System.out.print(i+” “);
}

Arrays.parallelSort(arr);

System.out.println(“\nArray elements after sorting”);
for (int i : arr)
{
System.out.print(i+” “);
}
}
}

Output:-
5 8 1 0 6 9
Array elements after sorting
0 1 5 6 8 9

 Nashorn JavaScript Engine
Nashorn is a JavaScript engine. It is used to execute JavaScript code dynamically at JVM (Java Virtual Machine). Java provides a command-line tool jjs which is used to execute JavaScript code.
You can execute JavaScript code by using jjs command-line tool and by embedding into Java source code.
Example: Executing by Using Terminal
Following is the step by step process to execute JavaScript code at the JVM.
1) Create a file hello.js.
2) Write and save the following code into the file.
var hello = function(){
print(“Hello Nashorn”);
};
hello();
3) Open terminal
4) Write command jjs hello.js and press enter.
After executing command, you will see the below output.
Output:
Hello Nashorn

Example: Executing JavaScript file in Java Code
You can execute JavaScript file directly from your Java file. In the following code, we are reading a file hello.js with the help of FileReader class.
import javax.script.*;
import java.io.*;

public class Demo
{
public static void main(String[] args) throws Exception
{
ScriptEngine ee = new ScriptEngineManager().getEngineByName(“Nashorn”);
ee.eval(new FileReader(“js/hello.js”));
}
}

 Java Optional Class
Java introduced a new class Optional in jdk8. It is a public final class and used to deal with NullPointerException in Java application. You must import java.util package to use this class. It provides methods which are used to check the presence of value for particular variable.
Example :-
import java.util.Optional;

public class Demo
{
public static void main(String[] args)
{
String[] str = new String[10];
Optional checkNull = Optional.ofNullable(str[5]);
if(checkNull.isPresent())
{
String lowercaseString = str[5].toLowerCase();
System.out.print(lowercaseString);
}
Else
{
System.out.println(“string value is not present”);
}

}
}

 Java StringJoiner
Java added a new final class StringJoiner in java.util package. It is used to construct a sequence of characters separated by a delimiter. Now, we can create string by passing delimiters like comma(,), hyphen(-) etc. You can also pass prefix and suffix to the char sequence.

import java.util.StringJoiner;

public class StringJoinerExample
{
public static void main(String[] args)
{
StringJoiner joinNames = new StringJoiner(“,”); // passing comma(,) as delimiter

// Adding values to StringJoiner
joinNames.add(“Rahul”);
joinNames.add(“Raju”);
joinNames.add(“Peter”);
joinNames.add(“Raheem”);

System.out.println(joinNames);
}
}

Output : Rahul,Raju,Peter,Raheem

 Java 8 JDBC Improvements
In Java 8, Java made two major changes in JDBC API.
1) The JDBC-ODBC Bridge has been removed.
Oracle does not support the JDBC-ODBC Bridge. Oracle recommends that you use JDBC drivers provided by the vendor of your database instead of the JDBC-ODBC Bridge.
2) Added some new features in JDBC 4.2.
Java JDBC 4.2 introduces the following features:
• Addition of REF_CURSOR support.
• Addition of java.sql.DriverAction Interface
• Addition of security check on deregisterDriver Method in DriverManager Class
• Addition of the java.sql.SQLType Interface
• Addition of the java.sql.JDBCType Enum
• Add Support for large update counts
• Changes to the existing interfaces
• Rowset 1.2: Lists the enhancements for JDBC RowSet.

ServiceNow connector deployment guide 1.0.0.0

ServiceNow LDAP Integration

ServiceNow LDAP Integration:

Step 1: Login using admin account and Search For LDAP in search filter left side of panel and Click on Create new Server.

Step 2:

  • Select Type of LDAP server as Active Directory
  • Give any server Name (eg. Company_name LDAP)
  • Give Your Server URL of Your Active Directory.
  • Click on Submit

Step 3:

-In Next screen it will ask you to enter Login Distinguish Name (DN) and Password ( LDAP service account credentials ).

– Starting search directory: is the path in where you are going to search users .

– Once done with all these fields click on test connection to check it is connecting successfully or not. (It will show message at top)

 

  • Once Connection is Successful the right click on top and save it.

Step 4:

Next Step is to set LDAP OU Definitions for Users and Groups:

For that scroll down on same screen you will see the section for LDAP OU Definitions having pre-define definitions for user and groups.

  • Click on Users
  • This below screen will be open in that RDN and Query field you have to keep it empty and only you have to give filter to isolate users here I am giving uid=* it will take all users from user id.

After that test connection for OU definition:

  • You can click on brows to see records:

All records which are present in AD are fetched here

 

 

Step 5:

After Setting LDAP OU Definitions next is Data Sources

  • In data sources we load our AD records in ldap table and transfer that records in particular Service now tables.

For this configuration scroll down on same OU definition screen:

Click on this generated Data Source then following screen will appear.

  • You have to give any name to Import set table name field in this table we are first going to load our AD records. ( eg. Import set table name = Mytable_ldap_import)it will automatically generate name by prefix “u_ Mytable_ldap_import”

  • Then by clicking test load 20 records you can test records are loading or not. You will get this success message and how much records are inserted or updated and error logs also.

  • Click on Return to data source to get back to our configurations on data sources. And click on load all records it will load all AD records in our ldap table which we have created (u_Mytable_ldap_import) we have create above.

 

  • You will get this import success message it means All the records from AD are loaded in our ldap table.

  • You can check those records are inserted or not in table . On top left side there is search filter put your table name (eg.u_ Mytable_ldap_import.list)

 

Step 6:

Next step is to create transform map to navigate that again navigate to data sources select our data source and there is section Transforms click on New

  • Transform Maps are for transferring data from Source table to destination table.
  • Here source table is our ldap table which we have created and stored records from AD and target table is ServiceNow table in which we want to store our data.

 

 

  • Fields we have to fill:
    • Name: give any name for you transform map.
    • Source table: is automatically selected.
    • Enforce mandatory: options like which fields you want to transfer All fields, only mapped. You can select as per requirement.
    • On right side there is field target table: here you have to select target table in which you are going to transfer records as we are transferring users then it must go in users table of ServiceNow so select sys_users as target table.

 

  • If you are selecting only mapped Fields option in Enforce Mandatory Fields the you have to map fields of source table with target table by clicking Mapping Assist.
  • You will see following screen left side source table fields and right side target table fields.
  • You have to just add fields from source table and target table from which to field data should be transfer.(eg. Here I am Mapping 3 fields as shown in following screenshot)
  • After mapping click on save.
  • You will be able to see those fields .

 

Step 7:

Next step is To transform Source table records in target table(ServiceNow users table). For that click on transform  link is available on table transform map screen.

  • After that following screen will appear. You have to just click on transform

 

 

-It Will Show success Message for transformation. It means all records are transferd from source table to targeted table. There is link transform history you can check whether it is successful with errors or not. And how many records are inserted, updated all status.

  • You can check in ServiceNow users table. Top left side in search filter search for users.
  • You can see 3 records which were available in AD are inserted here in user table of ServiceNow

 

Finally all Steps are done you have successfully imported all records from you AD to ServiceNow.

LDAP integration is done with ServiceNow.

 

ServiceNow connector deployment guide 1.0.0.0

Difference Between the Liferay 6.2 and Liferay 7/DXP

  1. Basic Difference Between the Liferay 6.2 and Liferay 7/DXP

Sr.No

Parameters

Liferay 6.2

Liferay 7/DXP

1.

Modularity Development

Liferay 6.2 partially support and it’s an experiment and it need more effort to achieve the modularity.

Liferay 7 support modularity development using OSGi framework.

2.

Bootstrap Version

Support Bootstrap 2 UI framework.

Liferay 7 support Bootstrap 3 UI framework.

3.

AUI Version

AUI 2.x components are used.

AUI 3.x components are used.

4.

Application Development

Liferay Application Development based on Plugins.

Liferay Application Development based on OSGi bundles.

5.

Enterprises Editions name

We simply call Liferay 6.2 EE or CE

Liferay 7 EE called Liferay DXP

6.

Application Packaged method

Liferay Applications packaged as war files and deployed in traditional application server.

Liferay Applications packaged as OSGi bundle jar files and deployed in OSGi container. It support WAR deployment as well.

7.

Isolation

Liferay 6.2 core portal and its default portlets all available in ROOT directory and deployed in Application Server.

Liferay 7 separate core portal and its default portlets. Core portal only have core features rest of features made it as portlets and packaged as bundles. Core portal files in ROOT directory deployed in Application Server. All portlet bundles available in data/OSGI directory. It means bundles deployed in OSGi container.

8.

Search Engine

Liferay 6.2 in built search engine is Apache Lucene. Liferay 6.2 have SOLR web to enable SOLR search.

Liferay 7 inbuilt search engine Elastic Search. It support SOLR search as well.

9.

Single Page Application

Liferay 6.2 does not have inbuilt Single Page Application support but we can integrate SPA framework to achieve it.

Liferay 7 have Single Page Application inbuilt support using Senna.js

10.

Build tools Support

Liferay 6.2 support MAVEN, ANT.

Liferay 7 support MAVEN, GRADLE build tools.

11.

Application development tools.

Liferay 6.2 have Plugins SDK Command Line Interface to create portlet, hook, theme and layout.

Liferay 7 introduce new tool called BLADE CLI to develop Liferay 7 Application as bundles. Internally its uses the Build tools GRADLE flavor.

12.

Activate/Deactivate Application

Liferay 6.2 it is not possible. We should un-deploy the plugins from the server so that we can remove the unused features.

We can activate/deactivate Liferay Application Bundles simply using Apache Gogo shell Command Line Interface without un-deploy the bundle from the container.

13.

Languages For UI

Liferay 6.2 does not have design languages like Clay and Lexicon. But it supports all necessary UI Languages like HTML, CSS, Bootstrap, JQuery, Alloy-UI etc

Liferay 7 have introduced Clay and Lexicon language to design UI. Lexicon is a design language that provides a common framework for building interfaces. Clay is web implementation of Lexicon.It’s built with HTML, CSS, and Javascript with Bootstrap as a foundation

14.

Flexibility

Not So flexible environment, we need to perform code changes for any single change. like We cannot deactivate default portlets without change in the code.

Provide more flexible environment like We can easily deactivate default portlets if we are not using. We simply deactivate portlet bundle.

 

 

 

ServiceNow connector deployment guide 1.0.0.0

Why ServiceNow Leading ITSM from past 4 years as per granter Magic Quadrant.

The main aim of ServiceNow is to make work easier and in fastest way.

It helps to reduce manual IT work like unstructured work, eliminating the back and forth emails, phone calls and the processes that waste time, money, and sap productivity. It brings automation in every process of organization i.e. entire enterprise—HR, customer service, security, and beyond—can tap into the power of the Now Platform to create a better experience for employees, users, customers, and transform the way work is done.

 

  1. ServiceNow has Intelligent Automation Engine at Knowledge17 to bring machine learning to everyday work.
  2. It has used DxContinuum as a core technology for that engine.
  3. Also it applying artificial intelligence to routine service desk conversations with Qlue’s virtual agent messaging capabilities will enhance customer experiences.

Below are the features of ServiceNow to recognize as a Leader in ITSM.

Automation:

Automation/Orchestration is about aligning the business request with the applications, data, and infrastructure in fastest way and reduce manual dependency. Task associates with workflow to trigger and response in scheduler manner.

Business transformation

It fulfil the requirement of each audience. It became one of the leading business advisor.

It has create its own value with the design thinking power. Turn digitalization to its opportunity. I has goal for enterprise with business strategists.

Change management

So many enhance and new features added in change management such as Email notification, Auto Add Agenda Decisions in change Adversary board (CAB), meeting notes, checking features of workbench.

Cloud Architecture

Ø  The ServiceNow cloud is built on an advanced architecture called multi-instance.

  • A multi-instance architecture gives every customer its own unique database, which reduce Data cloning with other user. The multi-instance architecture is not built on large centralized database software and infrastructure. Instead, everything deploy on instances on a per-customer basis, allowing the multi-instance cloud to scale horizontally and infinitely. For multi-instance cloud, data deploy separate application logic (Apache Tomcat Java Virtual Machines) and database processes (MySQL) for every customer.
  • Each customer instance is a unique software stack and this means that, unlike some competing platforms, there is no 70-page document of restrictions and limitations. User instances in SNOW cloud are for individual enterprise and individual business needs. With this architecture and deployment model comes a wealth of benefits; true data isolation, advanced high availability and customer-driven upgrade schedules.
  • Unique customer instances far easier to perform and issues can be resolved on a customer-by-customer basis, which is called true data isolation.
  • Also individual instance can upgrade so fastly as no dependency and data collaborated with other instance which is very fastest process.

Cloud Operations

Ø  As the demand for cloud services grows. It becomes a big challenges in maintaining service level standards as well as controlling the risks and costs to the organization. So, Today’s IT leaders must have a way to meet these needs, while at the same time get to the cloud faster. To achieve success, they must have a standard operating approach to both their hybrid and public clouds without slowing down service innovation.

Ø  ServiceNow Cloud Management solution gets you to the cloud faster by allowing you to deliver enterprise‑class services faster, without runaway costs, user complexity or increased risks. Virtual Provisioning Cloud Administrator, Virtual Provisioning Cloud Approver, Virtual Provisioning Cloud Operator, Virtual Provisioning Cloud User

Cloud security

  • As a customer, your instance is hosted in the SaaS environment. Which has “Private” environment only hosting subscription service. Also same time the instance is logically separated from all other tenants in our cloud environment because of multi‑instance architecture.

Enterprise cloud

Ø  Enterprise Cloud Computing refers to a computing environment residing behind a firewall that delivers software, infrastructure and platform services to an enterprise. The unique, multi‑instance architecture ensures that, as a customer, you can fully customize cloud services and perform upgrades on your own schedule. Highly secure, the Nonstop Cloud conforms to the highest levels of compliance and global regulations.

HR service management

Ø  ServiceNow HR Service Management improves HR service delivery by offering a consumer‑like self‑service portal to employees along with out‑of‑the‑box request and fulfill process automation. An HR service catalog presents employees with pre‑defined services such as benefits or employee relations items. Once requests are submitted through the HR service catalog, cases are automatically assigned to a designated human resources specialist or team for fulfilment. Integrated reporting provides insight into volume, types of requests, and individual workloads which improve both services and HR operations.

Innovation

Ø  Now, IT is expected to align with the business and become an equal partner in business success—increasing productivity, unlocking new revenues, and powering competitive advantage. Based upon growing demand the SNOW has its innovative idea to fulfill user’s demand.

IT Integration

Ø  ServiceNow integrates with many third party applications and data sources.

Ø  The most common integrations are with CMDB, Incident Management, Problem Management, Change Management, User Administration, and Single Sign-on. A variety of techniques can be used, most notably Web Services, JDBC, LDAP, Excel, CSV, and Email, as well as any industry standard technologies that use SOAP, REST, or WSDL. Additionally, API and command-line integrations can be done using a MID Server. ServiceNow has performed the following integrations with enterprise systems and platforms, which means it extends integration scope with almost all the third party.

IT service management

Ø  Deliver IT Service Management on a single, cloud-based platform. Asset management, contract management,Procurement,Product Catalog,Benchmarks,Change management, Expense Line, Incident Management,ITSM Guided Setup, on-call scheduling, Problem Management, Request Management, Service Catalog, Service Desk, Service Level Management, Service Portfolio Management,ITSM Performance Analytics Solutions, HR Service Management, Field Service Management, Legal Service Management, Finance Service Management, Marketing Service Management, Security Operations, Customer Service Management, Application Development.

Ø  Using our ServiceNow Developer Suite helps you meet the demand for custom business applications that enable you to provide business services. With a rich set of pre‑built services and templates, you can quickly build, test and publish applications that can span from a single department to your entire enterprise. And because minimal to no coding is required, almost anyone can build business applications for every line of business and department.

Service management

Ø  Create a modern work environment by placing a service‑oriented lens on the activities, tasks and processes that make up day‑to‑day work life. This service model enables enterprise service domains to define services, provide an intuitive service experience, deliver service, assure service availability and analyse critical service metrics. It replace legacy mailing chain and spreadsheet.

Ø  With ServiceNow Service Management, you can refine, structure and automate the flow of work to streamline service delivery. It connects provider and requestor.

Ø  Our customers have standardized on ServiceNow for enterprise‑wide service management — applying the service model to many different use cases outside of IT, into the broader enterprise and beyond. IT, HR, facilities, field service and other service domains use our model to manage all of the service relationships that make up the contemporary workplace.

 

Human Resources Management

ServiceNow HR Service Management streamlines and improves HR service delivery by offering a consumer‑like self‑service portal to employees along with out‑of‑the‑box request and fulfill process automation. An HR service catalog presents employees with pre‑defined services such as benefits or employee relations items. Once requests are submitted through the HR service catalog, cases are automatically assigned to a designated human resources specialist or team for fulfilment. Integrated reporting provides insight into volume, types of requests, and individual workloads so that HR management can align services and resources, and identify opportunities to improve both services and HR operations.

IT operations management

IT Operations Management (ITOM) encompasses a set of capabilities for ensuring that enterprise infrastructure and applications are optimized and always available for the business. ServiceNow ITOM enables infrastructure, applications, and processes to be managed in a highly automated – and service‑centric – manner.

Governance

Continuous monitoring and real time dashboard provide actionable information about high impact risks, vendor status, noncompliance and significant audit finding.

Employees Service Experience

  • PROVIDE INSTANT ANSWERS TO QUESTIONS
  • ALLOW EMPLOYEES TO REQUEST ANY HR SERVICE
  • AUTOMATICALLY ROUTE CASES TO THE RIGHT PEOPLE
  • ORCHESTRATE ACTION ACROSS MULTIPLE DEPARTMENTS
  • PROVIDE A CONSUMER-LIKE SERVICE EXPERIENCE
ServiceNow connector deployment guide 1.0.0.0

Integrate KeyCloak with OpenDJ LDAP

 

  1. Login keycloak server in administrator mode.
  2. Select the realm Demo
  3. Click on User Federation tab.

 

  1. Select ldap from drop down list. You will redirected to Add user federation provider page.

 

  1. Fill the following data :

 

Edit Mode                  –          Select Writable

            Vendor                        –          Other

            Connection URL       –          ldap://<localhost>:1389

            Users DN                    –          dc=example,dc=com

            Bind DN                     –          cn=Directory Manager

            Bind Credential         –          Opendj Password

 

            Cliclk on Test connection.    

  1. Click on Save.
  1. Register new account to Demo realm.
  2. You will be able to see your created user in keycloak User List.

 

  1. You will also able to see your created user in OpenDJ.

 

 

 

 

ServiceNow connector deployment guide 1.0.0.0

KeyCloak SAML SSSO with WordPress

This blog discusses about the wordpress SAML SSO woth KeyCloak IAM

  1. Start wordpress install miniOrange SSO using SAML 2.0 plugin.
  2. Start keycloak server in administartor mode.
  3. In your Keycloak admin console, select the realm that you want to use.
  4. From left menu, select Clients.

 

  1. Create a new client/application. Configure the following:

 

Client ID                                –           The SP-EntityID / Issuer from the wordpress plugin under                                        Identity Provider tab

Name                                      –           Provide a name for this client (Eg. WordPress)

Description                            –           Provide a description (Eg. WordPress site)

Enabled                                  –           ON

Client Protocol                      –           SAML

Include AuthnStatement      –           ON

Sign Documents                    –           ON

Sign Assertions                      –           ON

Signature Algorithm             –           RSA_SHA256

Canonicalization Method     –           EXCLUSIVE

Force Name ID Format        –           ON

Name ID Format                   –           Email

Root URL                              –           The ACS (Assertion Consumer Service) URL from the                                                          wordpress plugin under Identity Provider tab.

Valid Redirect URIs              –           The ACS (Assertion Consumer Service) URL from the                                                          wordpress plugin under Identity Provider tab.

 

  1. Under Fine Grain SAML Endpoint Configuration, configure the following:

 

Assertion Consumer Service –         The ACS (Assertion Consumer Service) URL from the        POST Binding URL                            wordpress plugin under Identity Provider tab.

 

  1. Click on Save.

 

 

  1. Configuring WordPress as SP in WordPress

 

  1. Go to,

http://<YOUR_DOMAIN>>/auth/realms/{YOUR_REALM}/ protocol/ saml/ descriptor.           This will open an XML in the browser.

 

  1. In miniOrange SAML plugin, go to Service Provider Tab. Enter the following values:

Identity Provider Name   –           Keycloak

IdP Entity ID or Issuer     –           Search for entityID. Enter it’s value in this textbox.

SAML Login URL            –           Search for SingleSignOnService Binding=                                                                                                      “urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect”.                                          Enter the Location value in the textbox.

X.509 Certificate               –           Enter the X509Certificate tag value in this textbox

 

  1. In miniOrange SAML plugin, go to Attribute/RoleMapping tab. Enter the following values:

 

Username         –              Name of the username attribute from IdP (Keep NameID by default)

Email                –              Name of the email attribute from IdP (Keep NameID by default)

FirstName        –              Name of the firstname attribute from IdP

LastName        –               Name of the lastname attribute from IdP

 

  1. Under the Role Mapping section, configure which GROUP value coming in the SAML response needs to be mapped to which role in WordPress. The Group value coming in the SAML response will be mapped to the Role assigned here and the user will be assigned that role in WordPress.

Keep all values as it is. Click Save.

  1. Go to SSO Login Settings tab. Enable Check this option if you want to add a Widget to your page under Use a Widget.

 

11.1. Go to Appearances > Widgets.

11.2. Select “Login with Keycloak“. Drag and drop to your favourite location and save.

 

  1. Hit the URL : http://localhost/wordpress

 

 

  1. Click on login with Keycloak, you will be directed to Keycloak Authentication page.

 

 

  1. Login with registered email and password.

 

You will see it redirects to word press and user is logged in.

ServiceNow connector deployment guide 1.0.0.0

Keycloak IAM Installation and Basic Config

 

  1. Download keycloak 3.4.3.Final server zip file from http://www.keycloak.org /downloads.html.

 

  1. Unzip the file and go to the bin/ directory.
  2. Run standalone.sh and hit http://localhost:8080/auth. It will open keycloak welcome page.

 

  1. Fill the data and click on create.
  2. After you create the initial admin account, you can log in to the Admin Console.

Click on Administration Console link or hit http://localhost:8080/auth/admin/.

 

  1. Login with the username and password you created on the Welcome page. The Keycloak Admin Console page opens.

  1. Creating a Realm and User in Keycloak.

7.1. Log in to the Keycloak Admin Console

7.2. In the top left corner dropdown menu that is titled Master, click Add Realm.

7.3. Create new realm from scratch so type demo for the realm name and click Create.

7.4. After creating the realm the main Admin Console page opens. The current realm is now set to demo. You can switch between managing the master realm and the realm you just created by clicking the top left corner dropdown menu.

  1. Creating a New User in Keycloak.

8.1. In the left menu bar click Users. The user list page opens.

8.2. On the right side of the empty user list, click Add User. Fill the user information and click save.

8.3. To define a temporary password for your new user. Click the Credentials tab. Type a new password and confirm it. Click Reset Password to reset the user password to the new one you specified.

 

ServiceNow connector deployment guide 1.0.0.0

VilMinds Agile/Scrum Card

What Is Agile?
The Agile movement seeks alternatives to traditional project management. Agile approaches help teams respond to unpredictability through incremental, iterative work cadences and empirical feedback. Agilists propose alternatives to waterfall, or traditional sequential development.

What is Scrum?
Scrum is the most popular way of introducing Agility due to its simplicity and flexibility.Scrum emphasizes empirical feedback, team self management, and striving to build properly tested product increments within short iterations.
Tools Used in agile/Scrum project.
JIRA , Rally , Redmine etc.

Agile Overview.
Delivering small piece of functionality within short period of time (Sprint).
Small piece of functionality is considered as User Story.
Product Backlog: Complete product functionality (user stories).
Sprint = Short period, it can be 2 Weeks, 3 Weeks depends on the project.

Agile/Scrum roles:
1) Product Owner – Responsible for writing user stories, acceptance criteria.
2) Scrum Master – Responsible to manage the scrum and sprints
3) Team (Developer, Testers, Architects etc.) – Responsible to implement and deliver the user stories

Agile Ceremonies or Events:

1) Sprint grooming
Occurs only once at beginning of the sprint, More than 1 Hour
Product owner explains each user story and acceptance criteria and clarifies the requirements.
Each user story is estimated according to its complexity and weightage; Story points is the measure for estimation.

Different tools can be used to estimate the user story. Ex, Jira agile poker, planning poker (https://www.planningpoker.com/) etc.

2) Sprint Planning/ sprint Kick off
Occurs only once at beginning of the sprint, More than 1 Hour
Planning user stories for implementation/delivery for a particular sprint according to team capacity.
Some or all the user stories from groomed stories can be planned for the particular sprint.
Sprint Backlog: User stories taken for that particular sprint.

Braking user stories in subtasks:
User stories will be broken down in the sub tasks like below and assigned to the team members.
Ex.
1) Analysis and understanding user story- 4Hr
2) Design
3) Writing java code
4) Designing user interface
5) Code quality
6) Unit Testing
7) Test Case writing
8) Test case execution
9) Defect tracing
10) Defect Verification
11) Demo

3) Sprint Review/Demo
Occurs only once at end of the sprint , More than 1 Hour.
At the end of the sprint the implemented/tested user stories will be demoed to the product owner.
Demo to the client (Product owner)

4) Sprint Retrospective
Occurs only once at end of the sprint, More than 1 Hour
The sprint retrospective is a meeting facilitated by the ScrumMaster at which the team discusses the just-concluded sprint and determines what could be changed that might make the next sprint more productive.

Three points will be discussed in this meeting.
a) What went well
b) What went wrong
c) Improvement’s

Ex.
What went right/well wrong Improvement
Sprint demo went well Requirement was not clear Team Sync.

5) Daily Scrum
This is the daily meeting for the particular sprint, 15-20 Minutes.
Team member has to give the status update to the team in following manner.
What I did yesterday, today and if any blocker/dependency.

ServiceNow connector deployment guide 1.0.0.0

Helpful GIT Commands

-Initial git clone
git clone https://jon@git.vilminds.com/primo/mobile/project-name.git

-Git commit Changes
git add –all
git commit -m “Initial Commit”

-Git Push
git push -u origin master

-Git Pull
git pull origin master

-Git Create Branch in Local
git checkout -b new-branch existing-branch

For merging forked branch , need to create pull request and admin can merge it.

-Git add  all files under folder

git add src/test/\*

 

ServiceNow connector deployment guide 1.0.0.0

OpenAM Validate OAuth token – java code

public static void validateOAuthToken(String token) {

Client client = Client.create();
WebResource webResource = client.resource(OPENAM_HOST+”/oauth2/tokeninfo?access_token=”+token);

ClientResponse response = webResource.type(MediaType.APPLICATION_FORM_URLENCODED).get(ClientResponse.class);

String output = response.getEntity(String.class);
System.out.println(response.getStatus());
System.out.println(“>> access token info>>”+output);
}