Commit ba61c42a authored by Matija Obreza's avatar Matija Obreza
Browse files

Start on JPA token store

parent c84e52e8
/**
* Copyright 2013 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.genesys2.server.service.impl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.genesys2.server.model.impl.User;
import org.genesys2.server.model.oauth.OAuthAccessToken;
import org.genesys2.server.model.oauth.OAuthClientDetails;
import org.genesys2.server.persistence.domain.OAuthAccessTokenPersistence;
import org.genesys2.server.persistence.domain.OAuthClientDetailsPersistence;
import org.genesys2.server.service.OAuth2ClientDetailsService;
import org.genesys2.server.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import org.springframework.security.oauth2.common.exceptions.InvalidClientException;
import org.springframework.security.oauth2.provider.ClientAlreadyExistsException;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.NoSuchClientException;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
//@Service("tokenStore")
//@Transactional
public class OAuth2TokenStoreImpl implements TokenStore {
private static final Log logger = LogFactory.getLog(OAuth2TokenStoreImpl.class);
@Autowired
private OAuthClientDetailsPersistence clientDetailsPersistence;
@Autowired
private OAuthAccessTokenPersistence accessTokenPersistence;
@Autowired
private UserService userService;
private PasswordEncoder passwordEncoder = NoOpPasswordEncoder.getInstance();
/**
* @param passwordEncoder
* the password encoder to set
*/
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}
@Override
public Collection<OAuth2AccessToken> findTokensByClientId(String clientId) {
// return accessTokenPersistence.findByClientId(clientId)
return null;
}
@Override
public Collection<OAuth2AccessToken> findTokensByUserName(String username) {
User user = userService.getUserByEmail(username);
return accessTokenPersistence.findByUser(user);
}
@Override
public OAuth2AccessToken getAccessToken(OAuth2Authentication arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public OAuth2AccessToken readAccessToken(String arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public OAuth2Authentication readAuthentication(OAuth2AccessToken arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public OAuth2Authentication readAuthentication(String arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public OAuth2Authentication readAuthenticationForRefreshToken(OAuth2RefreshToken arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public OAuth2RefreshToken readRefreshToken(String arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void removeAccessToken(OAuth2AccessToken arg0) {
// TODO Auto-generated method stub
}
@Override
public void removeAccessTokenUsingRefreshToken(OAuth2RefreshToken arg0) {
// TODO Auto-generated method stub
}
@Override
public void removeRefreshToken(OAuth2RefreshToken arg0) {
// TODO Auto-generated method stub
}
@Override
public void storeAccessToken(OAuth2AccessToken arg0, OAuth2Authentication arg1) {
// TODO Auto-generated method stub
}
@Override
public void storeRefreshToken(OAuth2RefreshToken arg0, OAuth2Authentication arg1) {
// TODO Auto-generated method stub
}
}
......@@ -31,3 +31,4 @@ log4j.rootLogger=info, stdout
#log4j.category.org.genesys2=debug
#log4j.category.org.hibernate.search=debug
log4j.category.org.apache.tomcat.jdbc.pool=debug
log4j.category.org.springframework.security.oauth2=trace
......@@ -20,12 +20,12 @@
#db.username = sa
#db.password =
db.url=jdbc:mysql://127.0.0.1/pgrsys_genesys?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
db.url=jdbc:mysql://127.0.0.1/oauth?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
db.driverClassName = com.mysql.jdbc.Driver
db.username = root
db.password =
db.showSql=false
db.hbm2ddl=do-nothing
db.showSql=true
db.hbm2ddl=update
c3p0.acquireIncrement=1
c3p0.minPoolSize=5
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment