Skip to content

Commit

Permalink
[SHIBUI-1058]
Browse files Browse the repository at this point in the history
Fixed entity descriptor creation to persist the createdBy username.
  • Loading branch information
Bill Smith committed Jan 22, 2019
1 parent 1d2138b commit 9595493
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public EntityService jpaEntityService() {
}

@Bean
public EntityDescriptorService jpaEntityDescriptorService() {
return new JPAEntityDescriptorServiceImpl(openSamlObjects(), jpaEntityService());
public EntityDescriptorService jpaEntityDescriptorService(UserService userService) {
return new JPAEntityDescriptorServiceImpl(openSamlObjects(), jpaEntityService(), userService);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ public interface EntityDescriptorRepository extends CrudRepository<EntityDescrip
@Query("select e from EntityDescriptor e")
Stream<EntityDescriptor> findAllByCustomQueryAndStream();

Stream<EntityDescriptor> findAllByCreatedBy(String username);
Stream<EntityDescriptor> findAllByCreatedBy(String createdBy);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.SecurityInfoRepresentation;
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.ServiceProviderSsoDescriptorRepresentation;
import edu.internet2.tier.shibboleth.admin.ui.opensaml.OpenSamlObjects;
import edu.internet2.tier.shibboleth.admin.ui.security.model.User;
import edu.internet2.tier.shibboleth.admin.ui.security.service.UserService;
import edu.internet2.tier.shibboleth.admin.util.MDDCConstants;
import edu.internet2.tier.shibboleth.admin.util.ModelRepresentationConversions;

Expand Down Expand Up @@ -80,15 +82,24 @@ public class JPAEntityDescriptorServiceImpl implements EntityDescriptorService {
@Autowired
private EntityService entityService;

public JPAEntityDescriptorServiceImpl(OpenSamlObjects openSamlObjects, EntityService entityService) {
private UserService userService;

public JPAEntityDescriptorServiceImpl(OpenSamlObjects openSamlObjects, EntityService entityService, UserService userService) {
this.openSamlObjects = openSamlObjects;
this.entityService = entityService;
this.userService = userService;
}

@Override
public EntityDescriptor createDescriptorFromRepresentation(final EntityDescriptorRepresentation representation) {
EntityDescriptor ed = openSamlObjects.buildDefaultInstanceOfType(EntityDescriptor.class);
ed.setEntityID(representation.getEntityId());
User user = userService.getCurrentUser();
if (user != null) {
ed.setCreatedBy(user.getUsername());
} else {
LOGGER.warn("Current user was null! Who is logged in?");
}

// setup SPSSODescriptor
if (representation.getServiceProviderSsoDescriptor() != null) {
Expand Down

0 comments on commit 9595493

Please sign in to comment.