Here are the examples of the java api org.apache.http.NameValuePair taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
164 Examples
19
Source : HTTPPOSTData.java
with Apache License 2.0
from tlw-ray
with Apache License 2.0
from tlw-ray
/**
* @author Matt
* @since 24-jan-2005
*/
public clreplaced HTTPPOSTData extends BaseStepData implements StepDataInterface {
public RowMetaInterface outputRowMeta;
public RowMetaInterface inputRowMeta;
public String realEncoding;
public int[] header_parameters_nrs;
public int[] body_parameters_nrs;
public int[] query_parameters_nrs;
public int indexOfUrlField;
public String realUrl;
public NameValuePair[] headerParameters;
public NameValuePair[] bodyParameters;
public NameValuePair[] queryParameters;
public boolean useHeaderParameters;
public boolean contentTypeHeaderOverwrite;
public boolean useBodyParameters;
public boolean useQueryParameters;
public int indexOfRequestEnreplacedy;
public String realProxyHost;
public int realProxyPort;
public String realHttpLogin;
public String realHttpPreplacedword;
public int realSocketTimeout;
public int realConnectionTimeout;
public int realcloseIdleConnectionsTime;
public HTTPPOSTData() {
super();
indexOfUrlField = -1;
useHeaderParameters = false;
contentTypeHeaderOverwrite = false;
useBodyParameters = false;
useQueryParameters = false;
indexOfRequestEnreplacedy = -1;
realEncoding = null;
realProxyHost = null;
realProxyPort = 8080;
realHttpLogin = null;
realHttpPreplacedword = null;
}
}
19
Source : HTTPData.java
with Apache License 2.0
from tlw-ray
with Apache License 2.0
from tlw-ray
/**
* @author Matt
* @since 24-jan-2005
*/
public clreplaced HTTPData extends BaseStepData implements StepDataInterface {
public int[] argnrs;
public RowMetaInterface outputRowMeta;
public RowMetaInterface inputRowMeta;
public int indexOfUrlField;
public String realUrl;
public String realProxyHost;
public int realProxyPort;
public String realHttpLogin;
public String realHttpPreplacedword;
public int[] header_parameters_nrs;
public boolean useHeaderParameters;
public NameValuePair[] headerParameters;
public int realSocketTimeout;
public int realConnectionTimeout;
public int realcloseIdleConnectionsTime;
/**
* Default constructor.
*/
public HTTPData() {
super();
indexOfUrlField = -1;
realProxyHost = null;
realProxyPort = 8080;
realHttpLogin = null;
realHttpPreplacedword = null;
}
}
19
Source : UrlEncodedPair.java
with Apache License 2.0
from proshin-roman
with Apache License 2.0
from proshin-roman
public final clreplaced UrlEncodedPair implements NameValuePair {
private final NameValuePair origin;
public UrlEncodedPair(final String name, final Object value) {
this(name, value.toString());
}
public UrlEncodedPair(final String name, final String value) {
this(new BasicNameValuePair(name, value));
}
public UrlEncodedPair(final NameValuePair origin) {
this.origin = origin;
}
@Override
public String getName() {
return this.origin.getName();
}
@Override
public String getValue() {
try {
return URLEncoder.encode(this.origin.getValue(), StandardCharsets.UTF_8.displayName());
} catch (final UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
}
19
Source : PlainNameValuePair.java
with Apache License 2.0
from proshin-roman
with Apache License 2.0
from proshin-roman
public final clreplaced PlainNameValuePair implements NameValuePair {
private final NameValuePair origin;
public PlainNameValuePair(final String name, final Object value) {
this(name, value.toString());
}
public PlainNameValuePair(final String name, final String value) {
this(new BasicNameValuePair(name, value));
}
public PlainNameValuePair(final NameValuePair origin) {
this.origin = origin;
}
@Override
public String getName() {
return this.origin.getName();
}
@Override
public String getValue() {
return this.origin.getValue();
}
}
19
Source : ConversionUtils.java
with Apache License 2.0
from ngageoint
with Apache License 2.0
from ngageoint
/**
* Converts an Apache {@link NameValuePair} to a {@link Pair}.
*
* @param pair the Apache pair to convert.
* @return the converted pair.
*/
public static Pair<String, String> toPair(final NameValuePair pair) {
return new ImmutablePair<>(pair.getName(), pair.getValue());
}
19
Source : RequestHandler.java
with MIT License
from LucaScorpion
with MIT License
from LucaScorpion
public <T, R extends Response<T>> R get(String endpoint, Clreplaced<R> clazz, NameValuePair... params) {
return handleRequest(buildRequest(endpoint, Request::Get, getParameters(params)), clazz);
}
19
Source : RequestHandler.java
with MIT License
from LucaScorpion
with MIT License
from LucaScorpion
public <T, R extends Response<T>> R post(String endpoint, Clreplaced<R> clazz, NameValuePair... params) {
return handleRequest(buildRequest(endpoint, Request::Post, Collections.emptyList()).bodyForm(getParameters(params)), clazz);
}
19
Source : RequestUtil.java
with Apache License 2.0
from doporg
with Apache License 2.0
from doporg
/**
* 发送put请求到gitlab
*
* @param path 路径
* @param params 参数键值对
* @return 返回状态码
*/
public static int put(String path, List<NameValuePair> params) {
String url = api + path;
NameValuePair p = new BasicNameValuePair("access_token", rootAccessToken);
params.add(p);
return httpPut(url, params);
}
19
Source : RequestUtil.java
with Apache License 2.0
from doporg
with Apache License 2.0
from doporg
/**
* 发送post请求到gitlab
* root身份
*
* @param path 路径
* @param params 参数键值对
* @return 返回状态码
*/
public static int post(String path, List<NameValuePair> params) {
String url = api + path;
NameValuePair p = new BasicNameValuePair("access_token", rootAccessToken);
params.add(p);
return httpPost(url, params);
}
19
Source : HttpDataAdapter.java
with Apache License 2.0
from binjr
with Apache License 2.0
from binjr
protected URI craftRequestUri(String path, NameValuePair... params) throws SourceCommunicationException {
return craftRequestUri(path, params != null ? Arrays.asList(params) : null);
}
19
Source : HttpUtil.java
with Apache License 2.0
from anylineorg
with Apache License 2.0
from anylineorg
public static HttpResult delete(Map<String, String> headers, String url, String encode, NameValuePair... pairs) {
return delete(client(url), headers, url, encode, pairs);
}
18
Source : HttpSendClient.java
with Apache License 2.0
from ucarGroup
with Apache License 2.0
from ucarGroup
private List<NameValuePair> buildPostData(Map<String, Object> params) {
if (params == null || params.size() == 0) {
return new ArrayList<NameValuePair>(0);
}
List<NameValuePair> ret = new ArrayList<NameValuePair>(params.size());
for (String key : params.keySet()) {
Object p = params.get(key);
if (key != null && p != null) {
NameValuePair np = new BasicNameValuePair(key, p.toString());
ret.add(np);
}
}
return ret;
}
18
Source : ProjectBlobPage.java
with MIT License
from theonedev
with MIT License
from theonedev
@Override
public String appendRaw(String url) {
try {
URIBuilder builder;
builder = new URIBuilder(url);
for (NameValuePair pair : builder.getQueryParams()) {
if (pair.getName().equals(PARAM_RAW))
return url;
}
return builder.addParameter(PARAM_RAW, "true").build().toString();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
18
Source : ComponentContainer.java
with Apache License 2.0
from sbabcoc
with Apache License 2.0
from sbabcoc
/**
* Determine if actual query parameters include all expected name/value pairs.
*
* @param actualParams actual query parameters of landing page
* @param expectPair expected query parameters
* @return 'true' of actual query parameters include all expected name/value pairs; otherwise 'false'
*/
private static boolean hasExpectedParam(final List<NameValuePair> actualParams, final NameValuePair expectPair) {
Iterator<NameValuePair> iterator = actualParams.iterator();
while (iterator.hasNext()) {
NameValuePair actualPair = iterator.next();
if (!actualPair.getName().equals(expectPair.getName())) {
continue;
}
String actualValue = actualPair.getValue();
String expectValue = expectPair.getValue();
if ((actualValue == null) ^ (expectValue == null)) {
continue;
}
if ((actualValue == null) || (actualValue.matches(expectValue))) {
iterator.remove();
return true;
}
}
return false;
}
18
Source : DefaultLeaderBoardResource.java
with MIT License
from RobertoGraham
with MIT License
from RobertoGraham
final clreplaced DefaultLeaderBoardResource implements LeaderBoardResource {
private static final NameValuePair OWNER_TYPE_PARAMETER = new BasicNameValuePair("ownertype", "1");
private static final NameValuePair PAGE_NUMBER_PARAMETER = new BasicNameValuePair("pageNumber", "0");
private final CloseableHttpClient httpClient;
private final OptionalResponseHandlerProvider optionalResponseHandlerProvider;
private final Supplier<String> accessTokenSupplier;
private final Supplier<String> inAppIdSupplier;
private DefaultLeaderBoardResource(final CloseableHttpClient httpClient, final OptionalResponseHandlerProvider optionalResponseHandlerProvider, final Supplier<String> accessTokenSupplier, final Supplier<String> inAppIdSupplier) {
this.httpClient = httpClient;
this.optionalResponseHandlerProvider = optionalResponseHandlerProvider;
this.accessTokenSupplier = accessTokenSupplier;
this.inAppIdSupplier = inAppIdSupplier;
}
static DefaultLeaderBoardResource newInstance(final CloseableHttpClient httpClient, final OptionalResponseHandlerProvider optionalResponseHandlerProvider, final Supplier<String> sessionTokenSupplier, final Supplier<String> inAppIdSupplier) {
return new DefaultLeaderBoardResource(httpClient, optionalResponseHandlerProvider, sessionTokenSupplier, inAppIdSupplier);
}
private Optional<List<String>> cohortAccounts(final Platform platform, final PartyType partyType) throws IOException {
return httpClient.execute(RequestBuilder.get("https://fortnite-public-service-prod11.ol.epicgames.com/fortnite/api/game/v2/leaderboards/cohort/" + inAppIdSupplier.get()).addParameter("playlist", String.format("%s_m0_%s", platform.code(), partyType.code())).setHeader(AUTHORIZATION, "bearer " + accessTokenSupplier.get()).build(), optionalResponseHandlerProvider.forClreplaced(Cohort.clreplaced)).map(Cohort::cohortAccounts);
}
@Override
public Optional<List<LeaderBoardEntry>> findHighestWinnersByPlatformAndByPartyTypeForCurrentSeason(final Platform platform, final PartyType partyType, final int maxEntries) throws IOException {
Objects.requireNonNull(platform, "platform cannot be null");
Objects.requireNonNull(partyType, "partyType cannot be null");
if (maxEntries < 0 || maxEntries > 1000)
throw new IllegalArgumentException("maxEntries cannot be less than 0 or greater than 1000");
return httpClient.execute(RequestBuilder.post(String.format("https://fortnite-public-service-prod11.ol.epicgames.com/fortnite/api/leaderboards/type/global/stat/br_placetop1_%s_m0_%s/window/weekly", platform.code(), partyType.code())).addParameter(OWNER_TYPE_PARAMETER).addParameter(PAGE_NUMBER_PARAMETER).addParameter("itemsPerPage", String.valueOf(maxEntries)).setHeader(AUTHORIZATION, "bearer " + accessTokenSupplier.get()).setEnreplacedy(EnreplacedyBuilder.create().setContentType(APPLICATION_JSON).setText(Json.createArrayBuilder(cohortAccounts(platform, partyType).orElseGet(ArrayList::new)).build().toString()).build()).build(), optionalResponseHandlerProvider.forClreplaced(RawLeaderBoard.clreplaced)).map(RawLeaderBoard::leaderBoardEntries).map(leaderBoardEntries -> leaderBoardEntries.stream().sorted(Comparator.comparingLong(LeaderBoardEntry::value).reversed()).collect(Collectors.toList()));
}
}
18
Source : AuthenticationResource.java
with MIT License
from RobertoGraham
with MIT License
from RobertoGraham
final clreplaced AuthenticationResource {
private static final NameValuePair GRANT_TYPE_PreplacedWORD_PARAMETER = new BasicNameValuePair("grant_type", "preplacedword");
private static final NameValuePair GRANT_TYPE_EXCHANGE_CODE_PARAMETER = new BasicNameValuePair("grant_type", "exchange_code");
private static final NameValuePair GRANT_TYPE_REFRESH_TOKEN_PARAMETER = new BasicNameValuePair("grant_type", "refresh_token");
private static final NameValuePair GRANT_TYPE_OTP_PARAMETER = new BasicNameValuePair("grant_type", "otp");
private static final NameValuePair TOKEN_TYPE_EG1 = new BasicNameValuePair("token_type", "eg1");
private final CloseableHttpClient httpClient;
private final OptionalResponseHandlerProvider optionalResponseHandlerProvider;
private AuthenticationResource(final CloseableHttpClient httpClient, final OptionalResponseHandlerProvider optionalResponseHandlerProvider) {
this.httpClient = httpClient;
this.optionalResponseHandlerProvider = optionalResponseHandlerProvider;
}
static AuthenticationResource newInstance(final CloseableHttpClient httpClient, final OptionalResponseHandlerProvider optionalResponseHandlerProvider) {
return new AuthenticationResource(httpClient, optionalResponseHandlerProvider);
}
private Optional<Token> postForToken(final String bearerToken, final NameValuePair... formParameters) throws IOException {
return httpClient.execute(RequestBuilder.post("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token").setHeader(AUTHORIZATION, "basic " + bearerToken).setEnreplacedy(EnreplacedyBuilder.create().setContentType(APPLICATION_FORM_URLENCODED).setParameters(formParameters).build()).build(), optionalResponseHandlerProvider.forClreplaced(DefaultToken.clreplaced)).map(Function.idenreplacedy());
}
Optional<Token> preplacedwordGrantedToken(final String epicGamesEmailAddress, final String epicGamesPreplacedword, final String epicGamesLauncherToken) throws IOException {
return postForToken(epicGamesLauncherToken, GRANT_TYPE_PreplacedWORD_PARAMETER, new BasicNameValuePair("username", epicGamesEmailAddress), new BasicNameValuePair("preplacedword", epicGamesPreplacedword));
}
Optional<Exchange> accessTokenGrantedExchange(final String accessToken) throws IOException {
return httpClient.execute(RequestBuilder.get("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/exchange").setHeader(AUTHORIZATION, "bearer " + accessToken).build(), optionalResponseHandlerProvider.forClreplaced(Exchange.clreplaced));
}
Optional<Token> exchangeCodeGrantedToken(final String exchangeCode, final String fortniteClientToken) throws IOException {
return postForToken(fortniteClientToken, GRANT_TYPE_EXCHANGE_CODE_PARAMETER, TOKEN_TYPE_EG1, new BasicNameValuePair("exchange_code", exchangeCode));
}
Optional<Token> refreshTokenGrantedToken(final String refreshToken, final String fortniteClientToken) throws IOException {
return postForToken(fortniteClientToken, GRANT_TYPE_REFRESH_TOKEN_PARAMETER, new BasicNameValuePair("refresh_token", refreshToken));
}
Optional<Token> twoFactorAuthenticationCodeGrantedToken(final String epicGamesLauncherToken, final String challenge, final String twoFactorAuthenticationCode) throws IOException {
return postForToken(epicGamesLauncherToken, GRANT_TYPE_OTP_PARAMETER, new BasicNameValuePair("otp", twoFactorAuthenticationCode), new BasicNameValuePair("challenge", challenge));
}
void retireAccessToken(final String accessToken) throws IOException {
httpClient.execute(RequestBuilder.delete("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/sessions/kill/" + accessToken).setHeader(AUTHORIZATION, "bearer " + accessToken).build(), optionalResponseHandlerProvider.forString());
}
Optional<Eula> getEula(final String accessToken, final String accountId) throws IOException {
return httpClient.execute(RequestBuilder.get(String.format("%s/%s", "https://eulatracking-public-service-prod-m.ol.epicgames.com/eulatracking/api/public/agreements/fn/account", accountId)).setHeader(AUTHORIZATION, "bearer " + accessToken).addParameter("locale", "en-US").build(), optionalResponseHandlerProvider.forClreplaced(Eula.clreplaced));
}
void acceptEula(final String accessToken, final String accountId, final long eulaVersion) throws IOException {
httpClient.execute(RequestBuilder.post(String.format("%s/%d/%s/%s/%s", "https://eulatracking-public-service-prod-m.ol.epicgames.com/eulatracking/api/public/agreements/fn/version", eulaVersion, "account", accountId, "accept")).setHeader(AUTHORIZATION, "bearer " + accessToken).addParameter("locale", "en").build(), optionalResponseHandlerProvider.forString());
}
void grantAccess(final String accessToken, final String accountId) throws IOException {
httpClient.execute(RequestBuilder.post(String.format("%s/%s", "https://fortnite-public-service-prod11.ol.epicgames.com/fortnite/api/game/v2/grant_access", accountId)).setHeader(AUTHORIZATION, "bearer " + accessToken).build(), optionalResponseHandlerProvider.forString());
}
void killOtherSessions(final String accessToken) throws IOException {
httpClient.execute(RequestBuilder.delete("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/sessions/kill").addParameter("killType", "OTHERS_ACCOUNT_CLIENT_SERVICE").setHeader(AUTHORIZATION, "bearer " + accessToken).build(), optionalResponseHandlerProvider.forString());
}
}
18
Source : BanksCriteria.java
with Apache License 2.0
from proshin-roman
with Apache License 2.0
from proshin-roman
public BanksCriteria withPaging(final PagingCriteria paging) {
for (final NameValuePair parameter : paging) {
this.pairs.add(parameter);
}
return this;
}
18
Source : Template.java
with MIT License
from peta-pico
with MIT License
from peta-pico
private void getPossibleValuesFromNanopubApi(List<NameValuePair> urlParams, String searchterm, Map<String, String> labelMap, List<String> values) {
try {
Map<String, String> params = new HashMap<>();
for (NameValuePair p : urlParams) {
params.put(p.getName(), p.getValue());
}
params.put("searchterm", " " + searchterm);
ApiResponse result = ApiAccess.getAll("find_signed_things", params);
int count = 0;
for (ApiResponseEntry r : result.getData()) {
if (r.get("superseded").equals("1") || r.get("retracted").equals("1"))
continue;
String uri = r.get("thing");
values.add(uri);
String desc = r.get("description");
if (desc.length() > 80)
desc = desc.substring(0, 77) + "...";
if (!desc.isEmpty())
desc = " - " + desc;
String userString = "";
User user = User.getUserForPubkey(r.get("pubkey"));
if (user != null)
userString = " - by " + user.getShortDisplayName();
labelMap.put(uri, r.get("label") + desc + userString);
count++;
if (count > 9)
return;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
18
Source : HttpUtil.java
with Educational Community License v2.0
from opencast
with Educational Community License v2.0
from opencast
public static HttpPost post(String uri, NameValuePair... formParams) {
final HttpPost post = new HttpPost(uri);
setFormParams(post, formParams);
return post;
}
18
Source : HttpUtil.java
with Educational Community License v2.0
from opencast
with Educational Community License v2.0
from opencast
public static HttpPost post(NameValuePair... formParams) {
final HttpPost post = new HttpPost();
setFormParams(post, formParams);
return post;
}
18
Source : RequestHandler.java
with MIT License
from LucaScorpion
with MIT License
from LucaScorpion
/**
* Get a list with all the parameters, including default and auth parameters.
* This also filters out any parameters that are {@code null}.
*
* @param params The parameters to use.
* @return A list containing the given and default parameters.
*/
private List<NameValuePair> getParameters(NameValuePair... params) {
List<NameValuePair> paramList = new ArrayList<>();
// Add all non-null parameters.
paramList.addAll(Arrays.stream(params).filter(Objects::nonNull).collect(Collectors.toList()));
// Add the parameters which always need to be present.
paramList.add(new BasicNameValuePair("app", APP_ID));
paramList.add(new BasicNameValuePair("plat", PLAT_ID));
return paramList;
}
18
Source : Parameters.java
with MIT License
from gflewis
with MIT License
from gflewis
public List<NameValuePair> nvpList() {
List<NameValuePair> result = new ArrayList<NameValuePair>(this.size());
for (Map.Entry<String, String> entry : this.entrySet()) {
NameValuePair nvp = new BasicNameValuePair(entry.getKey(), entry.getValue());
result.add(nvp);
}
return result;
}
18
Source : HttpUtil.java
with Apache License 2.0
from Demo-Liu
with Apache License 2.0
from Demo-Liu
public static String getPostRes(HttpClient client, String url, NameValuePair[] pair) throws IOException, URISyntaxException {
return getPostRes(client, url, pair, null);
}
18
Source : HttpUtil.java
with Apache License 2.0
from Demo-Liu
with Apache License 2.0
from Demo-Liu
public static String getGetRes(HttpClient client, String url, NameValuePair[] pair) throws IOException, URISyntaxException {
return getGetRes(client, url, pair, null);
}
18
Source : AttackThread.java
with MIT License
from Contrast-Security-OSS
with MIT License
from Contrast-Security-OSS
private void permute(List<NameValuePair> fields, boolean attack, int attackPercent) {
for (int i = 0; i < fields.size(); i++) {
NameValuePair field = fields.get(i);
String value = field.getValue();
String newValue = value;
newValue = getToken();
if (RANDOM.nextInt(100) < attackPercent) {
newValue = getAttack();
}
NameValuePair newField = new BasicNameValuePair(field.getName(), newValue);
fields.set(i, newField);
}
}
18
Source : HttpPostTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Test
public void getRequestBodyParametersreplacedtringWithNullEncoding() throws HopException {
HttpPost http = mock(HttpPost.clreplaced);
doCallRealMethod().when(http).getRequestBodyParamsreplacedtr(any(NameValuePair[].clreplaced), anyString());
NameValuePair[] pairs = new NameValuePair[] { new BasicNameValuePair("u", "usr"), new BasicNameValuePair("p", "preplaced") };
replacedertEquals("u=usr&p=preplaced", http.getRequestBodyParamsreplacedtr(pairs, null));
}
18
Source : HttpPostData.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* @author Matt
* @since 24-jan-2005
*/
public clreplaced HttpPostData extends BaseTransformData implements ITransformData {
public IRowMeta outputRowMeta;
public IRowMeta inputRowMeta;
public String realEncoding;
public int[] header_parameters_nrs;
public int[] body_parameters_nrs;
public int[] query_parameters_nrs;
public int indexOfUrlField;
public String realUrl;
public NameValuePair[] headerParameters;
public NameValuePair[] bodyParameters;
public NameValuePair[] queryParameters;
public boolean useHeaderParameters;
public boolean contentTypeHeaderOverwrite;
public boolean useBodyParameters;
public boolean useQueryParameters;
public int indexOfRequestEnreplacedy;
public String realProxyHost;
public int realProxyPort;
public String realHttpLogin;
public String realHttpPreplacedword;
public int realSocketTimeout;
public int realConnectionTimeout;
public int realcloseIdleConnectionsTime;
public HttpPostData() {
super();
indexOfUrlField = -1;
useHeaderParameters = false;
contentTypeHeaderOverwrite = false;
useBodyParameters = false;
useQueryParameters = false;
indexOfRequestEnreplacedy = -1;
realEncoding = null;
realProxyHost = null;
realProxyPort = 8080;
realHttpLogin = null;
realHttpPreplacedword = null;
}
}
18
Source : HttpData.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* @author Matt
* @since 24-jan-2005
*/
public clreplaced HttpData extends BaseTransformData implements ITransformData {
public int[] argnrs;
public IRowMeta outputRowMeta;
public IRowMeta inputRowMeta;
public int indexOfUrlField;
public String realUrl;
public String realProxyHost;
public int realProxyPort;
public String realHttpLogin;
public String realHttpPreplacedword;
public int[] header_parameters_nrs;
public boolean useHeaderParameters;
public NameValuePair[] headerParameters;
public int realSocketTimeout;
public int realConnectionTimeout;
public int realcloseIdleConnectionsTime;
/**
* Default constructor.
*/
public HttpData() {
super();
indexOfUrlField = -1;
realProxyHost = null;
realProxyPort = 8080;
realHttpLogin = null;
realHttpPreplacedword = null;
}
}
18
Source : StaticSolver.java
with GNU General Public License v3.0
from aalhuz
with GNU General Public License v3.0
from aalhuz
// Edit paths to files as need
private static String CreateIncludeMapResolutionFile(SolverModel model, String get, ArrayList<String> candidateUrls, List<NameValuePair> varval, HashMap<String, ArrayList<String>> incMap, String cFile) {
String str = "";
if (model != null) {
if (get != null || model.getGetMap().size() > 0 || model.getNvps().size() > 0) {
for (String src : findSrcUrl(cFile)) {
System.out.println("source url is " + src);
if (incMap != null) {
str = "FILE:" + cFile + "\n";
str += "SRC_URL:" + src + "\n";
}
str += "DEST_URL: ";
if (candidateUrls != null && candidateUrls.size() > 0) {
for (String u : candidateUrls) {
str += u + " ";
System.out.println("u " + u);
}
} else if ((candidateUrls == null || candidateUrls.size() == 0) && model.getUrl() != null) {
System.out.println("model.getUrl " + model.getUrl());
str += model.getUrl();
}
if (varval != null) {
str += "\nNameValuePair: ";
for (NameValuePair p : varval) {
str += p.toString() + " ";
}
}
str += "\nget: ";
if (get != null)
str += get;
}
}
} else // in case of ear vulnerabilities
{
for (String src : findSrcUrl(cFile)) {
String localhost = "http://localhost/";
System.out.println("source url is " + src);
if (incMap != null) {
str = "FILE:" + cFile + "\n";
str += "SRC_URL:" + src + "\n";
int index = src.indexOf("http://192.168.0.123");
if (index != -1)
localhost = src.substring(0, index + ("http://192.168.0.123/".length()));
}
str += "DEST_URL: ";
if (candidateUrls != null && candidateUrls.size() > 0) {
for (String u : candidateUrls) {
str += u + " ";
System.out.println("u " + u);
}
} else if ((candidateUrls == null || candidateUrls.size() == 0)) {
{
String url = cFile.replace("staticreplacedysisSpec/var/www/html/", localhost);
url = url.substring(0, url.indexOf("__"));
str += url;
}
}
str += "\nNameValuePair: ";
str += "\nget: ";
}
}
return str;
}
17
Source : HttpUtilsTest.java
with Eclipse Public License 1.0
from OpenLiberty
with Eclipse Public License 1.0
from OpenLiberty
private void verifyNonNullHeaders(List<NameValuePair> inputHeaders, Header[] headers) {
replacedertEquals("Number of entries in header list did not match expected value. Input headers were: " + inputHeaders + ". Got headers: " + Arrays.toString(headers), inputHeaders.size(), headers.length);
if (!inputHeaders.isEmpty()) {
for (Header postObjHeader : headers) {
NameValuePair compareHeaderValue = new BasicNameValuePair(postObjHeader.getName(), postObjHeader.getValue());
replacedertTrue("Input headers did not originally contain obtained header: " + postObjHeader + ". Input headers were: " + inputHeaders + ". Got headers: " + Arrays.toString(headers), inputHeaders.contains(compareHeaderValue));
}
}
}
17
Source : HttpUtil.java
with Educational Community License v2.0
from opencast
with Educational Community License v2.0
from opencast
private static void setFormParams(HttpEnreplacedyEnclosingRequest r, NameValuePair[] formParams) {
final List<NameValuePair> params = list(formParams);
try {
r.setEnreplacedy(new UrlEncodedFormEnreplacedy(params, "UTF-8"));
} catch (UnsupportedEncodingException e) {
chuck(e);
}
}
17
Source : PostRequest.java
with GNU General Public License v2.0
from mguessan
with GNU General Public License v2.0
from mguessan
public void removeParameter(final String name) {
ArrayList<NameValuePair> toDelete = new ArrayList<>();
for (NameValuePair param : parameters) {
if (param.getName().equals(name)) {
toDelete.add(param);
}
}
parameters.removeAll(toDelete);
}
17
Source : URLQuery.java
with Apache License 2.0
from maestro-performance
with Apache License 2.0
from maestro-performance
/**
* Get a parameter value as a string
* @param name the parameter name
* @param defaultValue the default value if not given
* @return the parameter value or defaultValue if not given
*/
public String getString(final String name, final String defaultValue) {
for (NameValuePair param : params) {
if (param.getName().equals(name)) {
return param.getValue();
}
}
return defaultValue;
}
17
Source : RequestHandler.java
with MIT License
from LucaScorpion
with MIT License
from LucaScorpion
public <T, R extends Response<T>> R get(ApiEndpoint endpoint, Clreplaced<R> clazz, NameValuePair... params) {
return get(endpoint.toString(), clazz, params);
}
17
Source : RequestHandler.java
with MIT License
from LucaScorpion
with MIT License
from LucaScorpion
public <T, R extends Response<T>> R post(ApiEndpoint endpoint, Clreplaced<R> clazz, NameValuePair... params) {
return post(endpoint.toString(), clazz, params);
}
17
Source : StrKit.java
with MIT License
from libsgh
with MIT License
from libsgh
/**
* 贴吧api 参数md5
* @param list 参数列表
* @return 加密字符串
*/
public static String md5Sign(List<NameValuePair> list) {
StringBuilder sb = new StringBuilder();
for (NameValuePair nameValuePair : list) {
sb.append(String.format("%s=%s", nameValuePair.getName(), nameValuePair.getValue()).toString());
}
sb.append("tiebaclient!!!");
return MD5Kit.toMd5(sb.toString()).toUpperCase();
}
17
Source : HttpClientUtils.java
with GNU General Public License v3.0
from JohnNiang
with GNU General Public License v3.0
from JohnNiang
/**
* Requests with https schema.
*
* @param requestUrl request url must not be blank
* @param method http method name must not be blank
* @param enreplacedy http enreplacedy
* @param params name value pair parameters
* @return response string result
* @throws IOException in case of a problem or the connection was aborted
*/
@NonNull
public static HttpResponse requestViaHttps(@NonNull String requestUrl, @NonNull String method, @Nullable HttpEnreplacedy enreplacedy, @Nullable NameValuePair... params) throws IOException {
return requestForResponse(requestUrl, method, enreplacedy, getHttpsClient(), params);
}
17
Source : HttpClientUtils.java
with GNU General Public License v3.0
from JohnNiang
with GNU General Public License v3.0
from JohnNiang
/**
* Requests with http schema
*
* @param requestUrl request url must not be blank
* @param method http method name must not be blank
* @param enreplacedy http enreplacedy
* @param params name value pair parameters
* @return response string result
* @throws IOException in case of a problem or the connection was aborted
*/
@NonNull
public static HttpResponse requestViaHttp(@NonNull String requestUrl, @NonNull String method, @Nullable HttpEnreplacedy enreplacedy, @Nullable NameValuePair... params) throws IOException {
return requestForResponse(requestUrl, method, enreplacedy, getHttpClient(), params);
}
17
Source : UrlEncodedUtils.java
with Apache License 2.0
from jdcloud-api
with Apache License 2.0
from jdcloud-api
/**
* Returns a String that is suitable for use as an {@code application/x-www-form-urlencoded}
* list of parameters in an HTTP PUT or HTTP POST.
*
* @param parameters The parameters to include.
* @param parameterSeparator The parameter separator, by convention, {@code '&'} or {@code ';'}.
* @param charset The encoding to use.
* @return An {@code application/x-www-form-urlencoded} string
*
* @since 4.3
*/
public static String format(final List<? extends NameValuePair> parameters, final char parameterSeparator, final String charset) {
final StringBuilder result = new StringBuilder();
for (final NameValuePair parameter : parameters) {
final String encodedName = encodeFormFields(parameter.getName(), charset);
final String encodedValue = encodeFormFields(parameter.getValue(), charset);
if (result.length() > 0) {
result.append(parameterSeparator);
}
result.append(encodedName);
if (encodedValue != null) {
result.append(NAME_VALUE_SEPARATOR);
result.append(encodedValue);
}
}
return result.toString();
}
17
Source : BridgeWebSocketServer.java
with MIT License
from imTigger
with MIT License
from imTigger
private String getToken(List<NameValuePair> params) {
for (NameValuePair pair : params) {
if (pair.getName().equals("access_token")) {
return pair.getValue();
}
}
return null;
}
17
Source : Parameters.java
with MIT License
from gflewis
with MIT License
from gflewis
public void add(NameValuePair nvp) {
super.put(nvp.getName(), nvp.getValue());
}
17
Source : GitLabOAuthAuthenticator.java
with Apache License 2.0
from finos
with Apache License 2.0
from finos
private String getAccessTokenFromLocation(String location, String expectedState) {
int redirectURILength = getAppRedirectURI().length();
char nextChar = location.charAt(redirectURILength);
if (nextChar != '#') {
throw new GitLabAuthOtherException(this.modeInfo.getMode(), "Could not get access token from redirect URI " + location + ": expected URI of the form " + getAppRedirectURI() + "#...");
}
List<NameValuePair> parameters;
try {
parameters = URLEncodedUtils.parse(location.substring(redirectURILength + 1), Charset.defaultCharset());
} catch (Exception e) {
throw new GitLabAuthOtherException(this.modeInfo.getMode(), "Could not get access token from redirect URI " + location + ": could not parse parameters from fragment", e);
}
String accessToken = null;
boolean foundState = false;
for (NameValuePair nvp : parameters) {
switch(nvp.getName()) {
case ACCESS_TOKEN_PARAM:
{
accessToken = nvp.getValue();
break;
}
case STATE_PARAM:
{
if (!Objects.equals(expectedState, nvp.getValue())) {
throw new GitLabAuthOtherException(this.modeInfo.getMode(), "Could not get access token from redirect URI " + location + ": expected state " + expectedState + ", found " + nvp.getValue());
}
foundState = true;
break;
}
case TOKEN_TYPE_PARAM:
{
if (!BEARER_TOKEN_TYPE.equalsIgnoreCase(nvp.getValue())) {
throw new GitLabAuthOtherException(this.modeInfo.getMode(), "Could not get access token from redirect URI " + location + ": expected token type " + BEARER_TOKEN_TYPE + ", found " + nvp.getValue());
}
break;
}
default:
{
// nothing for other parameters
}
}
}
if (!foundState && (expectedState != null)) {
throw new GitLabAuthOtherException(this.modeInfo.getMode(), "Could not get access token from redirect URI " + location + ": expected state " + expectedState + ", found no state");
}
if (accessToken == null) {
throw new GitLabAuthOtherException(this.modeInfo.getMode(), "Could not get access token from redirect URI " + location + ": found no access token");
}
return accessToken;
}
17
Source : RequestUtil.java
with Apache License 2.0
from doporg
with Apache License 2.0
from doporg
/**
* 发送post请求到gitlab
*
* @param path 路径
* @param userId 用户id
* @param params 参数键值对
* @return 返回状态码
*/
public static int post(String path, Long userId, List<NameValuePair> params) {
String access_token = userFeign.getUserCredentialV1ByUserId(userId, UserCredentialType.DOP_INNER_GITLAB_TOKEN).getCredential();
String url = api + path;
NameValuePair p = new BasicNameValuePair("access_token", access_token);
params.add(p);
return httpPost(url, params);
}
17
Source : RequestUtil.java
with Apache License 2.0
from doporg
with Apache License 2.0
from doporg
/**
* 发送put请求到gitlab
*
* @param path 路径
* @param userId 用户id
* @param params 参数键值对
* @return 返回状态码
*/
public static int put(String path, Long userId, List<NameValuePair> params) {
String access_token = userFeign.getUserCredentialV1ByUserId(userId, UserCredentialType.DOP_INNER_GITLAB_TOKEN).getCredential();
String url = api + path;
NameValuePair p = new BasicNameValuePair("access_token", access_token);
params.add(p);
return httpPut(url, params);
}
17
Source : UserService.java
with Apache License 2.0
from doporg
with Apache License 2.0
from doporg
/**
* 根据用户名获得用户id,然后修改用户密码
*
* @param username 用户名
* @param preplacedword 密码
*/
public void updateUserPreplacedword(String username, String preplacedword) {
String path = "/users?username=" + username;
int id = RequestUtil.getList(path, UserIdBo.clreplaced).get(0).getId();
path = "/users/" + id;
NameValuePair p1 = new BasicNameValuePair("preplacedword", preplacedword);
NameValuePair p2 = new BasicNameValuePair("skip_reconfirmation", "true");
List<NameValuePair> params = new ArrayList<>();
params.add(p1);
params.add(p2);
RequestUtil.put(path, params);
}
17
Source : FileService.java
with Apache License 2.0
from doporg
with Apache License 2.0
from doporg
/**
* 更新文件并作为一次提交
*
* @param id 项目id
* @param file_path 文件路径
* @param branch 分支
* @param content 更新的文件内容
* @param commit_message 提交信息
* @param userId 用户id
*/
public void updateFile(String id, String file_path, String branch, String content, String commit_message, Long userId) {
id = URLUtil.encodeURIComponent(id);
file_path = URLUtil.encodeURIComponent(file_path);
NameValuePair p1 = new BasicNameValuePair("branch", branch);
NameValuePair p2 = new BasicNameValuePair("content", content);
NameValuePair p3 = new BasicNameValuePair("commit_message", commit_message);
List<NameValuePair> list = new ArrayList<>();
list.add(p1);
list.add(p2);
list.add(p3);
String path = "/projects/" + id + "/repository/files/" + file_path;
RequestUtil.put(path, userId, list);
}
17
Source : AttackThread.java
with MIT License
from Contrast-Security-OSS
with MIT License
from Contrast-Security-OSS
private static List<NameValuePair> parseForm(String content) {
List<NameValuePair> fields = new ArrayList<NameValuePair>();
int formStart = content.indexOf("<form");
int formStop = content.indexOf("</form>");
if (formStart != -1 && formStop != -1) {
String formContent = content.substring(formStart, formStop);
String[] tags = formContent.split(">");
for (String tag : tags) {
tag = tag.trim();
if (tag.startsWith("<input") && tag.endsWith("checked")) {
NameValuePair nvp = parseAttribute(tag);
fields.add(nvp);
} else if (tag.startsWith("<textarea") || (tag.startsWith("<input") && !tag.contains("checkbox"))) {
NameValuePair nvp = parseAttribute(tag);
fields.add(nvp);
} else if (tag.startsWith("<option") && tag.endsWith("selected")) {
NameValuePair nvp = parseAttribute(tag + " name=\"vector\"");
fields.add(nvp);
} else if (tag.startsWith("<") && !tag.startsWith("</") && !tag.startsWith("<div") && !tag.startsWith("<label") && !tag.startsWith("<br") && !tag.startsWith("<p") && !tag.startsWith("<img") && !tag.startsWith("<h5")) {
}
}
}
return fields;
}
17
Source : ApacheCloudStackClient.java
with Apache License 2.0
from Autonomiccs
with Apache License 2.0
from Autonomiccs
/**
* This method will create a {@link BasicClientCookie} with the given {@link HeaderElement}.
* It sill set the cookie's name and value according to the {@link HeaderElement#getName()} and {@link HeaderElement#getValue()} methods.
* Moreover, it will transport every {@link HeaderElement} parameter to the cookie using the {@link BasicClientCookie#setAttribute(String, String)}.
* Additionally, it configures the cookie path ({@link BasicClientCookie#setPath(String)}) to value '/client/api' and the cookie domain using {@link #configureDomainForCookie(BasicClientCookie)} method.
*/
protected BasicClientCookie createCookieForHeaderElement(HeaderElement element) {
BasicClientCookie cookie = new BasicClientCookie(element.getName(), element.getValue());
for (NameValuePair parameter : element.getParameters()) {
cookie.setAttribute(parameter.getName(), parameter.getValue());
}
cookie.setPath("/client/api");
configureDomainForCookie(cookie);
return cookie;
}
17
Source : HttpUtil.java
with Apache License 2.0
from anylineorg
with Apache License 2.0
from anylineorg
public static HttpResult delete(CloseableHttpClient client, Map<String, String> headers, String url, String encode, NameValuePair... pairs) {
List<NameValuePair> list = new ArrayList<NameValuePair>();
if (null != pairs) {
for (NameValuePair pair : pairs) {
list.add(pair);
}
}
return delete(client, headers, url, encode, list);
}
16
Source : WXPayUtil.java
with Apache License 2.0
from yz-java
with Apache License 2.0
from yz-java
public static String getSign(List<NameValuePair> params) {
ArrayList<String> list = new ArrayList<String>();
StringBuilder sb = new StringBuilder();
for (NameValuePair pair : params) {
if (pair.getValue() != "" && !pair.getValue().equalsIgnoreCase("sign"))
list.add(pair.getName() + "=" + pair.getValue() + "&");
}
int size = list.size();
String[] arrayToSort = list.toArray(new String[size]);
Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);
for (int i = 0; i < size; i++) {
sb.append(arrayToSort[i]);
}
String result = sb.toString();
result += "key=" + KEY;
byte[] data = null;
try {
data = result.getBytes("utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String appSign = MD5Util.sign(data).toUpperCase();
return appSign;
}
See More Examples