Author Archives: admin

ANGULAR 4.2

Angular 4.2

The Angular team continues to publish new versions of Angular according to the Semantic versioning. Angular version 4 was released on March 16, six months’ later version 2 was released. In the last three months two minor versions and a lot of patch versions were born with new stuff. Angular 4.2 is already here and we have a huge number of new features added for making animations easier and powerful. Part of them are defining the reusable animations, querying for inner elements, animating when routes change and building/controlling an animation using AnimationBuilder. So, let’s dive deep-in and know about the new features in Angular 4.2.

Angular 4.2

WHAT’S NEW?

  • Angular Forms now includes validators for min and max attributes.
  • Developer can now bootstrap a component directly by passing an element reference to the bootstrap method of an ApplicationRef.
  • Enhanced i18n tooling including MissingTranslationStrategy and location notes in xliff2 files.
  • New compiler flag alwaysCompileGeneratedCode is available in opt-in, and will be turned on by default in the future.

NEW FEATURES IN ANGULAR 4.2
Forms

Two new validators joins the existing requirement, minLength, maxLength, email, and pattern. Min and Max helps the developer to validate whether the input is at least or at most the value specified or not.

<input type=”number” [(ngModel)]=”user.age” min=”0″ max=”130″>

Update (2017-06-17): The min and max validators have been temporarily removed from Angular in version 4.2.3, as they are a breaking change. They’ll return in a major version, maybe 5.0.0.

Angular Animations

There are huge number of new features to make working with Animations easier and more powerful. Some of the new feature are:

  • Configure options and set input variables within animations.
  • Define reusable animations using animation().
  • Stagger multiple elements within an animation using stagger().
  • Enable queried elements to trigger their own animations.
  • Orchestrate a full-blown animation when routes change.
  • Programmatically build/control an animation using AnimationBuilder

A new query function has been introduced in the animation DSL, allowing to query the elements in the template. It uses querySelectorAll behind the scene, so the developer can use an element or a class as parameter. It also supports pseudo-selectors, and that opens a few interesting possibilities!

For example, you can now easily animate elements in a NgFor:

<div [@races]=”races?.length”>

<button class=”btn btn-primary mb-2″ (click)=”toggle()”>Toggle</button>

<div *ngFor=”let race of races | slice:0:4″>

<h2>{{race.name}}</h2>

<p>{{race.startInstant}}</p>

</div>

</div>

WITH THE FOLLOWING ANIMATION

trigger(‘races’, [

transition(‘* => *’, [

query(‘:leave’, [

animate(1000, style({ opacity: 0 }))

], { optional: true }),

query(‘:enter’, [

style({ opacity: 0 }),

animate(1000, style({ opacity: 1 }))

], { optional: true })

])

])

Now, every time an element is removed from the races array, it will slowly fade out. And when an element enters, it will slowly fade’s in.

Animation has also been added to build reusable animations. The syntax allows to have dynamic parameters with default values. The developer need to use a reusable animation, they can call useAnimation, and override the default parameters if they want to.

FINAL WORD

That’s all for this release! The focus was mainly on animations and tests, and the team is also working on reducing the bundle size of the applications, with the help of the Google Closure Compiler. We think we are going to learn more about that very soon!

SPRINGBOOT

SpringBoot

Spring is a very popular Java based framework for building web and enterprise applications. Unlike many other frameworks which focuses on only one area, Spring framework provides a wide variety of features addressing the modern business needs through its portfolio projects. Spring framework provides flexibility to configure the beans in multiple ways such as XML, Annotations, and JavaConfig. With the number of features increased the complexity also gets increases and configuring Spring applications becomes tedious and error-prone. Spring team created SpringBoot to address the complexity of configuration. Explore this article and know more about SpringBoot.

Overview of Spring framework

If you are a Java developer, then there is a high chance that you might have heard about Spring framework and probably have used it in your projects. Spring framework was initially created as a Dependency Injection container but we all know it is much more than that.

Spring is very popular because of various reasons

  • Spring’s dependency injection approach encourages the writing testable code.
  • Spring simplifies integration with other Java frameworks like JPA/Hibernate ORM, Struts/JSF, and other web frameworks
  • State of the art Web MVC framework for building web applications

Along with Spring framework there are many other Spring sister projects which helps to build applications addressing modern business needs:

SPRINGBOOT

Spring Data : Simplifies data access from relational and NoSQL data stores.

Spring Batch : Provides powerful batch processing framework.

Spring Security : Robust security framework to secure applications.

Spring Social : Supports integration with social networking sites such as Facebook, Twitter, LinkedIn, GitHub, and much more.

Spring Integration : An implementation of Enterprise Integration Patterns to facilitate integration with other enterprise applications using lightweight messaging and declarative adapters.

There are many other interesting projects addressing various other modern application development needs.

In the initial days, Spring framework has provided XML based approach for configuring beans. Later Spring has introduced XML based DSLs, Annotations, and JavaConfig based approaches for configuring beans.

A quick taste of SpringBoot

Welcome to SpringBoot! SpringBoot do what exactly you are looking for. It will do things automatically for the user and allows them to override the defaults if they want to.

Instead of explaining in theory let’s see by example.

Step 1: Create a Maven based SpringBoot Project

Create a Maven project and configure the dependencies as follows:

?

<?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.sivalabs</groupId>

<artifactId>hello-springboot</artifactId>

<packaging>jar</packaging>

<version>1.0-SNAPSHOT</version>

<name>hello-springboot</name>

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>1.3.2.RELEASE</version>

</parent>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<java.version>1.8</java.version>

</properties>

<dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-test</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-data-jpa</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-thymeleaf</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-devtools</artifactId>

</dependency>

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

</dependency>

</dependencies>

</project>

Wow our pom.xml suddenly become so small!!.

Step 2: Configure datasource/JPA properties in application.properties in src/main/resources as follows.

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.datasource.url=jdbc:mysql://localhost:3306/test

spring.datasource.username=root

spring.datasource.password=admin

spring.datasource.initialize=true

spring.jpa.hibernate.ddl-auto=update

spring.jpa.show-sql=true

Step 3: Create a JPA Entity and Spring Data JPA Repository Interface for the entity.

Create User.java, UserRepository.java and HomeController.java same as in springmvc-jpa-demo application.

Step 4: Create Thymeleaf view to show list of users

Copy /WEB-INF/views/index.html that we created in springmvc-jpa-demo application into src/-main/resources/templates folder in our new project.

Step 5: Create SpringBoot EntryPoint Class

Create a Java class Application.java with main method as follows:

@SpringBootApplication

public class Application

{

public static void main(String[] args)

{

SpringApplication.run(Application.class, args);

}

}

Now run Application.java as a Java Application and point your browser to

http://localhost:8080/.

SERVICE ORIENTED ARCHITECTURE

Service Oriented Architecture

Service-oriented architecture (SOA) is an evolution of distributed computing based on the request or reply design paradigm for synchronous and asynchronous applications. An application’s business logic or individual functions are modularized and presented as services for consumer or client applications. The key to these services is their loosely coupled nature; i.e., the service interface is independent of the implementation. Application developers or system integrators can build applications by composing one or more services without knowing the services’ underlying implementations. For instance, a service can be implemented either in .Net or J2EE, and the application consuming the service can be on a different platform or language. Explore this article and get an in-depth idea about SOA.

Key characteristics of SOA

  • SOA services have self-describing interfaces in platform-independent XML documents. Web Services Description Language (WSDL) is used to describe the services.
  • SOA services connects with the messages formally which is defined through XML Schema. Communication among the consumers and providers or services typically happens in heterogeneous environments, with less or no knowledge about the provider. Messages between the services can be viewed as key business documents processed in an enterprise.
    SOA services are maintained in the enterprise by a registry that acts as a directory listing. Applications can look up the services in the registry and can invoke the service.

Architecture

Architecture of SOA

Several service consumers can invoke services by sending the messages. These messages are transformed and routed by a service bus to an appropriate service implementation. The service architecture also provides a service management infrastructure that manages the services and activities such as, auditing, billing, and logging. In addition, the architecture also offers enterprises the flexibility of having agile business processes, better addresses the regulatory requirements like Sarbanes Oxley (SOX), and changes individual services without affecting other services.

Why SOA?

The reality in IT enterprises is that infrastructure is heterogeneous across the operating systems, applications, and system software. Some existing applications are used to run current business processes, so starting from the scratch to build new infrastructure isn’t an option. Enterprises should quickly respond to the business alterations with agility and should leverage the existing investments in applications and application infrastructure to address the new business requirements. SOA with its loosely coupled nature allows the enterprises to plug in new services or upgrade existing services in a granular fashion to address the new business requirements, provides the option to make the services consumable across different channels, and exposes the existing enterprise and legacy applications as services, thereby protecting existing IT infrastructure investments.

The Benefits of SOA

While the SOA concept is fundamentally not new, SOA differs from existing distributed technologies. SOA, with a ubiquitous set of standards, brings better reusability of existing assets or investments in the enterprise and lets the user to create applications that can be built on top of new and existing applications. SOA enables the changes to applications while keeping clients or service consumers isolated from evolutionary changes that happen in the service implementation. SOA enables upgrading individual services or services consumers; it is not necessary to completely rewrite an application or keep an existing system that no longer addresses the new business requirements. Lastly, SOA also provides enterprises better flexibility in building applications and business processes in an agile manner by leveraging existing application infrastructure to compose new services.

WHAT IS A RESTFUL API?

What is a RESTful API?

With all the hype surrounding RESTful web services, you’d think it was suddenly a new concept that shot forth on the scene only a year or two ago. The truth is, the concepts underlying RESTful APIs are as old as the web and are best understood from that perspective. Explore this article and know more about RESTful API and how it works.

RESTful API

REST technology is usually preferred as more robust Simple Object Access Protocol (SOAP) technology because REST leverages less bandwidth, making it more suitable for the internet usage. An API for a website is the code that allows two software programs to communicate with each other. The API spells out the proper way for a developer to write a program requesting all the services from an operating system or other application.

The REST is used by browsers can be thought as the language of the internet. As cloud usage is on the rise, APIs are emerging to expose web services. REST is a logical choice for building APIs that allows the users to connect and interact with cloud services. RESTful APIs are used by the sites such as Amazon, Google, LinkedIn, and Twitter.

How RESTful APIs works

A RESTful API breaks down a transaction to create a series of small modules. Each module addresses a particular underlying part of the transaction. This modularity provides developers with a lot of flexibility, but it can also be challenging for developers to design from scratch. Presently, the models provided by Amazon Simple Storage Service, Cloud Data Management Interface, and OpenStack Swift are the most popular.

A RESTful API explicitly takes advantage of HTTP methodologies defined by the RFC 2616 protocol. They use GET to retrieve a resource, PUT to change the state or to update a resource, which can be an object, file or a block, POST to create the resource, and DELETE to remove it.

With REST, networked components are a resource you request to access a black box whose implementation details are unclear. The presumption is that all calls are stateless; nothing can be retained by the RESTful service between executions.

As, the calls are stateless, REST is useful in cloud applications. Stateless components can be freely redeployed if something fails, and they can scale to accommodate load changes. This is because any request can be directed to any instance of component. That makes REST preferred for web use, but the RESTful model is also helpful in cloud services because binding to a service through an API is a matter of controlling how the URL is decoded. Cloud computing and micro services are almost certain to make RESTful API design the rule in the future.

SINGLE SIGN-ON (SSO)

Single Sign-On (SSO)

Single-sign-on (SSO) authentication at present is required more than ever. Nowadays, almost every website requires some form of authentication to access its features and content. With the number of websites and services increasing, a centralized login system has become a necessity. In this article we’ll let you know what is SSO and how SSO authentication works.

What is SSO

Single Sign On (SSO) occurs when a user logs in to one Client’s system and then signed in to other Clients system automatically, regardless of the platform, technology, or domain the user is using.

Google’s implementation of login for their products, such as Gmail, YouTube, Google Analytics, and much more, is one of the best examples of SSO. Any user who are logged-on to one of Google’s products are automatically logged in to their other products as well.

Single Sign On usually makes use of a Central Service which organizes the single sign on between multiple clients. In the example of Google, this central service is Google Accounts. When a user first logs-in, Google Accounts creates a cookie, which persists with the user as they navigate to other Google-owned services. The process flow is as follows:

  • The user accesses the first Google product.
  • The user receives a generated cookie.
  • The user navigates to another Google product.
  • The user is redirected again to their accounts.
  • Google Accounts sees that the user already has an authentication-related cookie, so it redirects the user to the requested product.

How it works

In a basic web SSO service, an agent module on the application server retrieves the specific authentication credentials for an individual user from a dedicated SSO policy server, while authenticating the user against a user repository such as a lightweight directory access protocol (LDAP) directory.

Some of the SSO services uses protocols such as Kerberos and the security assertion mark-up language (SAML). SAML is an XML standard that facilitates the exchange of user authentication and authorization data across secure domains. SAML-based SSO services involves the communications between the user, an identity provider that maintains a user directory, and a service provider. When a user attempts to access an application from the service provider, the service provider will send a request to the identity provider for authentication. The service provider will then verify the authentication and log the user in. The user will not have to log in again for the rest of his session. In a Kerberos-based setup, once the user credentials are provided, a ticket-granting-ticket (TGT) is issued. The TGT fetches service tickets for other applications the user wishes to access, without asking the user to re-enter the credentials.

Although single sign-on is a convenience to users, it presents risks to the enterprise security. An attacker who gains control over a user’s SSO credentials will be granted access to every application the user has rights, increasing the amount of potential damage. In order to avoid malicious access, it is essential that every aspect of SSO implementation be coupled with identity governance. Organizations can also use two factor authentication (2FA) or multifactor authentication (MFA) with SSO to improve the security.

Conclusion

SSO authentication is here, decentralized systems are becoming more and more common and authentication is an essential aspect of all of them. SSO solves a big problem such as how to manage the increasing number of users across a whole ecosystem of applications and services. If you are implementing authentication for a new application or a service, consider integrating SSO from the get-go.

WHAT IS PYTHON? WHAT ARE THE BENEFITS OF USING PYTHON? WHAT DO YOU UNDERSTAND OF PEP 8?

What Is Python? What are the benefits of using Python? What do you understand of PEP 8?

Python is one of the most successful interpreted language. When you write a Python script, it doesn’t need to get compiled before execution. Few other interpreted languages are PHP and Javascript.

Benefits Of Python Programming:

Python is a dynamic-typed language, this means that you don’t need to mention the date type of variables during their declaration. It allows to set variables like var1=101 and var2 =” You are an engineer.” without any error.

Python supports object orientated programming as you can define classes along with the composition and inheritance. It doesn’t use access specifiers like public or private.

Functions in Python are like first-class objects. It suggests you to assign them to variables, return from other methods, and pass as arguments.

Developing using Python is quick but running it often is slower than compiled languages. Luckily, Python enables to include the “C” language extensions so that you can optimize your scripts.

Python has several usages like web-based applications, test automation, data modeling, big data analytics, and much more. Alternatively, you can utilize it as “glue” layer to work with other languages.

PEP 8:

PEP 8 is the latest Python coding standard, a set of coding recommendations. It guides you to deliver more readable Python code.