Here are the examples of the java api org.springframework.context.ApplicationEventPublisher taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
155 Examples
19
View Complete Implementation : WeightRoutePredicateFactory.java
Copyright Apache License 2.0
Author : spring-cloud
Copyright Apache License 2.0
Author : spring-cloud
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
19
View Complete Implementation : GenericEntityService.java
Copyright Apache License 2.0
Author : hs-web
Copyright Apache License 2.0
Author : hs-web
@Autowired(required = false)
public void setEventPublisher(ApplicationEventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
19
View Complete Implementation : IdentityProviderEventPublisher.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
19
View Complete Implementation : AbstractGatewayControllerEndpoint.java
Copyright Apache License 2.0
Author : spring-cloud
Copyright Apache License 2.0
Author : spring-cloud
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
19
View Complete Implementation : ScimEventPublisher.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
public clreplaced ScimEventPublisher implements ApplicationEventPublisherAware {
private final IdenreplacedyZoneManager idenreplacedyZoneManager;
public ScimEventPublisher(final IdenreplacedyZoneManager idenreplacedyZoneManager) {
this.idenreplacedyZoneManager = idenreplacedyZoneManager;
}
private ApplicationEventPublisher publisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
public void userCreated(final ScimUser user) {
publish(UserModifiedEvent.userCreated(user, idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
public void userVerified(final ScimUser user) {
publish(UserModifiedEvent.userVerified(user, idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
public void userModified(final ScimUser user) {
publish(UserModifiedEvent.userModified(user, idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
public void userDeleted(final ScimUser user) {
publish(UserModifiedEvent.userDeleted(user, idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
public void groupCreated(final ScimGroup group) {
publish(GroupModifiedEvent.groupCreated(group.getId(), group.getDisplayName(), getMembers(group), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
public void groupModified(final ScimGroup group) {
publish(GroupModifiedEvent.groupModified(group.getId(), group.getDisplayName(), getMembers(group), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
public void groupDeleted(final ScimGroup group) {
publish(GroupModifiedEvent.groupDeleted(group.getId(), group.getDisplayName(), getMembers(group), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
private static String[] getMembers(final ScimGroup group) {
return ofNullable(group.getMembers()).orElse(Collections.emptyList()).stream().map(ScimGroupMember::getMemberId).toArray(String[]::new);
}
private void publish(final ApplicationEvent event) {
if (publisher != null) {
publisher.publishEvent(event);
}
}
}
19
View Complete Implementation : IdentityZoneEndpoints.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
19
View Complete Implementation : RecordService.java
Copyright GNU Affero General Public License v3.0
Author : hflabs
Copyright GNU Affero General Public License v3.0
Author : hflabs
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : LoginAuthenticationManager.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
19
View Complete Implementation : BaseMetadataOperations.java
Copyright GNU General Public License v2.0
Author : geonetwork
Copyright GNU General Public License v2.0
Author : geonetwork
/**
* @see org.springframework.context.ApplicationEventPublisherAware#setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
*/
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : IdentityProviderBootstrap.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
19
View Complete Implementation : RouteRefreshListener.java
Copyright Apache License 2.0
Author : spring-cloud
Copyright Apache License 2.0
Author : spring-cloud
// see ZuulDiscoveryRefreshListener
// TODO: make abstract clreplaced in commons?
public clreplaced RouteRefreshListener implements ApplicationListener<ApplicationEvent> {
private final ApplicationEventPublisher publisher;
private HeartbeatMonitor monitor = new HeartbeatMonitor();
public RouteRefreshListener(ApplicationEventPublisher publisher) {
replacedert.notNull(publisher, "publisher may not be null");
this.publisher = publisher;
}
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextRefreshedEvent || event instanceof RefreshScopeRefreshedEvent || event instanceof InstanceRegisteredEvent) {
reset();
} else if (event instanceof ParentHeartbeatEvent) {
ParentHeartbeatEvent e = (ParentHeartbeatEvent) event;
resetIfNeeded(e.getValue());
} else if (event instanceof HeartbeatEvent) {
HeartbeatEvent e = (HeartbeatEvent) event;
resetIfNeeded(e.getValue());
}
}
private void resetIfNeeded(Object value) {
if (this.monitor.update(value)) {
reset();
}
}
private void reset() {
this.publisher.publishEvent(new RefreshRoutesEvent(this));
}
}
19
View Complete Implementation : PasswordChangeEventPublisher.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
/**
* Event publisher for preplacedword changes with the resulting event type varying
* according to the input and outcome. Can be
* used as an aspect intercepting calls to a component that changes user
* preplacedword.
*/
public clreplaced PreplacedwordChangeEventPublisher implements ApplicationEventPublisherAware {
private IdenreplacedyZoneManager idenreplacedyZoneManager;
static final String DEFAULT_EMAIL_DOMAIN = "this-default-was-not-configured.invalid";
private ScimUserProvisioning dao;
private ApplicationEventPublisher publisher;
public PreplacedwordChangeEventPublisher(ScimUserProvisioning provisioning, IdenreplacedyZoneManager idenreplacedyZoneManager) {
this.dao = provisioning;
this.idenreplacedyZoneManager = idenreplacedyZoneManager;
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
public void preplacedwordFailure(String userId, Exception e) {
UaaUser user = getUser(userId);
publish(new PreplacedwordChangeFailureEvent(e.getMessage(), user, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
public void preplacedwordChange(String userId) {
publish(new PreplacedwordChangeEvent("Preplacedword changed", getUser(userId), getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
UaaUser getUser(String userId) {
try {
// If the request came in for a user by id we should be able to
// retrieve the username
ScimUser scimUser = dao.retrieve(userId, idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId());
Date today = new Date();
if (scimUser != null) {
return new UaaUser(scimUser.getId(), scimUser.getUserName(), "N/A", getEmail(scimUser), null, scimUser.getGivenName(), scimUser.getFamilyName(), today, today, scimUser.getOrigin(), scimUser.getExternalId(), scimUser.isVerified(), scimUser.getZoneId(), scimUser.getSalt(), scimUser.getPreplacedwordLastModified());
}
} catch (ScimResourceNotFoundException e) {
// ignore
}
return null;
}
String getEmail(ScimUser scimUser) {
List<Email> emails = scimUser.getEmails();
if (emails == null || emails.isEmpty()) {
return scimUser.getUserName().contains("@") ? scimUser.getUserName() : scimUser.getUserName() + "@" + DEFAULT_EMAIL_DOMAIN;
}
for (Email email : emails) {
if (email.isPrimary()) {
return email.getValue();
}
}
return scimUser.getEmails().get(0).getValue();
}
Authentication getPrincipal() {
return ofNullable(SecurityContextHolder.getContext().getAuthentication()).orElse(SYSTEM_AUTHENTICATION);
}
private void publish(AbstractUaaEvent event) {
if (publisher != null) {
publisher.publishEvent(event);
}
}
}
19
View Complete Implementation : BadCredentialsListener.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
19
View Complete Implementation : ConfigurationService.java
Copyright Apache License 2.0
Author : spring-cloud
Copyright Apache License 2.0
Author : spring-cloud
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
19
View Complete Implementation : TotpMfaEndpoint.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : AbstractGatewayFilterFactory.java
Copyright Apache License 2.0
Author : spring-cloud
Copyright Apache License 2.0
Author : spring-cloud
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
19
View Complete Implementation : UaaTokenServices.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : DocumentManagerService.java
Copyright GNU Affero General Public License v3.0
Author : hflabs
Copyright GNU Affero General Public License v3.0
Author : hflabs
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : ScimEventPublisher.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
19
View Complete Implementation : BaseMetadataIndexer.java
Copyright GNU General Public License v2.0
Author : geonetwork
Copyright GNU General Public License v2.0
Author : geonetwork
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
19
View Complete Implementation : ClientAdminEndpoints.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
publisher = applicationEventPublisher;
}
19
View Complete Implementation : UaaChangePasswordService.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
public clreplaced UaaChangePreplacedwordService implements ChangePreplacedwordService, ApplicationEventPublisherAware {
private final ScimUserProvisioning scimUserProvisioning;
private final PreplacedwordValidator preplacedwordValidator;
private ApplicationEventPublisher publisher;
public UaaChangePreplacedwordService(ScimUserProvisioning scimUserProvisioning, PreplacedwordValidator preplacedwordValidator) {
this.scimUserProvisioning = scimUserProvisioning;
this.preplacedwordValidator = preplacedwordValidator;
}
@Override
public void changePreplacedword(String username, String currentPreplacedword, String newPreplacedword) {
if (username == null || currentPreplacedword == null) {
throw new BadCredentialsException(username);
}
preplacedwordValidator.validate(newPreplacedword);
List<ScimUser> results = scimUserProvisioning.retrieveByUsernameAndOriginAndZone(username, UAA, IdenreplacedyZoneHolder.getCurrentZoneId());
if (results.isEmpty()) {
throw new ScimResourceNotFoundException("User not found");
}
ScimUser user = results.get(0);
UaaUser uaaUser = getUaaUser(user);
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
try {
if (scimUserProvisioning.checkPreplacedwordMatches(user.getId(), newPreplacedword, IdenreplacedyZoneHolder.get().getId())) {
throw new InvalidPreplacedwordException("Your new preplacedword cannot be the same as the old preplacedword.", UNPROCESSABLE_ENreplacedY);
}
scimUserProvisioning.changePreplacedword(user.getId(), currentPreplacedword, newPreplacedword, IdenreplacedyZoneHolder.get().getId());
publish(new PreplacedwordChangeEvent("Preplacedword changed", uaaUser, authentication, IdenreplacedyZoneHolder.getCurrentZoneId()));
} catch (Exception e) {
publish(new PreplacedwordChangeFailureEvent(e.getMessage(), uaaUser, authentication, IdenreplacedyZoneHolder.getCurrentZoneId()));
throw e;
}
}
private UaaUser getUaaUser(ScimUser scimUser) {
Date today = new Date();
return new UaaUser(scimUser.getId(), scimUser.getUserName(), "N/A", scimUser.getPrimaryEmail(), null, scimUser.getGivenName(), scimUser.getFamilyName(), today, today, scimUser.getOrigin(), scimUser.getExternalId(), scimUser.isVerified(), scimUser.getZoneId(), scimUser.getSalt(), scimUser.getPreplacedwordLastModified());
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
protected void publish(ApplicationEvent event) {
if (publisher != null) {
publisher.publishEvent(event);
}
}
}
19
View Complete Implementation : IdentityZoneEventPublisher.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
19
View Complete Implementation : ClientAdminEventPublisherTests.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
clreplaced ClientAdminEventPublisherTests {
private MulreplacedenantClientServices mockMulreplacedenantClientServices;
private ApplicationEventPublisher mockApplicationEventPublisher;
private ClientAdminEventPublisher subject;
@BeforeEach
void setUp() {
mockMulreplacedenantClientServices = mock(MulreplacedenantClientServices.clreplaced);
subject = new ClientAdminEventPublisher(mockMulreplacedenantClientServices, mock(IdenreplacedyZoneManager.clreplaced));
mockApplicationEventPublisher = mock(ApplicationEventPublisher.clreplaced);
subject.setApplicationEventPublisher(mockApplicationEventPublisher);
OAuth2Request oAuth2Request = new AuthorizationRequest("client", Collections.singletonList("read")).createOAuth2Request();
UaaAuthentication authentication1 = UaaAuthenticationTestFactory.getAuthentication("ID", "joe", "[email protected]");
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(oAuth2Request, authentication1);
SecurityContextHolder.getContext().setAuthentication(oAuth2Authentication);
}
@AfterEach
void tearDown() {
SecurityContextHolder.clearContext();
}
@Test
void create() {
BaseClientDetails client = new BaseClientDetails("foo", null, null, "client_credentials", "none");
subject.create(client);
verify(mockApplicationEventPublisher).publishEvent(isA(ClientCreateEvent.clreplaced));
}
@Test
void update() {
BaseClientDetails client = new BaseClientDetails("foo", null, null, "client_credentials", "none");
subject.update(client);
verify(mockApplicationEventPublisher).publishEvent(isA(ClientUpdateEvent.clreplaced));
}
@Test
void delete() throws Throwable {
BaseClientDetails client = new BaseClientDetails("foo", null, null, "client_credentials", "none");
ProceedingJoinPoint jp = mock(ProceedingJoinPoint.clreplaced);
when(jp.proceed()).thenReturn(client);
subject.delete(jp, "foo");
verify(mockApplicationEventPublisher).publishEvent(isA(ClientDeleteEvent.clreplaced));
}
@Test
void secretChange() {
when(mockMulreplacedenantClientServices.loadClientByClientId("foo")).thenReturn(new BaseClientDetails("foo", null, null, "client_credentials", "none"));
subject.secretChange("foo");
verify(mockApplicationEventPublisher).publishEvent(isA(SecretChangeEvent.clreplaced));
}
@Test
void secretFailure() {
when(mockMulreplacedenantClientServices.loadClientByClientId("foo")).thenReturn(new BaseClientDetails("foo", null, null, "client_credentials", "none"));
subject.secretFailure("foo", new RuntimeException("planned"));
verify(mockApplicationEventPublisher).publishEvent(isA(SecretFailureEvent.clreplaced));
}
@Test
void secretFailureMissingClient() {
when(mockMulreplacedenantClientServices.loadClientByClientId("foo")).thenThrow(new InvalidClientException("Not found"));
subject.secretFailure("foo", new RuntimeException("planned"));
verify(mockApplicationEventPublisher).publishEvent(isA(SecretFailureEvent.clreplaced));
}
}
19
View Complete Implementation : IdentityProviderEndpoints.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
19
View Complete Implementation : AbstractGatewayFilterFactory.java
Copyright Apache License 2.0
Author : spring-cloud
Copyright Apache License 2.0
Author : spring-cloud
/**
* This clreplaced is BETA and may be subject to change in a future release.
*
* @param <C> {@link AbstractConfigurable} subtype
*/
public abstract clreplaced AbstractGatewayFilterFactory<C> extends AbstractConfigurable<C> implements GatewayFilterFactory<C>, ApplicationEventPublisherAware {
private ApplicationEventPublisher publisher;
@SuppressWarnings("unchecked")
public AbstractGatewayFilterFactory() {
super((Clreplaced<C>) Object.clreplaced);
}
public AbstractGatewayFilterFactory(Clreplaced<C> configClreplaced) {
super(configClreplaced);
}
protected ApplicationEventPublisher getPublisher() {
return this.publisher;
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
public static clreplaced NameConfig {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
19
View Complete Implementation : PasswordChangeEventPublisherTests.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
clreplaced PreplacedwordChangeEventPublisherTests {
private ScimUserProvisioning mockScimUserProvisioning;
private ApplicationEventPublisher mockApplicationEventPublisher;
private IdenreplacedyZoneManager mockIdenreplacedyZoneManager;
private String currentZoneId;
private PreplacedwordChangeEventPublisher subject;
private Authentication authentication;
@BeforeEach
void setUp() {
mockScimUserProvisioning = mock(ScimUserProvisioning.clreplaced);
mockApplicationEventPublisher = mock(ApplicationEventPublisher.clreplaced);
mockIdenreplacedyZoneManager = mock(IdenreplacedyZoneManager.clreplaced);
currentZoneId = "currentZoneId-" + RandomStringUtils.random(8);
subject = new PreplacedwordChangeEventPublisher(mockScimUserProvisioning, mockIdenreplacedyZoneManager);
subject.setApplicationEventPublisher(mockApplicationEventPublisher);
authentication = new OAuth2Authentication(new AuthorizationRequest("client", Collections.singletonList("read")).createOAuth2Request(), UaaPreplacedwordTestFactory.getAuthentication("ID", "joe", "[email protected]"));
SecurityContextHolder.getContext().setAuthentication(authentication);
}
@AfterEach
void tearDown() {
SecurityContextHolder.clearContext();
}
@Test
void preplacedwordChange() {
when(mockScimUserProvisioning.retrieve("foo", currentZoneId)).thenReturn(ScimUserTestFactory.getScimUser("joe", "[email protected]", "Joe", "Schmo"));
subject.preplacedwordChange("foo");
verify(mockApplicationEventPublisher).publishEvent(isA(PreplacedwordChangeEvent.clreplaced));
}
@Test
void preplacedwordFailure() {
when(mockScimUserProvisioning.retrieve("foo", currentZoneId)).thenReturn(ScimUserTestFactory.getScimUser("joe", "[email protected]", "Joe", "Schmo"));
subject.preplacedwordFailure("foo", new RuntimeException("planned"));
verify(mockApplicationEventPublisher).publishEvent(isA(PreplacedwordChangeFailureEvent.clreplaced));
}
@Test
void shouldReturnNullUserWhenUserIdIsUnrecognized() {
String unknownUserId = "unknownId";
when(mockScimUserProvisioning.retrieve(unknownUserId, currentZoneId)).thenReturn(null);
replacedertNull(subject.getUser(unknownUserId));
}
@Test
void shouldReturnNullWhenFindingAUserThrows() {
String userId = "validId";
when(mockScimUserProvisioning.retrieve(userId, currentZoneId)).thenThrow(new ScimResourceNotFoundException("So sad"));
replacedertNull(subject.getUser(userId));
}
@Test
void shouldConstructEmailBasedOnUsernameIfNoEmailList() {
ScimUser scimUser = scimUserFrom("userName", null);
replacedertEquals(String.format("userName@%s", DEFAULT_EMAIL_DOMAIN), subject.getEmail(scimUser));
}
@Test
void shouldNotConstructEmailBasedOnUsernameIfNoEmailListAndTheUsernameContainsAnAtSymbol() {
ScimUser scimUser = scimUserFrom("userName@", null);
replacedertEquals("userName@", subject.getEmail(scimUser));
}
@Test
void shouldConstructEmailBasedOnUsernameIfEmailListIsEmpty() {
ScimUser scimUser = scimUserFrom("userName", Collections.emptyList());
replacedertEquals(String.format("userName@%s", DEFAULT_EMAIL_DOMAIN), subject.getEmail(scimUser));
}
@Test
void shouldConstructEmailBasedOnUsernameIfEmailListIsEmptyAndTheUsernameContainsAnAtSymbol() {
ScimUser scimUser = scimUserFrom("userName@", Collections.emptyList());
replacedertEquals("userName@", subject.getEmail(scimUser));
}
@Test
void shouldReturnFirstEmailFromEmailListIfNoPrimary() {
ScimUser scimUser = scimUserFrom("userName", Arrays.asList("[email protected]", "[email protected]"));
replacedertEquals("[email protected]", subject.getEmail(scimUser));
}
@Test
void shouldReturnFirstPrimaryEmail() {
ScimUser scimUser = scimUserFrom("userName", Arrays.asList("[email protected]", "[email protected]", "[email protected]"));
scimUser.getEmails().get(1).setPrimary(true);
replacedertEquals("[email protected]", subject.getEmail(scimUser));
}
@Test
void notAuthenticatedReturnsSystemAuth() {
replacedertSame(authentication, subject.getPrincipal());
SecurityContextHolder.clearContext();
replacedertSame(SystemAuthentication.SYSTEM_AUTHENTICATION, subject.getPrincipal());
}
private ScimUser scimUserFrom(String userName, List<String> emailAddresses) {
ScimUser scimUser = new ScimUser(userName, userName, userName, userName);
if (emailAddresses != null) {
List<ScimUser.Email> emails = emailAddresses.stream().map((emailAddress) -> {
ScimUser.Email email = new ScimUser.Email();
email.setValue(emailAddress);
return email;
}).collect(Collectors.toList());
scimUser.setEmails(emails);
}
return scimUser;
}
}
19
View Complete Implementation : ScimUserEndpoints.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(@NonNull ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
19
View Complete Implementation : AuthenticationCleanedEventHandler.java
Copyright GNU Affero General Public License v3.0
Author : hflabs
Copyright GNU Affero General Public License v3.0
Author : hflabs
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : MfaProviderEndpoints.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
19
View Complete Implementation : FilterDocumentServiceTemplate.java
Copyright GNU Affero General Public License v3.0
Author : hflabs
Copyright GNU Affero General Public License v3.0
Author : hflabs
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : DynamicLdapAuthenticationManager.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : SynchronizationTaskPerformer.java
Copyright GNU Affero General Public License v3.0
Author : hflabs
Copyright GNU Affero General Public License v3.0
Author : hflabs
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : BadCredentialsListener.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
/**
* Spring {@code ApplicationListener} which picks up the listens for Spring
* Security events and relays them.
*
* @author Dave Syer
*/
public clreplaced BadCredentialsListener implements ApplicationListener<AuthenticationFailureBadCredentialsEvent>, ApplicationEventPublisherAware {
private ApplicationEventPublisher publisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
@Override
public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent event) {
String principal = event.getAuthentication().getName();
UaaAuthenticationDetails details = (UaaAuthenticationDetails) event.getAuthentication().getDetails();
if (event.getException() instanceof UsernameNotFoundException) {
publisher.publishEvent(new PrincipalNotFoundEvent(principal, details, IdenreplacedyZoneHolder.getCurrentZoneId()));
} else {
publisher.publishEvent(new PrincipalAuthenticationFailureEvent(principal, details, IdenreplacedyZoneHolder.getCurrentZoneId()));
}
}
}
19
View Complete Implementation : RecodeWebService.java
Copyright GNU Affero General Public License v3.0
Author : hflabs
Copyright GNU Affero General Public License v3.0
Author : hflabs
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : ClientAuthenticationPublisher.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
19
View Complete Implementation : ByIntervalCollector.java
Copyright GNU Affero General Public License v3.0
Author : hflabs
Copyright GNU Affero General Public License v3.0
Author : hflabs
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : ExternalLoginAuthenticationManager.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
19
View Complete Implementation : TaskLauncher.java
Copyright GNU Affero General Public License v3.0
Author : hflabs
Copyright GNU Affero General Public License v3.0
Author : hflabs
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : LoginSamlAuthenticationProvider.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
19
View Complete Implementation : DefaultUserTokenManager.java
Copyright Apache License 2.0
Author : hs-web
Copyright Apache License 2.0
Author : hs-web
@Autowired(required = false)
public void setEventPublisher(ApplicationEventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
19
View Complete Implementation : IdentityProviderEventPublisher.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
public clreplaced IdenreplacedyProviderEventPublisher implements ApplicationEventPublisherAware {
private final IdenreplacedyZoneManager idenreplacedyZoneManager;
private ApplicationEventPublisher publisher;
public IdenreplacedyProviderEventPublisher(final IdenreplacedyZoneManager idenreplacedyZoneManager) {
this.idenreplacedyZoneManager = idenreplacedyZoneManager;
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
public void idpCreated(IdenreplacedyProvider idenreplacedyProvider) {
publish(IdenreplacedyProviderModifiedEvent.idenreplacedyProviderCreated(idenreplacedyProvider, idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
public void idpModified(IdenreplacedyProvider idenreplacedyProvider) {
publish(IdenreplacedyProviderModifiedEvent.idenreplacedyProviderModified(idenreplacedyProvider, idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
public void publish(ApplicationEvent event) {
if (publisher != null) {
publisher.publishEvent(event);
}
}
}
19
View Complete Implementation : DefaultAuthorizingHandler.java
Copyright Apache License 2.0
Author : hs-web
Copyright Apache License 2.0
Author : hs-web
@Autowired
public void setEventPublisher(ApplicationEventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
19
View Complete Implementation : TokenRevocationEndpoint.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
19
View Complete Implementation : PasswordChangeEventPublisher.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
19
View Complete Implementation : ClientAuthenticationPublisher.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
public clreplaced ClientAuthenticationPublisher implements ApplicationEventPublisherAware {
private ApplicationEventPublisher publisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
public void clientAuthenticationSuccess(Authentication authentication) {
publish(new ClientAuthenticationSuccessEvent(authentication, IdenreplacedyZoneHolder.getCurrentZoneId()));
}
public void clientAuthenticationFailure(Authentication authentication, AuthenticationException ex) {
publish(new ClientAuthenticationFailureEvent(authentication, ex, IdenreplacedyZoneHolder.getCurrentZoneId()));
}
public void publish(ApplicationEvent event) {
if (publisher != null) {
publisher.publishEvent(event);
}
}
}
19
View Complete Implementation : IdentityZoneEventPublisher.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
public clreplaced IdenreplacedyZoneEventPublisher implements ApplicationEventPublisherAware {
private ApplicationEventPublisher publisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
public void idenreplacedyZoneCreated(IdenreplacedyZone idenreplacedyZone) {
publish(IdenreplacedyZoneModifiedEvent.idenreplacedyZoneCreated(idenreplacedyZone));
}
public void idenreplacedyZoneModified(IdenreplacedyZone idenreplacedyZone) {
publish(IdenreplacedyZoneModifiedEvent.idenreplacedyZoneModified(idenreplacedyZone));
}
public void publish(ApplicationEvent event) {
if (publisher != null) {
publisher.publishEvent(event);
}
}
}
19
View Complete Implementation : ClientAdminEventPublisher.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
19
View Complete Implementation : ChangeEmailEndpoints.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
@Override
public void setApplicationEventPublisher(@NonNull ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
19
View Complete Implementation : ClientAdminEventPublisher.java
Copyright Apache License 2.0
Author : cloudfoundry
Copyright Apache License 2.0
Author : cloudfoundry
/**
* Event publisher for client registration changes with the resulting event type
* varying according to the input and outcome. Can be used as an aspect intercepting
* calls to a component that changes client details.
*/
public clreplaced ClientAdminEventPublisher implements ApplicationEventPublisherAware {
private final MulreplacedenantClientServices clientDetailsService;
private final IdenreplacedyZoneManager idenreplacedyZoneManager;
private ApplicationEventPublisher publisher;
public ClientAdminEventPublisher(final MulreplacedenantClientServices clientDetailsService, final IdenreplacedyZoneManager idenreplacedyZoneManager) {
this.clientDetailsService = clientDetailsService;
this.idenreplacedyZoneManager = idenreplacedyZoneManager;
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
public ApplicationEventPublisher getPublisher() {
return publisher;
}
public void create(ClientDetails client) {
publish(new ClientCreateEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
public void createTx(ClientDetails[] clients) {
for (ClientDetails client : clients) {
publish(new ClientCreateEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
}
public void update(ClientDetails client) {
publish(new ClientUpdateEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
public void updateTx(ClientDetails[] clients) {
for (ClientDetails client : clients) {
publish(new ClientUpdateEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
}
public ClientDetails delete(ProceedingJoinPoint jp, String clientId) throws Throwable {
ClientDetails client = (ClientDetails) jp.proceed();
publish(new ClientDeleteEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
return client;
}
public void deleteTx(ClientDetails[] clients) {
for (ClientDetails client : clients) {
publish(new ClientDeleteEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
}
public void modifyTx(ClientDetailsModification[] clients) {
for (ClientDetailsModification client : clients) {
if (ClientDetailsModification.ADD.equals(client.getAction())) {
publish(new ClientCreateEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
} else if (ClientDetailsModification.UPDATE.equals(client.getAction())) {
publish(new ClientUpdateEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
} else if (ClientDetailsModification.DELETE.equals(client.getAction())) {
publish(new ClientDeleteEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
} else if (ClientDetailsModification.UPDATE_SECRET.equals(client.getAction())) {
publish(new ClientUpdateEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
if (client.isApprovalsDeleted()) {
publish(new SecretChangeEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
publish(new ClientApprovalsDeletedEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
} else if (ClientDetailsModification.SECRET.equals(client.getAction())) {
if (client.isApprovalsDeleted()) {
publish(new SecretChangeEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
publish(new ClientApprovalsDeletedEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
}
}
}
public void secretTx(ClientDetailsModification[] clients) {
for (ClientDetailsModification client : clients) {
publish(new ClientDeleteEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
if (client.isApprovalsDeleted()) {
publish(new ClientApprovalsDeletedEvent(client, getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
}
}
public void secretFailure(String clientId, Exception e) {
publish(new SecretFailureEvent(e.getMessage(), getClient(clientId), getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
public void secretChange(String clientId) {
publish(new SecretChangeEvent(getClient(clientId), getPrincipal(), idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId()));
}
private ClientDetails getClient(String clientId) {
try {
return clientDetailsService.loadClientByClientId(clientId, idenreplacedyZoneManager.getCurrentIdenreplacedyZoneId());
} catch (InvalidClientException e) {
return null;
}
}
private Authentication getPrincipal() {
return SecurityContextHolder.getContext().getAuthentication();
}
private void publish(AbstractUaaEvent event) {
if (publisher != null) {
publisher.publishEvent(event);
}
}
}