Commit deb48f1a authored by Matija Obreza's avatar Matija Obreza

Removed deprecated methods

parent e17d7588
......@@ -50,19 +50,6 @@ public interface OAuthClientDetailsService extends ClientDetailsService {
*/
OAuthClient getClient(String clientId);
/**
* Adds the client.
*
* @param title the title
* @param description the description
* @param redirectUris the redirect uris
* @param accessTokenValiditySeconds the access token validity seconds
* @param refreshTokenValiditySeconds the refresh token validity seconds
* @return the OAuth client
* @deprecated Use {@link #addClient(OAuthClient)} instead
*/
OAuthClient addClient(String title, String description, String redirectUris, Integer accessTokenValiditySeconds, Integer refreshTokenValiditySeconds);
/**
* Register a new OAuth client.
*
......
......@@ -134,36 +134,6 @@ public class OAuthServiceImpl implements OAuthClientDetailsService {
return client;
}
/*
* (non-Javadoc)
* @see
* org.genesys.blocks.oauth.service.OAuthClientDetailsService#addClient(java.
* lang.String, java.lang.String, java.lang.String, java.lang.Integer,
* java.lang.Integer)
*/
@Override
@Transactional
public OAuthClient addClient(final String title, final String description, final String redirectUris, final Integer accessTokenValidity, final Integer refreshTokenValidity) {
final String clientId = RandomStringUtils.randomAlphanumeric(5) + "." + RandomStringUtils.randomAlphanumeric(20) + "@" + hostname;
final String clientSecret = RandomStringUtils.randomAlphanumeric(32);
final OAuthClient client = new OAuthClient();
client.setTitle(title);
client.setDescription(description);
client.setRedirect(StringUtils.defaultIfBlank(redirectUris, null));
client.setAccessTokenValidity(accessTokenValidity);
client.setRefreshTokenValidity(refreshTokenValidity);
client.setClientId(clientId);
client.setClientSecret(passwordEncoder.encode(clientSecret));
client.getScope().add("read");
client.getScope().add("write");
client.getAuthorizedGrantTypes().add("authorization_code");
client.getAuthorizedGrantTypes().add("refresh_token");
client.getRoles().add(OAuthRole.CLIENT);
return oauthClientRepository.save(client);
}
/*
* (non-Javadoc)
* @see
......
......@@ -56,7 +56,7 @@ public interface BasicUserService<R extends GrantedAuthority, T extends BasicUse
T getUserByEmail(String email);
/**
* Create a new user account with {@link #getDefaultUserRole()} assigned.
* Create a new user account.
*
* @param email unique email address
* @param fullName Full name
......@@ -70,8 +70,8 @@ public interface BasicUserService<R extends GrantedAuthority, T extends BasicUse
T createUser(String email, String fullName, String password, BasicUser.AccountType accountType) throws NotUniqueUserException, PasswordPolicyException, UserException;
/**
* Grant specified roles to user. The {@link #getDefaultUserRole()} will be
* added if missing.
* Grant specified roles to user. The {@link #getDefaultUserRoles()} will not be
* persisted.
*
* @param user the user
* @param roles the roles
......@@ -133,14 +133,6 @@ public interface BasicUserService<R extends GrantedAuthority, T extends BasicUse
*/
List<R> listAvailableRoles();
/**
* Gets the default user role.
*
* @return the default user role
* @deprecated Use {@link #getDefaultUserRoles()}
*/
R getDefaultUserRole();
/**
* Get default roles assigned to users. These are transient and not persisted to the database.
*
......
......@@ -123,14 +123,6 @@ public abstract class BasicUserServiceImpl<R extends GrantedAuthority, T extends
this.accountLockoutTime = accountLockoutTime;
}
/*
* (non-Javadoc)
* @see
* org.genesys.blocks.security.service.BasicUserService#getDefaultUserRole()
*/
@Override
public abstract R getDefaultUserRole();
/* (non-Javadoc)
* @see org.genesys.blocks.security.service.BasicUserService#getDefaultUserRoles()
*/
......
......@@ -151,16 +151,10 @@ public class ApplicationConfig {
user.setEmail(email);
user.setFullName(fullName);
user.setAccountType(accountType);
user.setRoles(Sets.newHashSet(getDefaultUserRole()));
setPassword(user, password);
return testUserRepository.save(user);
return deepLoad(testUserRepository.save(user));
}
@Override
public UserRole getDefaultUserRole() {
return UserRole.USER;
}
@Override
public Collection<UserRole> getDefaultUserRoles() {
return Sets.newHashSet(UserRole.USER, UserRole.EVERYONE);
......
......@@ -140,8 +140,6 @@ public class BasicUserServiceTest extends ServiceTest {
*/
@Test
public void testDefaultUserRole() {
assertThat(testUserService.getDefaultUserRole(), not(nullValue()));
assertThat(testUserService.getDefaultUserRole(), is(UserRole.USER));
assertThat(testUserService.getDefaultUserRoles(), containsInAnyOrder(UserRole.USER, UserRole.EVERYONE));
}
......@@ -155,9 +153,6 @@ public class BasicUserServiceTest extends ServiceTest {
@Test
public void testDefaultRoleAlwaysAssigned() throws NotUniqueUserException, PasswordPolicyException, UserException {
TestUser user = testUserService.createUser(USER_EMAIL, USER_FULLNAME, "password", AccountType.SYSTEM);
assertThat("Default user role was not assigned automatically", user.getRoles(), contains(UserRole.USER));
user = testUserService.setRoles(user, Sets.newHashSet(UserRole.USER));
assertThat("Default user role was not assigned automatically", user.getRoles(), containsInAnyOrder(testUserService.getDefaultUserRoles().toArray()));
user = testUserService.setRoles(user, Sets.newHashSet(UserRole.EXTRAROLE));
......
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