I was able to solve this using below Code :
Java Code :
Configuration hadoopConfiguration = SparkSession.sparkContext().hadoopConfiguration();
log.info("CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH : "+hadoopConfiguration.get(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH ));
String accessKey = new String(hadoopConfiguration.getPassword("fs.s3a.access.key"));
String secretKey = new String(hadoopConfiguration.getPassword("fs.s3a.secret.key"));
Scala Code :
val hadoopConfiguration = sparkSession.sparkContext.hadoopConfiguration
hadoopConfiguration.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, keyFileHdfsPath);
val access_Key = hadoopConfiguration.getPassword("fs.s3a.access.key").mkString
val secret_Key = hadoopConfiguration.getPassword("fs.s3a.secret.key").mkString