concept action in category spring

This is an excerpt from Manning's book Spring Microservices in Action, 2E.
Authorization. How do you determine whether the service client calling a microservice is allowed to undertake the action they’re trying to undertake?
The published message will include the organization ID associated with the change event and will also include what action occurred (Add, Update, or Delete).
Listing 10.3 Publishing a message to the message broker
package com.optimagrowth.organization.events.source; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.stream.messaging.Source; import org.springframework.messaging.support.MessageBuilder; import org.springframework.stereotype.Component; import com.optimagrowth.organization.events.model.OrganizationChangeModel; import com.optimagrowth.organization.utils.UserContext; @Component public class SimpleSourceBean { private Source source; private static final Logger logger = LoggerFactory.getLogger(SimpleSourceBean.class); @Autowired public SimpleSourceBean(Source source){ #A this.source = source; } public void publishOrganizationChange(String action, String organizationId){ logger.debug("Sending Kafka message {} for Organization Id: {}", action, organizationId); OrganizationChangeModel change = new OrganizationChangeModel( OrganizationChangeModel.class.getTypeName(), action, organizationId, UserContext.getCorrelationId()); #B source.output().send(MessageBuilder.withPayload(change).build()); #C } }

This is an excerpt from Manning's book Spring Security in Action.
So you use annotations to instruct Spring what to do: expose endpoints, wrap methods in transactions, intercept methods in aspects, and so on. The same is true with Spring Security configurations. This is where Spring Security comes into action. So what you want is to use, as comfortable already, annotations, beans, and in general Spring-fashioned configuration style to define your application-level security. If you think of a Spring application, the behavior that you need to protect is defined by methods.
Figure 10.1 After the user logs into their account, they access a page containing forgery code. This code impersonates the user and might execute actions on behalf of the user.
![]()
What happened? You were logged into the application so you could manage your files. When you add, change or delete a file, the web page which you interact with calls some endpoints from the server to execute these operations. Instead, when you opened the foreign page by clicking the unknown link in the email, that page called the server and executed actions on your behalf (e.g. deleted your files). It could do that because you logged in previously in the application, so the server trusted the actions are coming from you. You maybe think that someone couldn’t trick you so easy to click a link from a foreign mail or message, but trust me, this often happens to a lot of people. Most of the web app users out there aren’t aware of security risks. So it’s wiser you, who knows all these things protect them by building secure apps rather than rely on your apps’ users to protect themselves.
CSRF attacks assume that a user is logged into a web application. They’re tricked by the attacker to open a page that contains scripts that execute actions in the same application the user was working on. Because the user has already logged in (as we’ve assumed from the beginning), the forgery code can now impersonate the user and do actions on their behalf.

This is an excerpt from Manning's book Spring Microservices in Action.
Authorization— How do you determine whether the service client calling a microservice is allowed to undertake the action they’re trying to undertake?
package com.thoughtmechanix.organization.events.source; //Removed imports for conciseness @Component public class SimpleSourceBean { private Source source; private static final Logger logger = LoggerFactory.getLogger(SimpleSourceBean.class); @Autowired public SimpleSourceBean(Source source){ #1 this.source = source; } public void publishOrgChange(String action,String orgId){ logger.debug("Sending Kafka message {} for Organization Id: {}", action, orgId); OrganizationChangeModel change = new OrganizationChangeModel( OrganizationChangeModel.class.getTypeName(), action, orgId, UserContext.getCorrelationId()); #2 source .output() .send( MessageBuilder .withPayload(change) .build()); #3 } }
From the general architecture laid out in section 10.3, you can see that there are many moving pieces behind a build/deployment pipeline. Because the purpose of this book is to show you things “in action,” we’re going to walk through the specifics of implementing a build/deployment pipeline for the EagleEye services. Figure 10.16 lays out the different technologies you’re going to use to implement your pipeline:

This is an excerpt from Manning's book Spring Batch in Action.
Here, we go down a level in the job configuration and describe what makes up a job: steps. Don’t hesitate to refer back to figure 3.2 to view the relationships between all the batch entities. A step is a phase in a job; chapter 2, section 2.3.1, describes these concepts. Steps define the sequence of actions a job will take, one at a time. In the online store use case, you receive products in a compressed file; the job decompresses the file before importing and saving the products in the database, as illustrated in figure 3.3.
PRM....210124.60BlackBerry 8100 Pearl BlackBerry PRM....211139.45Sony Ericsson W810i Sony Ericson PRB....734 34.95Spring Batch in action Manning PRB....736 44.95Spring in action Manning PRM....214145.50Nokia 2610 Phone Nokia

This is an excerpt from Manning's book Spring Dynamic Modules in Action.
The bundle element is not limited to only Spring DM bundles; it works for any OSGi-compliant bundle. You can also use the bundle element with bundles that aren’t yet deployed to the OSGi platform, thanks to the location attribute. With this attribute, you can indicate where to find a bundle by using the Spring resource syntax. You can also choose an action to be performed when the bundle is loaded by Spring DM. The following snippet shows how to create a bundle bean from the filesystem and then start it:
<osgi:bundle
id="myBundle"
location="file:/my/bundle/repo/somebundle.jar"
action="start" />The action attribute supports five values that are the equivalent of the methods of the Bundle interface: install, start, update, stop, and uninstall. They have the same semantics, but Spring DM makes their use easier than in a pure OSGi environment. If you take a look at the Javadoc for these methods, you’ll notice that they have strict preconditions. For example, you can’t call the start method on a bundle that isn’t in the resolved state yet. With the action attribute of bundle, Spring DM handles these kinds of implicit transitions, and no OSGi exceptions will be thrown.
Table 4.4 lists all the attributes available in the bundle element. Notice the destroy-action attribute, which can tie an action to a bundle when the application context is destroyed, providing an easy way to stop bundles in a cascade, for example.
Table 4.4. Attributes of the bundle element
Attribute name
Values
Description
id Any XML-valid ID Unique ID of the bean in the application context. symbolic-name Any valid OSGi symbolic-name The symbolic name of an already installed bundle. location Spring resource syntax The location to load the bundle from, usually to interact with and call some lifecycle methods. start-level Integer The bundle start level. action install, start, update, stop, uninstall An action executed on the bundle. This uses the same semantics as the methods from the Bundle interface, with preconditions weakened. destroy-action install, start, update, stop, uninstall An action executed on the bundle when the application context is destroyed. This uses the same semantics as the methods from the Bundle interface, with preconditions weakened.

This is an excerpt from Manning's book Dependency Injection: Design Patterns Using Spring and Guice.
Listing 1.9 shows the Hollywood Principle in action.
Finally, the @On annotation is used to resolve events to fire against. For now, let it suffice to say that @On controls which method annotated with @Get is called based on an incoming request parameter named action.