Refactoring part 2

pull/210/head
Amanda Anganes 2012-09-18 14:36:27 -04:00
parent c40efda6b5
commit dd2abd94d1
16 changed files with 12 additions and 584 deletions

View File

@ -1,60 +0,0 @@
/*******************************************************************************
* Copyright 2012 The MITRE Corporation
*
* 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.mitre.openid.connect.service;
import org.mitre.openid.connect.model.Address;
/**
* Interface for Address service
*
* @author Michael Joseph Walsh
*
*/
public interface AddressService {
/**
* Save an Address
*
* @param address
* the Address to be saved
*/
public void save(Address address);
/**
* Get Address for id
*
* @param id
* id for Address
* @return Address for id, or null
*/
public Address getById(Long id);
/**
* Remove the Address
*
* @param address
* the Address to remove
*/
public void remove(Address address);
/**
* Remove the Address
*
* @param id
* id for Address to remove
*/
public void removeById(Long id);
}

View File

@ -1,78 +0,0 @@
/*******************************************************************************
* Copyright 2012 The MITRE Corporation
*
* 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.mitre.openid.connect.service;
import java.util.Collection;
import java.util.Date;
import org.mitre.openid.connect.model.Event;
/**
* Interface for Event service
*
* @author Michael Joseph Walsh
*
*/
public interface EventService {
/**
* Returns the Events for a given Date range
*
* @param start
* the Date to start from
* @param end
* the Date to end at
* @param startChunk
* the start chuck of a list you desire
* @param chunkSize
* the size of the chunk you desire
*
* @return a Collection of Events
*/
public Collection<Event> getEventsDuringPeriod(Date start, Date end, int startChunk, int chunkSize);
/**
* Get Event by id
*
* @param id
* id for Event
* @return Event for id, or null
*/
public Event getById(Long id);
/**
* Remove Event
*
* @param event
* Event to remove
*/
public void remove(Event event);
/**
* Remove Event for id
*
* @param id
* id for Event to remove
*/
public void removeById(Long id);
/**
* Save Event
*
* @param event
* Event to be saved
*/
public void save(Event event);
}

View File

@ -1,60 +0,0 @@
/*******************************************************************************
* Copyright 2012 The MITRE Corporation
*
* 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.mitre.openid.connect.service;
import org.mitre.openid.connect.model.IdTokenClaims;
/**
* Interface for IdTokenClaims service
*
* @author Michael Joseph Walsh
*
*/
public interface IdTokenClaimsService {
/**
* Save an IdTokenClaims
*
* @param address
* the Address to be saved
*/
public void save(IdTokenClaims idTokenClaims);
/**
* Get IdTokenClaims for id
*
* @param id
* id for IdTokenClaims
* @return IdTokenClaims for id, or null
*/
public IdTokenClaims getById(Long id);
/**
* Remove the IdTokenClaims
*
* @param idTokenClaims
* the IdTokenClaims to remove
*/
public void remove(IdTokenClaims idTokenClaims);
/**
* Remove the IdTokenClaims
*
* @param id
* id for IdTokenClaims to remove
*/
public void removeById(Long id);
}

View File

@ -1,60 +0,0 @@
/*******************************************************************************
* Copyright 2012 The MITRE Corporation
*
* 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.mitre.openid.connect.service;
import org.mitre.openid.connect.model.IdToken;
/**
* Interface for IdToken service
*
* @author Michael Joseph Walsh
*
*/
public interface IdTokenService {
/**
* Save an IdToken
*
* @param idToken
* the IdToken to be saved
*/
public void save(IdToken idToken);
/**
* Get IdToken for id
*
* @param id
* id for IdToken
* @return IdToken for id, or null
*/
public IdToken getById(Long id);
/**
* Remove the IdToken
*
* @param idToken
* the IdToken to remove
*/
public void remove(IdToken idToken);
/**
* Remove the IdToken
*
* @param id
* id for IdToken to remove
*/
public void removeById(Long id);
}

View File

@ -41,7 +41,6 @@ public interface UserInfoService {
* @return UserInfo for user id, or null
*/
public UserInfo getByUserId(String userId);
/**
* Remove the UserInfo
*

View File

@ -1,73 +0,0 @@
/*******************************************************************************
* Copyright 2012 The MITRE Corporation
*
* 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.mitre.openid.connect.service.impl;
import org.mitre.openid.connect.model.Address;
import org.mitre.openid.connect.repository.AddressRepository;
import org.mitre.openid.connect.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Implementation of the AddressService
*
* @author Michael Joseph Walsh
*
*/
@Service
@Transactional
public class AddressServiceImpl implements AddressService {
@Autowired
private AddressRepository addressRepository;
/**
* Default constructor
*/
public AddressServiceImpl() {
}
/**
* Constructor for use in test harnesses.
*
* @param repository
*/
public AddressServiceImpl(AddressRepository addressRepository) {
this.addressRepository = addressRepository;
}
@Override
public void save(Address address) {
this.addressRepository.save(address);
}
@Override
public Address getById(Long id) {
return addressRepository.getById(id);
}
@Override
public void remove(Address address) {
this.addressRepository.remove(address);
}
@Override
public void removeById(Long id) {
this.addressRepository.removeById(id);
}
}

View File

@ -35,7 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
*/
@Service
@Transactional
public class ApprovedSiteServiceImpl implements ApprovedSiteService {
public class DefaultApprovedSiteService implements ApprovedSiteService {
@Autowired
private ApprovedSiteRepository approvedSiteRepository;
@ -43,7 +43,7 @@ public class ApprovedSiteServiceImpl implements ApprovedSiteService {
/**
* Default constructor
*/
public ApprovedSiteServiceImpl() {
public DefaultApprovedSiteService() {
}
@ -52,7 +52,7 @@ public class ApprovedSiteServiceImpl implements ApprovedSiteService {
*
* @param repository
*/
public ApprovedSiteServiceImpl(ApprovedSiteRepository approvedSiteRepository) {
public DefaultApprovedSiteService(ApprovedSiteRepository approvedSiteRepository) {
this.approvedSiteRepository = approvedSiteRepository;
}

View File

@ -30,7 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
*/
@Service
@Transactional
public class UserInfoServiceImpl implements UserInfoService {
public class DefaultUserInfoService implements UserInfoService {
@Autowired
private UserInfoRepository userInfoRepository;
@ -38,7 +38,7 @@ public class UserInfoServiceImpl implements UserInfoService {
/**
* Default constructor
*/
public UserInfoServiceImpl() {
public DefaultUserInfoService() {
}
@ -47,7 +47,7 @@ public class UserInfoServiceImpl implements UserInfoService {
*
* @param repository
*/
public UserInfoServiceImpl(UserInfoRepository userInfoRepository) {
public DefaultUserInfoService(UserInfoRepository userInfoRepository) {
this.userInfoRepository = userInfoRepository;
}

View File

@ -6,9 +6,7 @@ import java.util.List;
import org.mitre.openid.connect.model.UserInfo;
import org.mitre.openid.connect.repository.UserInfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.GrantedAuthorityImpl;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
@ -23,7 +21,7 @@ import org.springframework.stereotype.Service;
*
*/
@Service("userInfoUserDetailsService")
public class UserInfoUserDetailsService implements UserDetailsService {
public class DefaultUserInfoUserDetailsService implements UserDetailsService {
@Autowired
UserInfoRepository repository;

View File

@ -32,7 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
*/
@Service
@Transactional
public class WhitelistedSiteServiceImpl implements WhitelistedSiteService {
public class DefaultWhitelistedSiteService implements WhitelistedSiteService {
@Autowired
private WhitelistedSiteRepository repository;
@ -40,7 +40,7 @@ public class WhitelistedSiteServiceImpl implements WhitelistedSiteService {
/**
* Default constructor
*/
public WhitelistedSiteServiceImpl() {
public DefaultWhitelistedSiteService() {
}
@ -49,7 +49,7 @@ public class WhitelistedSiteServiceImpl implements WhitelistedSiteService {
*
* @param repository
*/
public WhitelistedSiteServiceImpl(WhitelistedSiteRepository whitelistedSiteRepository) {
public DefaultWhitelistedSiteService(WhitelistedSiteRepository whitelistedSiteRepository) {
this.repository = whitelistedSiteRepository;
}

View File

@ -1,84 +0,0 @@
/*******************************************************************************
* Copyright 2012 The MITRE Corporation
*
* 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.mitre.openid.connect.service.impl;
import java.util.Collection;
import java.util.Date;
import org.mitre.openid.connect.model.Event;
import org.mitre.openid.connect.repository.EventRepository;
import org.mitre.openid.connect.service.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Implementation of the EventService
*
* @author Michael Joseph Walsh
*
*/
@Service
@Transactional
public class EventServiceImpl implements EventService {
@Autowired
private EventRepository eventRepository;
/**
* Default constructor
*/
public EventServiceImpl() {
}
/**
* Constructor for use in test harnesses.
*
* @param repository
*/
public EventServiceImpl(EventRepository eventRepository) {
this.eventRepository = eventRepository;
}
@Override
public Collection<Event> getEventsDuringPeriod(Date start, Date end,
int startChunk, int chunkSize) {
return eventRepository.getEventsDuringPeriod(start, end, startChunk, chunkSize);
}
@Override
public Event getById(Long id) {
return eventRepository.getById(id);
}
@Override
public void remove(Event event) {
eventRepository.remove(event);
}
@Override
public void removeById(Long id) {
eventRepository.removeById(id);
}
@Override
public void save(Event event) {
eventRepository.save(event);
}
}

View File

@ -1,74 +0,0 @@
/*******************************************************************************
* Copyright 2012 The MITRE Corporation
*
* 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.mitre.openid.connect.service.impl;
import org.mitre.openid.connect.model.IdTokenClaims;
import org.mitre.openid.connect.repository.IdTokenClaimsRepository;
import org.mitre.openid.connect.service.IdTokenClaimsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Implementation of the IdTokenClaimsService
*
* @author Michael Joseph Walsh
*
*/
@Service
@Transactional
public class IdTokenClaimsServiceImpl implements IdTokenClaimsService {
@Autowired
private IdTokenClaimsRepository idTokenClaimsRepository;
/**
* Default constructor
*/
public IdTokenClaimsServiceImpl() {
}
/**
* Constructor for use in test harnesses.
*
* @param repository
*/
public IdTokenClaimsServiceImpl(IdTokenClaimsRepository idTokenClaimsRepository) {
this.idTokenClaimsRepository = idTokenClaimsRepository;
}
@Override
public void save(IdTokenClaims idTokenClaims) {
idTokenClaimsRepository.save(idTokenClaims);
}
@Override
public IdTokenClaims getById(Long id) {
return idTokenClaimsRepository.getById(id);
}
@Override
public void remove(IdTokenClaims idTokenClaims) {
idTokenClaimsRepository.remove(idTokenClaims);
}
@Override
public void removeById(Long id) {
idTokenClaimsRepository.removeById(id);
}
}

View File

@ -1,74 +0,0 @@
/*******************************************************************************
* Copyright 2012 The MITRE Corporation
*
* 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.mitre.openid.connect.service.impl;
import org.mitre.openid.connect.model.IdToken;
import org.mitre.openid.connect.repository.IdTokenRepository;
import org.mitre.openid.connect.service.IdTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Implementation of the IdTokenService
*
* @author Michael Joseph Walsh
*
*/
@Service
@Transactional
public class IdTokenServiceImpl implements IdTokenService {
@Autowired
private IdTokenRepository idTokenRepository;
/**
* Default constructor
*/
public IdTokenServiceImpl() {
}
/**
* Constructor for use in test harnesses.
*
* @param repository
*/
public IdTokenServiceImpl(IdTokenRepository idTokenRepository) {
this.idTokenRepository = idTokenRepository;
}
@Override
public void save(IdToken idToken) {
idTokenRepository.save(idToken);
}
@Override
public IdToken getById(Long id) {
return idTokenRepository.getById(id);
}
@Override
public void remove(IdToken idToken) {
idTokenRepository.remove(idToken);
}
@Override
public void removeById(Long id) {
idTokenRepository.removeById(id);
}
}

View File

@ -28,7 +28,7 @@ import com.google.gson.JsonParser;
@Controller
@RequestMapping("/api/approved")
@PreAuthorize("hasRole('ROLE_USER')")
public class ApprovedSiteApi {
public class ApprovedSiteAPI {
@Autowired
private ApprovedSiteService approvedSiteService;

View File

@ -18,14 +18,12 @@ package org.mitre.openid.connect.web;
import java.security.Principal;
import java.util.Map;
import org.mitre.oauth2.service.OAuth2TokenEntityService;
import org.mitre.openid.connect.exception.UnknownUserInfoSchemaException;
import org.mitre.openid.connect.exception.UserNotFoundException;
import org.mitre.openid.connect.model.UserInfo;
import org.mitre.openid.connect.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.oauth2.common.exceptions.InvalidScopeException;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.stereotype.Controller;
@ -45,9 +43,6 @@ import com.google.common.collect.ImmutableMap;
@Controller
public class UserInfoEndpoint {
@Autowired
private OAuth2TokenEntityService tokenService;
@Autowired
private UserInfoService userInfoService;

View File

@ -6,7 +6,6 @@ package org.mitre.openid.connect.web;
import java.security.Principal;
import java.util.Collection;
import org.mitre.oauth2.model.ClientDetailsEntity;
import org.mitre.openid.connect.model.WhitelistedSite;
import org.mitre.openid.connect.service.WhitelistedSiteService;
import org.springframework.beans.factory.annotation.Autowired;
@ -30,7 +29,7 @@ import com.google.gson.JsonParser;
@Controller
@RequestMapping("/api/whitelist")
@PreAuthorize("hasRole('ROLE_ADMIN')")
public class WhitelistApi {
public class WhitelistAPI {
@Autowired
private WhitelistedSiteService whitelistService;