All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.terrafolio.gradle.plugins.jenkins.PreemptiveAuthInterceptor.groovy Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package com.terrafolio.gradle.plugins.jenkins

import java.io.IOException;

import com.sun.net.httpserver.HttpContext

import org.apache.http.HttpException;
import org.apache.http.HttpRequest
import org.apache.http.HttpRequestInterceptor

class PreemptiveAuthInterceptor implements HttpRequestInterceptor {
	def String username
	def String password
	
	public PreemptiveAuthInterceptor(String username, String password) {
		this.username = username
		this.password = password
	}

	@Override
	public void process(HttpRequest request,
			org.apache.http.protocol.HttpContext context) throws HttpException,
			IOException {
		request.addHeader('Authorization', 'Basic ' + "${username}:${password}".toString().bytes.encodeBase64().toString())
	}
}
	




© 2015 - 2025 Weber Informatics LLC | Privacy Policy