public RequestParametersForm(Form form) { super(); for (String key : form.getNames()) { // For each parameter in the form, add the parameter name and value // to the Map<String, Object>. keyValuePairs.put(key, form.getFirst(key).getValue()); } }
@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); }
protected boolean isLocal( Request request, String resourceStorePath ) { // check do we need local only access boolean isLocal = request.getResourceRef().getQueryAsForm().getFirst( IS_LOCAL_PARAMETER ) != null; if ( resourceStorePath != null ) { // overriding isLocal is we know it will be a collection isLocal = isLocal || resourceStorePath.endsWith( RepositoryItemUid.PATH_SEPARATOR ); } return isLocal; }
final Parameter fullHtml = queryParams.getFirst("fullhtml", true);
protected boolean isLocal(Request request, String resourceStorePath) { // check do we need local only access boolean isLocal = request.getResourceRef().getQueryAsForm().getFirst(IS_LOCAL_PARAMETER) != null; if (resourceStorePath != null) { // overriding isLocal is we know it will be a collection isLocal = isLocal || resourceStorePath.endsWith(RepositoryItemUid.PATH_SEPARATOR); } return isLocal; }
protected boolean isDescribe( Request request ) { // check do we need describe return request.getResourceRef().getQueryAsForm().getFirst( IS_DESCRIBE_PARAMETER ) != null; }
private static double parseDouble(Form form, String key) throws RestletException { String value = form.getFirst(key).getValue(); if (value == null || value.length() == 0) throw new RestletException("Missing value for " + key, Status.CLIENT_ERROR_BAD_REQUEST); try { return Double.parseDouble(value); } catch (NumberFormatException nfe) { throw new RestletException("Value for " + key + " is not a double", Status.CLIENT_ERROR_BAD_REQUEST); } }
protected boolean isRemote( Request request, String resourceStorePath ) { // check do we need remote only access boolean isRemote = request.getResourceRef().getQueryAsForm().getFirst( IS_REMOTE_PARAMETER ) != null; return isRemote; }
protected boolean isDescribe(Request request) { // check do we need describe return request.getResourceRef().getQueryAsForm().getFirst(IS_DESCRIBE_PARAMETER) != null; }
protected boolean isRemote(Request request, String resourceStorePath) { // check do we need remote only access return request.getResourceRef().getQueryAsForm().getFirst(IS_REMOTE_PARAMETER) != null; }
protected boolean asExpired(Request request, String resourceStorePath) { // check do we need expired access return request.getResourceRef().getQueryAsForm().getFirst(AS_EXPIRED_PARAMETER) != null; }
private char[] getPassword( Representation entity ) { char[] password = "".toCharArray(); Form form = new Form(); FormUtils.parse( form, entity ); Parameter passwordParam = form.getFirst( "password" ); if ( passwordParam != null ) { if ( !Strings.isEmpty( passwordParam.getValue() ) ) { password = passwordParam.getValue().toCharArray(); } } return password; }
protected boolean getQSBoolean(String name) { Parameter param = getRequest().getResourceRef().getQueryAsForm().getFirst(name); return param != null && (param.getValue() == null || param.getValue().equalsIgnoreCase("true")); }
public void doPost(Request req, Response resp) throws RestletException { Form form = req.getEntityAsForm(); if (form == null || form.getFirst("reload_configuration") == null) { throw new RestletException( "Unknown or malformed request. Please try again, somtimes the form "
@Override public EntityReference map( AssociationDescriptor associationDescriptor ) { Parameter param = queryAsForm.getFirst( associationDescriptor.qualifiedName().name() ); if( param == null ) { param = entityAsForm.getFirst( associationDescriptor.qualifiedName().name() ); } if( param != null ) { return EntityReference.parseEntityReference( param.getValue() ); } else { return null; } } },
@Override public Object map( PropertyDescriptor propertyDescriptor ) { Parameter param = queryAsForm.getFirst( propertyDescriptor.qualifiedName().name() ); if( param == null ) { param = entityAsForm.getFirst( propertyDescriptor.qualifiedName().name() ); } if( param != null ) { String value = param.getValue(); if( value != null ) { try { return valueDeserializer.deserialize( propertyDescriptor.valueType(), value ); } catch( ValueSerializationException e ) { throw new IllegalArgumentException( "Query parameter has invalid JSON format", e ); } } } return null; } },
/** * Processes the login request. * * @param request * The current request. * @param response * The current response. */ protected void login(final Request request, final Response response) { // Login detected final Form form = new Form(request.getEntity()); final Parameter identifier = form.getFirst(this.getIdentifierFormName()); final Parameter secret = form.getFirst(this.getSecretFormName()); // Set credentials final ChallengeResponse cr = new ChallengeResponse(this.getScheme(), identifier != null ? identifier.getValue() : null, secret != null ? secret.getValue() : null); request.setChallengeResponse(cr); this.log.info("calling attemptRedirect after login"); // Attempt to redirect this.attemptRedirect(request, response, form); }
public String getRestRepoRemoteStatus( ProxyRepository repository, Request request, Response response ) throws ResourceException { Form form = request.getResourceRef().getQueryAsForm(); boolean forceCheck = form.getFirst( "forceCheck" ) != null; RemoteStatus rs = repository.getRemoteStatus( new ResourceStoreRequest( RepositoryItemUid.PATH_ROOT ), forceCheck ); if ( RemoteStatus.UNKNOWN.equals( rs ) ) { // set status to ACCEPTED, since we have incomplete info response.setStatus( Status.SUCCESS_ACCEPTED ); } return rs == null ? null : rs.toString(); }
public String getRestRepoRemoteStatus(ProxyRepository repository, Request request, Response response) throws ResourceException { Form form = request.getResourceRef().getQueryAsForm(); boolean forceCheck = form.getFirst("forceCheck") != null; RemoteStatus rs = repository.getRemoteStatus(new ResourceStoreRequest(RepositoryItemUid.PATH_ROOT), forceCheck); if (RemoteStatus.UNKNOWN.equals(rs)) { // set status to ACCEPTED, since we have incomplete info response.setStatus(Status.SUCCESS_ACCEPTED); } return rs == null ? null : rs.toString() + (rs.getReason() == null ? "" : ":" + rs.getReason()); }