Skip to content

Instantly share code, notes, and snippets.

View joshlong's full-sized avatar
🍃
i'm on Twitter @starbuxman

Josh Long joshlong

🍃
i'm on Twitter @starbuxman
View GitHub Profile
@joshlong
joshlong / gist:5157555
Created March 13, 2013 23:43
http message converters
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> messageConverters) {
StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
stringConverter.setWriteAcceptCharset(false);
messageConverters.add(new ByteArrayHttpMessageConverter());
messageConverters.add(stringConverter);
messageConverters.add(new ResourceHttpMessageConverter());
@joshlong
joshlong / gist:5183821
Created March 17, 2013 21:56
rest-shell 1
Joshuas-MacBook-Pro:~ jlong$ rest-shell
___ ___ __ _____ __ _ _ _ _ __
| _ \ __/' _/_ _/' _/| || | / / | \ \
| v / _|`._`. | | `._`.| >< | / / / > >
|_|_\___|___/ |_| |___/|_||_| |_/_/ /_/
1.2.0.RELEASE
Welcome to the REST shell. For assistance hit TAB or type "help".
@joshlong
joshlong / gist:5183823
Last active December 15, 2015 01:59
rest shell 2
http://localhost:8080:> baseUri http://localhost:8080/api/
Base URI set to 'http://localhost:8080/api'
@joshlong
joshlong / gist:5183825
Last active December 15, 2015 01:59
rest shell 3
http://localhost:8080/api//users:> get /users/72 --output output-for-72.txt
>> output-for-72.txt
http://localhost:8080/api//users:> ! cat output-for-72.txt
command is:cat output-for-72.txt
> GET http://localhost:8080/api//users/72
< 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: application/xml
< Transfer-Encoding: chunked
@joshlong
joshlong / gist:5183827
Last active December 15, 2015 01:59
rest shell 4
http://localhost:8080/api//users:> headers set --name Accept --value application/json
{
"Accept" : "application/json"
}
http://localhost:8080/api//users:> get /users/72
> GET http://localhost:8080/api//users/72
> Accept: application/json
< 200 OK
< Server: Apache-Coyote/1.1
@joshlong
joshlong / gist:5184448
Created March 18, 2013 01:36
rest shell /users/72
http://localhost:8080/api:> get /users/72
> GET http://localhost:8080/api//users/72
< 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: application/xml
< Transfer-Encoding: chunked
< Date: Fri, 15 Mar 2013 22:54:34 GMT
<
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><user username="[email protected]" signupDate="2013-03-12T16:07:26.993-07:00" profilePhotoImported="true" password="password" lastName="Smith" importedFromServiceProvider="false" id="72" firstName="Jane" enabled="true"/>
Joshuas-MacBook-Pro:~ jlong$ curl --header "Accept: application/json" http://localhost:8080/api/users/72
{"id":72,"customers":null,"importedFromServiceProvider":false,"firstName":"Jane","lastName":"Smith","username":"[email protected]","password":"password","profilePhotoImported":true,"profilePhotoExt":null,"enabled":true,"signupDate":1363129646993}
@joshlong
joshlong / UserService.java
Created March 23, 2013 02:01
loadUserByUsername(String username) implementation
@Override
public CrmUserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
User user = loginByUsername(username);
if (null == user)
return null;
return new CrmUserDetails(user);
}
@joshlong
joshlong / UserService.java
Last active December 15, 2015 07:49
implementation of the details objects
public static class CrmUserDetails implements UserDetails {
public static final String SCOPE_READ = "read";
public static final String SCOPE_WRITE = "write";
public static final String ROLE_USER = "ROLE_USER";
private Collection<String> roles;
private Collection<GrantedAuthority> grantedAuthorities;
@joshlong
joshlong / gist:5226788
Last active December 15, 2015 07:49
security configuration class #1
package org.springsource.examples.spring31.web.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
/**
* class for all the security aware parts of the system like form-based login and OAuth
*
* @author Josh long
*/