public Object parse(StaplerRequest request, ContextInPath contextInPath, Class type, String parameterName) throws ServletException { String $provider = request.getParameter("$provider"); String $token = request.getParameter("$token"); if (StringUtils.isNotBlank($provider) && StringUtils.isNotBlank($token)) { ModelObject context = CredentialsDescriptor.lookupContext($provider, $token); if (type.isInstance(context)) { return type.cast(context); } } return CredentialsDescriptor.findContextInPath(request, type); } }
public Object parse(StaplerRequest request, ContextInPath contextInPath, Class type, String parameterName) throws ServletException { String $provider = request.getParameter("$provider"); String $token = request.getParameter("$token"); if (StringUtils.isNotBlank($provider) && StringUtils.isNotBlank($token)) { ModelObject context = CredentialsDescriptor.lookupContext($provider, $token); if (type.isInstance(context)) { return type.cast(context); } } return CredentialsDescriptor.findContextInPath(request, type); } }
/** * Attempts to resolve the credentials context from the {@link Stapler#getCurrentRequest()} (includes special * handling of the HTTP Referer to enable resolution from AJAX requests). * * @param type the type of context. * @param <T> the type of context. * @return the context from the request * @since 2.1.5 */ @CheckForNull public static <T extends ModelObject> T findContextInPath(@NonNull Class<T> type) { return findContextInPath(Stapler.getCurrentRequest(), type); }
/** * Attempts to resolve the credentials context from the {@link Stapler#getCurrentRequest()} (includes special * handling of the HTTP Referer to enable resolution from AJAX requests). * * @param type the type of context. * @param <T> the type of context. * @return the context from the request * @since 2.1.5 */ @CheckForNull public static <T extends ModelObject> T findContextInPath(@NonNull Class<T> type) { return findContextInPath(Stapler.getCurrentRequest(), type); }