Case study: security integration 101

Source: Internet
Author: User

Security integration 101

This is only a security demo. It adds a security mechanism to spring blazeds integration 101, the first demo in this series.

 

I. Run the demo:

1. RunProgram: Http: // localhost: 8400/spring-Flex-testdrive/spring-blazeds-security-101/index.html

2. If you have not logged on, click "Get Data" to display a "Access Denied" exception dialog box.

3. Log On With userid: John/password: John and click "Get Data" again to obtain data from the server.

4. Click the "logout" button and click "Get Data" again. The "Access Denied" exception dialog box is displayed again.

5. If you have logged on and passed the authentication, you do not need to use channelset to log on. For example. JSP (http: // localhost: 8400/spring-Flex-testdrive/login. in JSP), John/John is logged on. In the flex program, the user logs on to obtain data directly.

Ii. UnderstandingCode:

1. Main. mxml:

Set the channelset of RO during program Initialization

VaR channel: amfchannel = new amfchannel ("My-AMF", "http: // localhost: 8400/spring-Flex-testdrive/messagebroker/AMF ");
VaR channelset: channelset = new channelset ();
Channelset. addchannel (Channel );
Ro. channelset = channelset;

<S: remoteobject id = "Ro" Destination = "securedproductservice" fault = "faulthandler (event)"/>

2. log on and log out through Ro's channelset. Ro. channelset. login (user name, password) and Ro. channelset. logout ().

3. flex-servlet.xml

<Flex: remoting-destination ref = "securedproductservice"/>

4. securedproductservice defined in the app-config.xml is critical:

<Bean id = "securedproductservice" class = "org. springframework. Flex. samples. Product. productdao">
<Constructor-Arg ref = "datasource"/>
<Security: intercept-methods>
<Security: Protect method = "find *" Access = "role_user"/>
</Security: intercept-methods>
</Bean>

Authentication configuration is in the security-config.xml by using <Security/> in <bean/> to protect the method.

5. security-config.xml

<Authentication-Manager>
<Authentication-provider>
<User-service>
<User name = "John" Password = "John" authorities = "role_user"/>
<User name = "admin" Password = "admin" authorities = "role_user, role_admin"/>
<User name = "guest" Password = "guest" authorities = "role_guest"/>
</User-service>
</Authentication-provider>
</Authentication-Manager>

6. A part of the demo is JSP login code.

 

Iii. Summary:

This security mechanism is more about spring, which requires another topic. This is the end of this series of cases ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.