From 9d71a78e3e24a3d229b8186d5f64d22cb1782fd4 Mon Sep 17 00:00:00 2001
From: Anuj gupta <anujgupta@in.ibm.com>
Date: Tue, 8 Sep 2020 15:16:13 +0530
Subject: [PATCH] merged ibm-impl changes

---
 .gitignore                                    |  42 ++++++
 pom.xml                                       |   1 +
 provider/notification-ibm/pom.xml             | 132 +++++++++++++++++
 .../provider/ibm/Application.java             |  33 +++++
 .../di/ServiceAccountJwtClientFactory.java    |  38 +++++
 .../provider/ibm/security/SecurityConfig.java |  34 +++++
 .../provider/ibm/util/AppProperties.java      |  45 ++++++
 .../ibm/util/GoogleServiceAccountImpl.java    |  36 +++++
 .../util/IBMServiceAccountValidatorImpl.java  |  45 ++++++
 .../provider/ibm/util/JwtValidity.java        |  17 +++
 .../util/ServiceAccountJwtIBMClientImpl.java  | 136 ++++++++++++++++++
 .../src/main/resources/application.properties |  26 ++++
 12 files changed, 585 insertions(+)
 create mode 100644 provider/notification-ibm/pom.xml
 create mode 100644 provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/Application.java
 create mode 100644 provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/di/ServiceAccountJwtClientFactory.java
 create mode 100644 provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/security/SecurityConfig.java
 create mode 100644 provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/AppProperties.java
 create mode 100644 provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/GoogleServiceAccountImpl.java
 create mode 100644 provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/IBMServiceAccountValidatorImpl.java
 create mode 100644 provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/JwtValidity.java
 create mode 100644 provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/ServiceAccountJwtIBMClientImpl.java
 create mode 100644 provider/notification-ibm/src/main/resources/application.properties

diff --git a/.gitignore b/.gitignore
index 8d3666bc0..46c520986 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,45 @@
 **/out
 **/*.iml
 **/dependency-reduced-pom.xml
+HELP.md
+target/
+bin/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
+.gradle/
+
+### macOS ###
+*.DS_Store
+
+### Integration tests ###
+.gradle
+
+### Environment Configuration ###
+*.env
diff --git a/pom.xml b/pom.xml
index 82222e319..8bd5ba30b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,6 +78,7 @@
 		<module>notification-core</module>
 		<module>provider/notification-gcp</module>
 		<module>provider/notification-azure</module>
+		<module>provider/notification-ibm</module>
 	</modules>
 
 	<distributionManagement>
diff --git a/provider/notification-ibm/pom.xml b/provider/notification-ibm/pom.xml
new file mode 100644
index 000000000..39bace5e9
--- /dev/null
+++ b/provider/notification-ibm/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 2017-2019, Schlumberger
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.opengroup.osdu</groupId>
+    <artifactId>notification-ibm</artifactId>
+    <version>1.0.0</version>
+    <name>notification-ibm</name>
+    <description>IBM implementation for Notification service</description>
+    <packaging>jar</packaging>
+
+    <parent>
+        <groupId>org.opengroup.osdu</groupId>
+        <artifactId>os-notification</artifactId>
+        <version>1.0.0</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <properties>
+        <java.version>8</java.version>
+        <maven.compiler.target>${java.version}</maven.compiler.target>
+        <maven.compiler.source>${java.version}</maven.compiler.source>
+    </properties>
+
+    <repositories>
+        <repository>
+            <id>${gitlab-server}</id>
+            <url>https://community.opengroup.org/api/v4/groups/17/-/packages/maven</url>
+        </repository>
+    </repositories>
+
+    <distributionManagement>
+        <repository>
+            <id>${gitlab-server}</id>
+            <url>https://community.opengroup.org/api/v4/projects/143/packages/maven</url>
+        </repository>
+        <snapshotRepository>
+            <id>${gitlab-server}</id>
+            <url>https://community.opengroup.org/api/v4/projects/143/packages/maven</url>
+        </snapshotRepository>
+    </distributionManagement>
+
+    <dependencies>
+      <!--   <dependency>
+            <groupId>org.opengroup.osdu</groupId>
+            <artifactId>os-core-common</artifactId>
+        </dependency> -->
+     
+        
+        <dependency>
+            <groupId>org.opengroup.osdu</groupId>
+            <artifactId>os-core-lib-ibm</artifactId>
+            <version>0.3.6-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.opengroup.osdu</groupId>
+            <artifactId>notification-core</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+
+        <!-- unit test dependencies -->
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-api-mockito2</artifactId>
+            <version>2.0.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-module-junit4</artifactId>
+            <version>2.0.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>2.0.2-beta</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>spring-boot</classifier>
+                            <mainClass>
+                                org.opengroup.osdu.notification.provider.ibm.Application
+                            </mainClass>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-war-plugin</artifactId>
+                <configuration>
+                    <failOnMissingWebXml>false</failOnMissingWebXml>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/Application.java b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/Application.java
new file mode 100644
index 000000000..c9d86a36c
--- /dev/null
+++ b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/Application.java
@@ -0,0 +1,33 @@
+/*
+ *   Copyright 2017-2020, Schlumberger
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+package org.opengroup.osdu.notification.provider.ibm;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.scheduling.annotation.EnableAsync;
+
+@SpringBootApplication
+@ComponentScan({"org.opengroup.osdu"})
+@EnableAsync
+public class Application  {
+
+	public static void main(String[] args) {
+		SpringApplication.run(new Class[] { Application.class} , args);
+	}
+}
+
diff --git a/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/di/ServiceAccountJwtClientFactory.java b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/di/ServiceAccountJwtClientFactory.java
new file mode 100644
index 000000000..f2a5c0684
--- /dev/null
+++ b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/di/ServiceAccountJwtClientFactory.java
@@ -0,0 +1,38 @@
+/*
+ *   Copyright 2017-2020, Schlumberger
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+package org.opengroup.osdu.notification.provider.ibm.di;
+import org.opengroup.osdu.core.common.util.IServiceAccountJwtClient;
+import org.opengroup.osdu.notification.provider.ibm.util.AppProperties;
+import org.opengroup.osdu.notification.provider.ibm.util.ServiceAccountJwtIBMClientImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.AbstractFactoryBean;
+import org.springframework.stereotype.Component;
+
+
+public class ServiceAccountJwtClientFactory extends AbstractFactoryBean<IServiceAccountJwtClient> {
+
+	
+    @Override
+    public IServiceAccountJwtClient createInstance() throws Exception {
+        return new ServiceAccountJwtIBMClientImpl();
+    }
+
+    @Override
+    public Class<?> getObjectType() {
+        return IServiceAccountJwtClient.class;
+    }
+}
diff --git a/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/security/SecurityConfig.java b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/security/SecurityConfig.java
new file mode 100644
index 000000000..3dbea6539
--- /dev/null
+++ b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/security/SecurityConfig.java
@@ -0,0 +1,34 @@
+/*
+ *   Copyright 2017-2020, Schlumberger
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+package org.opengroup.osdu.notification.provider.ibm.security;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+
+@Configuration
+@EnableGlobalMethodSecurity(prePostEnabled = true)
+public class SecurityConfig extends WebSecurityConfigurerAdapter {
+
+    @Override
+    protected void configure(HttpSecurity httpSecurity) throws Exception {
+        httpSecurity
+                .httpBasic().disable()
+                .csrf().disable();  //disable default authN. AuthN handled by endpoints proxy
+    }
+}
\ No newline at end of file
diff --git a/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/AppProperties.java b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/AppProperties.java
new file mode 100644
index 000000000..1fcf572ec
--- /dev/null
+++ b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/AppProperties.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2020 IBM Corp. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opengroup.osdu.notification.provider.ibm.util;
+
+import org.opengroup.osdu.notification.provider.interfaces.IAppProperties;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AppProperties implements IAppProperties {
+
+    @Value("${app.entitlements}")
+    private String authorizeAPI;
+    @Value("${app.register}")
+    private String registerAPI;
+    @Value("${app.expireTime}")
+    private int expireTime;
+    @Value("${app.maxCacheSize}")
+    private int maxCacheSize;
+    
+
+    public String getAuthorizeAPI() {
+        return authorizeAPI;
+    }
+
+    public String getRegisterAPI() {
+        return registerAPI;
+    }
+
+
+}
diff --git a/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/GoogleServiceAccountImpl.java b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/GoogleServiceAccountImpl.java
new file mode 100644
index 000000000..323e59920
--- /dev/null
+++ b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/GoogleServiceAccountImpl.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017-2020, Schlumberger
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opengroup.osdu.notification.provider.ibm.util;
+
+import org.apache.http.impl.client.CloseableHttpClient;
+//import org.opengroup.osdu.core.gcp.GoogleIdToken.IGoogleIdTokenFactory;
+import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import lombok.SneakyThrows;
+
+@Component
+public class GoogleServiceAccountImpl implements IGoogleServiceAccount {
+
+    @SneakyThrows
+    @Override
+    public String getIdToken(String keyString, String audience) {
+    	// TODO for GSA token validation check whether we have to impl
+        return "token";//this.googleIdTokenFactory.getGoogleIdToken(keyString, audience, this.closeableHttpClient);
+    }
+}
\ No newline at end of file
diff --git a/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/IBMServiceAccountValidatorImpl.java b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/IBMServiceAccountValidatorImpl.java
new file mode 100644
index 000000000..5a492f2e0
--- /dev/null
+++ b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/IBMServiceAccountValidatorImpl.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2020 IBM Corp. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opengroup.osdu.notification.provider.ibm.util;
+
+import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;
+import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
+import com.google.api.client.http.javanet.NetHttpTransport;
+import com.google.api.client.json.jackson2.JacksonFactory;
+import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
+import org.opengroup.osdu.notification.provider.interfaces.IServiceAccountValidator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class IBMServiceAccountValidatorImpl implements IServiceAccountValidator {
+
+
+    @Override
+    public boolean isValidPublisherServiceAccount(String jwt) {
+    	//call isValidServiceAccount()
+    	// Check whether IBM have to implement the service account verification for PubSub Role
+    	// Marking it to return true, for the integration tests.
+    	return true;
+    }
+
+    @Override
+    public boolean isValidServiceAccount(String jwt, String userIdentity, String... googleAudiences) {
+    	// Marking it to return true, for the integration tests.
+    	return true;
+    }
+}
diff --git a/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/JwtValidity.java b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/JwtValidity.java
new file mode 100644
index 000000000..223df8263
--- /dev/null
+++ b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/JwtValidity.java
@@ -0,0 +1,17 @@
+package org.opengroup.osdu.notification.provider.ibm.util;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class JwtValidity {
+
+    String token;
+    long expiryTime;
+
+    JwtValidity(String jwt, long expiryTime) {
+        this.token = jwt;
+        this.expiryTime = expiryTime;
+    }
+}
diff --git a/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/ServiceAccountJwtIBMClientImpl.java b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/ServiceAccountJwtIBMClientImpl.java
new file mode 100644
index 000000000..7d3d658df
--- /dev/null
+++ b/provider/notification-ibm/src/main/java/org/opengroup/osdu/notification/provider/ibm/util/ServiceAccountJwtIBMClientImpl.java
@@ -0,0 +1,136 @@
+package org.opengroup.osdu.notification.provider.ibm.util;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.net.ssl.HttpsURLConnection;
+
+import org.apache.http.HttpStatus;
+import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
+import org.opengroup.osdu.core.common.model.http.AppException;
+import org.opengroup.osdu.core.common.util.IServiceAccountJwtClient;
+import org.opengroup.osdu.core.ibm.util.KeyCloakProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@Component
+public class ServiceAccountJwtIBMClientImpl implements IServiceAccountJwtClient {
+	
+	//private AppProperties config;
+	/*@Autowired
+	JaxRsDpsLog log;*/
+	@Value("${keycloak.url}")
+	private String url;
+	@Value("${keycloak.realm}")
+    private String realm;
+	@Value("${keycloak.client_id}")
+	private String client_id;
+	@Value("${keycloak.client_secert}")
+	private String client_secret;
+	private String grant_type = "password";
+	@Value("${keycloak.user}")
+	private String user;
+	@Value("${keycloak.password}")
+	private String pwd;
+	
+/*	public ServiceAccountJwtIBMClientImpl(AppProperties config) {
+        if (config == null) {
+            throw new IllegalArgumentException("AppProperties is null when initializing jwt client.");
+        } else {
+            this.config = config;
+        }
+    }*/
+	
+	@Override
+	public String getIdToken(String tenantName) {
+	/*	String t1=null;
+		try {
+			t1=KeyCloakProvider.getToken(user, pwd);
+			System.out.println("************t1 "+t1);
+			return "Bearer "+t1;
+		} catch (IOException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}*/
+		String token_endpoint = String.format("https://%s/auth/realms/%s/protocol/openid-connect/token", url, realm);
+		URL url;
+		String token = null;
+		HttpsURLConnection con;
+		try {
+			url = new URL(token_endpoint);
+			con = (HttpsURLConnection) url.openConnection();
+			con.setRequestMethod("POST");
+			con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+			Map<String, String> parameters = new HashMap<>();
+			parameters.put("grant_type", grant_type);
+			parameters.put("client_id", client_id);
+			parameters.put("client_secret", client_secret);
+			parameters.put("username", user);
+			parameters.put("password", pwd);
+
+			con.setDoOutput(true);
+			DataOutputStream out = new DataOutputStream(con.getOutputStream());
+			out.writeBytes(getParamsString(parameters));
+			out.flush();
+			out.close();
+
+			BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
+			String inputLine;
+			StringBuffer content = new StringBuffer();
+			while ((inputLine = in.readLine()) != null) {
+				content.append(inputLine);
+			}
+			in.close();
+
+			con.disconnect();
+
+			Gson gson = new Gson();
+			JsonObject jobj = gson.fromJson(content.toString(), JsonObject.class);
+			token = jobj.get("access_token").getAsString();
+			token = "Bearer "+token;
+		} catch (MalformedURLException e) {
+			log.error("MalformedURLException while generating token"+e.getMessage());
+			e.printStackTrace();
+		} catch (IOException e) {
+			log.error("IOException while generating token"+e.getMessage());
+			throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Provided invalid details", "Error generating token");
+		}
+		return token;
+		// TODO : Implement jwtCache for storing generated token
+	}
+
+	private static String getParamsString(Map<String, String> params)
+            throws UnsupportedEncodingException {
+        StringBuilder result = new StringBuilder();
+
+        for (Map.Entry<String, String> entry : params.entrySet()) {
+            result.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
+            result.append("=");
+            result.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
+            result.append("&");
+        }
+
+        String resultString = result.toString();
+        return resultString.length() > 0
+                ? resultString.substring(0, resultString.length() - 1)
+                : resultString;
+    }
+
+}
+
+
diff --git a/provider/notification-ibm/src/main/resources/application.properties b/provider/notification-ibm/src/main/resources/application.properties
new file mode 100644
index 000000000..fc48a5016
--- /dev/null
+++ b/provider/notification-ibm/src/main/resources/application.properties
@@ -0,0 +1,26 @@
+#
+#   Copyright 2017-2020, Schlumberger
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
+LOG_PREFIX=notification
+server.servlet.contextPath=/
+app.expireTime=300
+app.maxCacheSize=10
+server.error.whitelabel.enabled=false
+
+keycloak.url=TODO
+keycloak.realm=TODO
+keycloak.client_id=TODO
+keycloak.client_secert=TODO
\ No newline at end of file
-- 
GitLab