/** * Returns the first parameter found with the given name. * * @param name * The parameter name (case sensitive). * @return The first parameter found with the given name. */ public E getFirst(String name) { return getFirst(name, false); }
/** * Returns the first parameter found with the given name. * * @param name * The parameter name (case sensitive). * @return The first parameter found with the given name. */ public T getFirst(String name) { return getFirst(name, false); }
/** * Returns the first parameter found with the given name. * * @param name * The parameter name (case sensitive). * @return The first parameter found with the given name. */ public T getFirst(String name) { return getFirst(name, false); }
public static Parameter getParameter(Context context, String name) { Series<Parameter> parameters = getParameters(context); if (parameters == null) { return null; } return parameters.getFirst(name); }
/** * Returns the first parameter found in the current context (entity, query, * headers, etc) with the given name. * * @param name * The parameter name. * @return The first parameter found with the given name. */ protected NamedValue<String> getParameter(String name) { NamedValue<String> result = null; Series<? extends NamedValue<String>> set = getParameters(name); if (set != null) { result = set.getFirst(name); } return result; }
/** * Returns the value of the first parameter found with the given name. * * @param name * The parameter name. * @param ignoreCase * Indicates if the name comparison is case sensitive. * @param defaultValue * The default value to return if no matching parameter found. * @return The value of the first parameter found with the given name or the * default value. */ public String getFirstValue(String name, boolean ignoreCase, String defaultValue) { String result = defaultValue; final Parameter param = getFirst(name, ignoreCase); if (param != null) { result = param.getValue(); } return result; }
public Object getFirst(String headerName) { if (this.jaxRsRespHeaders != null) { Object rt = this.jaxRsRespHeaders.getFirst(headerName); if (rt != null) { return rt; } } Series<Header> headers = getHeaders(); if (headers != null) { Header first = headers.getFirst(headerName, true); if (first == null) { return null; } return first.getValue(); } return null; }
/** * Returns the value of the first parameter found with the given name. * * @param name * The parameter name. * @param ignoreCase * Indicates if the name comparison is case sensitive. * @param defaultValue * The default value to return if no matching parameter found or * if the parameter has a null value. * @return The value of the first parameter found with the given name or the * default value. */ public String getFirstValue(String name, boolean ignoreCase, String defaultValue) { String result = defaultValue; NamedValue<String> param = getFirst(name, ignoreCase); if ((param != null) && (param.getValue() != null)) { result = param.getValue(); } return result; }
/** * Returns the value of the first parameter found with the given name. * * @param name * The parameter name. * @param ignoreCase * Indicates if the name comparison is case sensitive. * @param defaultValue * The default value to return if no matching parameter found or * if the parameter has a null value. * @return The value of the first parameter found with the given name or the * default value. */ public String getFirstValue(String name, boolean ignoreCase, String defaultValue) { String result = defaultValue; NamedValue<String> param = getFirst(name, ignoreCase); if ((param != null) && (param.getValue() != null)) { result = param.getValue(); } return result; }
/** * @param params * @param paramName * @return * @throws ConvertQueryParamException */ Object getParamValue(final Series<Parameter> params, final String paramName) throws ConvertParameterException { Series<Parameter> parameters = params.subList(paramName); if (this.collType == null) { // no collection parameter Parameter firstFormParam = params.getFirst(paramName); String queryParamValue = WrapperUtil.getValue(firstFormParam); return convertParamValue(queryParamValue); } NamedValuesIter queryParamValueIter; queryParamValueIter = new NamedValuesIter(parameters); return convertParamValues(queryParamValueIter); } }
/** * Restores credentials from the cookie named {@link #getCookieName()} if available. The usual * processing is the followed. */ @Override protected boolean authenticate(final Request request, final Response response) { // Restore credentials from the cookie final Cookie credentialsCookie = request.getCookies().getFirst(this.getCookieName()); if(credentialsCookie != null) { ChallengeResponse credentials = this.parseCredentials(credentialsCookie.getValue()); if(credentials == null) { response.getCookieSettings().removeAll(this.getCookieName()); } else { request.setChallengeResponse(credentials); } } this.log.debug("Calling super.authenticate"); return super.authenticate(request, response); }
Parameter param = getParameters().get(i); Parameter includedParam = includedMediaType .getParameters().getFirst(param.getName());
if (this.collType == null) { // no collection parameter String firstCookieValue = WrapperUtil.getValue(cookies .getFirst(cookieName)); return convertParamValue(firstCookieValue);
@Override public Object getParamValue() { Series<Header> httpHeaders = Util.getHttpHeaders(this.tlContext .get().getRequest()); String headerName = this.headerParam.value(); try { if (this.collType == null) { // no collection parameter final String firstHeader = WrapperUtil.getValue(httpHeaders .getFirst(headerName, true)); return convertParamValue(firstHeader); } return convertParamValues(new NamedValuesIter( httpHeaders.subList(headerName, true))); } catch (ConvertParameterException e) { throw new ConvertHeaderParamException(e); } } }
@Override protected void afterHandle(Request request, Response response) { super.afterHandle(request, response); Cookie cookie = request.getCookies().getFirst("Credentials"); if (request.getClientInfo().isAuthenticated() && (cookie == null)) { String identifier = request.getChallengeResponse().getIdentifier(); String secret = new String(request.getChallengeResponse() .getSecret()); CookieSetting cookieSetting = new CookieSetting("Credentials", identifier + "=" + secret); cookieSetting.setAccessRestricted(true); cookieSetting.setPath("/"); cookieSetting.setComment("Unsecured cookie based authentication"); cookieSetting.setMaxAge(30); response.getCookieSettings().add(cookieSetting); } }
@Override protected void afterHandle(Request request, Response response) { super.afterHandle(request, response); Cookie cookie = request.getCookies().getFirst("Credentials"); if (request.getClientInfo().isAuthenticated() && (cookie == null)) { String identifier = request.getChallengeResponse().getIdentifier(); String secret = new String(request.getChallengeResponse() .getSecret()); CookieSetting cookieSetting = new CookieSetting("Credentials", identifier + "=" + secret); cookieSetting.setAccessRestricted(true); cookieSetting.setPath("/"); cookieSetting.setComment("Unsecured cookie based authentication"); cookieSetting.setMaxAge(30); response.getCookieSettings().add(cookieSetting); } }
@Override protected int beforeHandle(Request request, Response response) { Cookie cookie = request.getCookies().getFirst("Credentials"); if (cookie != null) { // Extract the challenge response from the cookie String[] credentials = cookie.getValue().split("="); if (credentials.length == 2) { String identifier = credentials[0]; String secret = credentials[1]; request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_COOKIE, identifier, secret)); } } else if (Method.POST.equals(request.getMethod()) && request.getResourceRef().getQueryAsForm().getFirst("login") != null) { // Intercepting a login form Form credentials = new Form(request.getEntity()); String identifier = credentials.getFirstValue("identifier"); String secret = credentials.getFirstValue("secret"); request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_COOKIE, identifier, secret)); // Continue call processing to return the target representation if // authentication is successful or a new login page request.setMethod(Method.GET); } return super.beforeHandle(request, response); }
@Override protected int beforeHandle(Request request, Response response) { Cookie cookie = request.getCookies().getFirst("Credentials"); if (cookie != null) { // Extract the challenge response from the cookie String[] credentials = cookie.getValue().split("="); if (credentials.length == 2) { String identifier = credentials[0]; String secret = credentials[1]; request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_COOKIE, identifier, secret)); } } else if (Method.POST.equals(request.getMethod()) && request.getResourceRef().getQueryAsForm().getFirst("login") != null) { // Intercepting a login form Form credentials = new Form(request.getEntity()); String identifier = credentials.getFirstValue("identifier"); String secret = credentials.getFirstValue("secret"); request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_COOKIE, identifier, secret)); // Continue call processing to return the target representation if // authentication is successful or a new login page request.setMethod(Method.GET); } return super.beforeHandle(request, response); }
CookieSetting credentialsCookie = response.getCookieSettings().getFirst(this.getCookieName());
if (oHeaders != null) { final Series<Parameter> headers = (Series<Parameter>) oHeaders; if (headers.getFirst("Content-Range", true) != null) { getResponse() .setStatus(