Skip to content

Commit

Permalink
[SHIBUI-1044]
Browse files Browse the repository at this point in the history
got rid of optional because I didn't want to write a converter... null checks it is, then
updated doc
  • Loading branch information
jj committed Dec 12, 2018
1 parent aec0fa4 commit fc43041
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16,362 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class UserBootstrap {
@Transactional
@EventListener
void bootstrapUsersAndRoles(ApplicationStartedEvent e) {
if (shibUIConfiguration.userBootstrapResource.isPresent()) {
log.info("configuring users from ${shibUIConfiguration.userBootstrapResource.get().URI}")
new CSVReader(new InputStreamReader(shibUIConfiguration.userBootstrapResource.get().inputStream)).each { it ->
if (shibUIConfiguration.userBootstrapResource) {
log.info("configuring users from ${shibUIConfiguration.userBootstrapResource.URI}")
new CSVReader(new InputStreamReader(shibUIConfiguration.userBootstrapResource.inputStream)).each { it ->
def (username, password, firstName, lastName, roleName) = it
def role = roleRepository.findByName(roleName).orElse(roleRepository.save(new Role(name: roleName)))
def user = userRepository.findByUsername(username).orElse(new User(username: username)).with {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ public class ShibUIConfiguration {
/**
* A Resource containing a CSV of users to bootstrap into the system. Currently, this must be in format
*
* <code>
* username,password,firstName,lastName,role
* </code>
*
* Note that the password must be encrypted in the file using the system configured password encryption (by default,
* BCrypt)
* Note that the password must be encrypted in the file. Ensure that you prepend the encoder to the value, e.g.
*
* <code>
* {bcrypt}$2a$10$ssM2LpFqceRQ/ta0JehGcu0BawFQDbxjQGSyVmKS6qa09hHLigtAO
* </code>
*/
private Optional<Resource> userBootstrapResource = Optional.empty();
private Resource userBootstrapResource;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class UserBootstrapTests extends Specification {

def "simple test"() {
setup:
shibUIConfiguration.userBootstrapResource = Optional.of(new ClassPathResource('/conf/1044.csv'))
shibUIConfiguration.userBootstrapResource = new ClassPathResource('/conf/1044.csv')
def userBootstrap = new UserBootstrap(shibUIConfiguration, userRepository, roleRepository)

when:
Expand Down
Loading

0 comments on commit fc43041

Please sign in to comment.