apigee/usergrid-stack — pull request #46 by realbeast (2013-01-29 05:56:53+00:00)
Title: fix token ttl

Token ttl does not work.

1) Set token max ttl

PUT http://localhost:8080/test-organization/test-app
{
"accesstokenttl":31536000000
}

2) Get token

GET http://localhost:8080/test-organization/test-app/token?grant_type=password&username=test@usergrid.com&password=testtest&ttl=999999999

```json
{
"access_token": "YWMtwiqLkW9JEeKBjUBhhnyiIgAAATzkJZvzqH45Os9x5sS2JhA-nHVmHkuhjZo",
"expires_in": 999999,
"user": {
"uuid": "bbdb5c67-6f48-11e2-818d-4061867ca222",
"type": "user",
"name": "test",
"created": 1360036895458,
"modified": 1360036895458,
"username": "test",
"email": "test@usergrid.com",
"activated": true,
"picture": "http://www.gravatar.com/avatar/40943d200a2378714034cdc1478241f8"
}
}
```

However, TokenServiceImpl.getUUIDForToken method check only token type.

```java
if ((getExpirationForTokenType(tokenCategory) > 0)
&& (currentTimeMillis() > (timestamp + getExpirationForTokenType(tokenCategory)))) {
throw new ExpiredTokenException("Token expired "
+ (currentTimeMillis() - (timestamp + getExpirationForTokenType(tokenCategory)))
+ " millisecons ago.");
}
```

So, I fixed.