You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by ad...@apache.org on 2010/05/26 20:34:49 UTC
svn commit: r948527 [30/38] - in /incubator/shiro:
branches/shiro-root-1.0.x/ branches/shiro-root-1.0.x/all/
branches/shiro-root-1.0.x/core/src/main/java/org/apache/shiro/
branches/shiro-root-1.0.x/core/src/main/java/org/apache/shiro/aop/
branches/shir...
Modified: incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/SampleManager.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/SampleManager.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/SampleManager.java (original)
+++ incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/SampleManager.java Wed May 26 18:34:28 2010
@@ -1,65 +1,65 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.shiro.samples.spring;
-
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-import org.apache.shiro.authz.annotation.RequiresRoles;
-
-
-/**
- * Business manager interface used for sample application.
- *
- * @author Jeremy Haile
- * @since 0.1
- */
-public interface SampleManager {
-
- /**
- * Returns the value stored in the user's session.
- *
- * @return the value.
- */
- String getValue();
-
-
- /**
- * Sets a value to be stored in the user's session.
- *
- * @param newValue the new value to store in the user's session.
- */
- void setValue(String newValue);
-
- /**
- * Method that requires <tt>role1</tt> in order to be invoked.
- */
- @RequiresRoles("role1")
- void secureMethod1();
-
- /**
- * Method that requires <tt>role2</tt> in order to be invoked.
- */
- @RequiresRoles("role2")
- void secureMethod2();
-
- /**
- * Method that requires <tt>permission1</tt> in order to be invoked.
- */
- @RequiresPermissions("permission2")
- void secureMethod3();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.samples.spring;
+
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.apache.shiro.authz.annotation.RequiresRoles;
+
+
+/**
+ * Business manager interface used for sample application.
+ *
+ * @author Jeremy Haile
+ * @since 0.1
+ */
+public interface SampleManager {
+
+ /**
+ * Returns the value stored in the user's session.
+ *
+ * @return the value.
+ */
+ String getValue();
+
+
+ /**
+ * Sets a value to be stored in the user's session.
+ *
+ * @param newValue the new value to store in the user's session.
+ */
+ void setValue(String newValue);
+
+ /**
+ * Method that requires <tt>role1</tt> in order to be invoked.
+ */
+ @RequiresRoles("role1")
+ void secureMethod1();
+
+ /**
+ * Method that requires <tt>role2</tt> in order to be invoked.
+ */
+ @RequiresRoles("role2")
+ void secureMethod2();
+
+ /**
+ * Method that requires <tt>permission1</tt> in order to be invoked.
+ */
+ @RequiresPermissions("permission2")
+ void secureMethod3();
+}
Propchange: incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/SampleManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/ui/WebStartDriver.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/ui/WebStartDriver.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/ui/WebStartDriver.java (original)
+++ incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/ui/WebStartDriver.java Wed May 26 18:34:28 2010
@@ -1,39 +1,39 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.shiro.samples.spring.ui;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/**
- * Driver class used to launch the web start application by loading a
- * Spring application context. Once the Spring application context is
- * loaded, the initialization of the {@link WebStartView} does the rest.
- *
- * @author Jeremy Haile
- * @since 0.1
- */
-public class WebStartDriver {
- public static String LAUNCH_SESSION_ID;
-
- public static void main(String[] args) {
- // Store the session id given as argument to a static property to make it available for Spring context
- if (args.length > 0) LAUNCH_SESSION_ID = args[0];
- new ClassPathXmlApplicationContext("webstart.spring.xml");
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.samples.spring.ui;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * Driver class used to launch the web start application by loading a
+ * Spring application context. Once the Spring application context is
+ * loaded, the initialization of the {@link WebStartView} does the rest.
+ *
+ * @author Jeremy Haile
+ * @since 0.1
+ */
+public class WebStartDriver {
+ public static String LAUNCH_SESSION_ID;
+
+ public static void main(String[] args) {
+ // Store the session id given as argument to a static property to make it available for Spring context
+ if (args.length > 0) LAUNCH_SESSION_ID = args[0];
+ new ClassPathXmlApplicationContext("webstart.spring.xml");
+ }
+}
Propchange: incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/ui/WebStartDriver.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/ui/WebStartView.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/ui/WebStartView.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/ui/WebStartView.java (original)
+++ incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/ui/WebStartView.java Wed May 26 18:34:28 2010
@@ -1,159 +1,159 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.shiro.samples.spring.ui;
-
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import javax.swing.*;
-
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.ClassPathResource;
-
-import org.apache.shiro.authz.AuthorizationException;
-import org.apache.shiro.samples.spring.SampleManager;
-
-
-/**
- * Simple web start application that helps to demo single sign-on and
- * remoting authorization using Shiro. The injected <tt>SampleManager</tt>
- * is hosted by the Spring sample web application and remotely invoked
- * when the buttons in this view are clicked.
- *
- * @author Jeremy Haile
- * @since 0.1
- */
-public class WebStartView implements ActionListener, InitializingBean {
-
- /*--------------------------------------------
- | C O N S T A N T S |
- ============================================*/
-
- /*--------------------------------------------
- | I N S T A N C E V A R I A B L E S |
- ============================================*/
- private SampleManager sampleManager;
- private JTextField valueField;
- private JButton saveButton;
- private JButton refreshButton;
- private JButton secureMethod1Button;
- private JButton secureMethod2Button;
- private JButton secureMethod3Button;
- private JFrame frame;
-
- /*--------------------------------------------
- | C O N S T R U C T O R S |
- ============================================*/
-
- /*--------------------------------------------
- | A C C E S S O R S / M O D I F I E R S |
- ============================================*/
-
- public void setSampleManager(SampleManager sampleManager) {
- this.sampleManager = sampleManager;
- }
-
- /*--------------------------------------------
- | M E T H O D S |
- ============================================*/
- public void afterPropertiesSet() throws Exception {
- ClassPathResource resource = new ClassPathResource("logo.png");
- ImageIcon icon = new ImageIcon(resource.getURL());
- JLabel logo = new JLabel(icon);
-
- valueField = new JTextField(20);
- updateValueLabel();
-
- saveButton = new JButton("Save Value");
- saveButton.addActionListener(this);
-
- refreshButton = new JButton("Refresh Value");
- refreshButton.addActionListener(this);
-
- JPanel valuePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- valuePanel.add(valueField);
- valuePanel.add(saveButton);
- valuePanel.add(refreshButton);
-
- secureMethod1Button = new JButton("Method #1");
- secureMethod1Button.addActionListener(this);
-
- secureMethod2Button = new JButton("Method #2");
- secureMethod2Button.addActionListener(this);
-
- secureMethod3Button = new JButton("Method #3");
- secureMethod3Button.addActionListener(this);
-
- JPanel methodPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- methodPanel.add(secureMethod1Button);
- methodPanel.add(secureMethod2Button);
- methodPanel.add(secureMethod3Button);
-
- frame = new JFrame("Apache Shiro Sample Application");
- frame.setSize(500, 200);
-
- Container panel = frame.getContentPane();
- panel.setLayout(new BorderLayout());
- panel.add(logo, BorderLayout.NORTH);
- panel.add(valuePanel, BorderLayout.CENTER);
- panel.add(methodPanel, BorderLayout.SOUTH);
-
- frame.setVisible(true);
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- });
- }
-
- private void updateValueLabel() {
- valueField.setText(sampleManager.getValue());
- }
-
- public void actionPerformed(ActionEvent e) {
- try {
-
- if (e.getSource() == saveButton) {
- sampleManager.setValue(valueField.getText());
-
- } else if (e.getSource() == refreshButton) {
- updateValueLabel();
-
- } else if (e.getSource() == secureMethod1Button) {
- sampleManager.secureMethod1();
- JOptionPane.showMessageDialog(frame, "Method #1 successfully called.", "Success", JOptionPane.INFORMATION_MESSAGE);
-
- } else if (e.getSource() == secureMethod2Button) {
- sampleManager.secureMethod2();
- JOptionPane.showMessageDialog(frame, "Method #2 successfully called.", "Success", JOptionPane.INFORMATION_MESSAGE);
- } else if (e.getSource() == secureMethod3Button) {
- sampleManager.secureMethod3();
- JOptionPane.showMessageDialog(frame, "Method #3 successfully called.", "Success", JOptionPane.INFORMATION_MESSAGE);
-
- } else {
- throw new RuntimeException("Unexpected action event from source: " + e.getSource());
- }
-
- } catch (AuthorizationException ae) {
- JOptionPane.showMessageDialog(frame, "Unauthorized to perform action: " + ae.getMessage(), "Unauthorized", JOptionPane.WARNING_MESSAGE);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.samples.spring.ui;
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import javax.swing.*;
+
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.ClassPathResource;
+
+import org.apache.shiro.authz.AuthorizationException;
+import org.apache.shiro.samples.spring.SampleManager;
+
+
+/**
+ * Simple web start application that helps to demo single sign-on and
+ * remoting authorization using Shiro. The injected <tt>SampleManager</tt>
+ * is hosted by the Spring sample web application and remotely invoked
+ * when the buttons in this view are clicked.
+ *
+ * @author Jeremy Haile
+ * @since 0.1
+ */
+public class WebStartView implements ActionListener, InitializingBean {
+
+ /*--------------------------------------------
+ | C O N S T A N T S |
+ ============================================*/
+
+ /*--------------------------------------------
+ | I N S T A N C E V A R I A B L E S |
+ ============================================*/
+ private SampleManager sampleManager;
+ private JTextField valueField;
+ private JButton saveButton;
+ private JButton refreshButton;
+ private JButton secureMethod1Button;
+ private JButton secureMethod2Button;
+ private JButton secureMethod3Button;
+ private JFrame frame;
+
+ /*--------------------------------------------
+ | C O N S T R U C T O R S |
+ ============================================*/
+
+ /*--------------------------------------------
+ | A C C E S S O R S / M O D I F I E R S |
+ ============================================*/
+
+ public void setSampleManager(SampleManager sampleManager) {
+ this.sampleManager = sampleManager;
+ }
+
+ /*--------------------------------------------
+ | M E T H O D S |
+ ============================================*/
+ public void afterPropertiesSet() throws Exception {
+ ClassPathResource resource = new ClassPathResource("logo.png");
+ ImageIcon icon = new ImageIcon(resource.getURL());
+ JLabel logo = new JLabel(icon);
+
+ valueField = new JTextField(20);
+ updateValueLabel();
+
+ saveButton = new JButton("Save Value");
+ saveButton.addActionListener(this);
+
+ refreshButton = new JButton("Refresh Value");
+ refreshButton.addActionListener(this);
+
+ JPanel valuePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ valuePanel.add(valueField);
+ valuePanel.add(saveButton);
+ valuePanel.add(refreshButton);
+
+ secureMethod1Button = new JButton("Method #1");
+ secureMethod1Button.addActionListener(this);
+
+ secureMethod2Button = new JButton("Method #2");
+ secureMethod2Button.addActionListener(this);
+
+ secureMethod3Button = new JButton("Method #3");
+ secureMethod3Button.addActionListener(this);
+
+ JPanel methodPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ methodPanel.add(secureMethod1Button);
+ methodPanel.add(secureMethod2Button);
+ methodPanel.add(secureMethod3Button);
+
+ frame = new JFrame("Apache Shiro Sample Application");
+ frame.setSize(500, 200);
+
+ Container panel = frame.getContentPane();
+ panel.setLayout(new BorderLayout());
+ panel.add(logo, BorderLayout.NORTH);
+ panel.add(valuePanel, BorderLayout.CENTER);
+ panel.add(methodPanel, BorderLayout.SOUTH);
+
+ frame.setVisible(true);
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ }
+
+ private void updateValueLabel() {
+ valueField.setText(sampleManager.getValue());
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ try {
+
+ if (e.getSource() == saveButton) {
+ sampleManager.setValue(valueField.getText());
+
+ } else if (e.getSource() == refreshButton) {
+ updateValueLabel();
+
+ } else if (e.getSource() == secureMethod1Button) {
+ sampleManager.secureMethod1();
+ JOptionPane.showMessageDialog(frame, "Method #1 successfully called.", "Success", JOptionPane.INFORMATION_MESSAGE);
+
+ } else if (e.getSource() == secureMethod2Button) {
+ sampleManager.secureMethod2();
+ JOptionPane.showMessageDialog(frame, "Method #2 successfully called.", "Success", JOptionPane.INFORMATION_MESSAGE);
+ } else if (e.getSource() == secureMethod3Button) {
+ sampleManager.secureMethod3();
+ JOptionPane.showMessageDialog(frame, "Method #3 successfully called.", "Success", JOptionPane.INFORMATION_MESSAGE);
+
+ } else {
+ throw new RuntimeException("Unexpected action event from source: " + e.getSource());
+ }
+
+ } catch (AuthorizationException ae) {
+ JOptionPane.showMessageDialog(frame, "Unauthorized to perform action: " + ae.getMessage(), "Unauthorized", JOptionPane.WARNING_MESSAGE);
+ }
+ }
+}
Propchange: incubator/shiro/trunk/samples/spring-client/src/main/java/org/apache/shiro/samples/spring/ui/WebStartView.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/samples/spring-client/src/main/resources/webstart.spring.xml
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/spring-client/src/main/resources/webstart.spring.xml?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/spring-client/src/main/resources/webstart.spring.xml (original)
+++ incubator/shiro/trunk/samples/spring-client/src/main/resources/webstart.spring.xml Wed May 26 18:34:28 2010
@@ -1,49 +1,49 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<!--
- - Application context for Shiro WebStart sample application
- -->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
-http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
-
- <bean id="webStartView"
- class="org.apache.shiro.samples.spring.ui.WebStartView">
- <property name="sampleManager" ref="sampleManager"/>
- </bean>
-
- <bean id="sampleManager"
- class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
- <property name="serviceUrl" value="http://localhost:9080/shiro/remoting/sampleManager"/>
- <property name="serviceInterface" value="org.apache.shiro.samples.spring.SampleManager"/>
- <property name="remoteInvocationFactory" ref="secureRemoteInvocationFactory"/>
- </bean>
-
- <bean id="secureRemoteInvocationFactory"
- class="org.apache.shiro.spring.remoting.SecureRemoteInvocationFactory">
- <constructor-arg index="0">
- <util:constant static-field="org.apache.shiro.samples.spring.ui.WebStartDriver.LAUNCH_SESSION_ID"/>
- </constructor-arg>
- </bean>
-
-</beans>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<!--
+ - Application context for Shiro WebStart sample application
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
+
+ <bean id="webStartView"
+ class="org.apache.shiro.samples.spring.ui.WebStartView">
+ <property name="sampleManager" ref="sampleManager"/>
+ </bean>
+
+ <bean id="sampleManager"
+ class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
+ <property name="serviceUrl" value="http://localhost:9080/shiro/remoting/sampleManager"/>
+ <property name="serviceInterface" value="org.apache.shiro.samples.spring.SampleManager"/>
+ <property name="remoteInvocationFactory" ref="secureRemoteInvocationFactory"/>
+ </bean>
+
+ <bean id="secureRemoteInvocationFactory"
+ class="org.apache.shiro.spring.remoting.SecureRemoteInvocationFactory">
+ <constructor-arg index="0">
+ <util:constant static-field="org.apache.shiro.samples.spring.ui.WebStartDriver.LAUNCH_SESSION_ID"/>
+ </constructor-arg>
+ </bean>
+
+</beans>
Propchange: incubator/shiro/trunk/samples/spring-client/src/main/resources/webstart.spring.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/samples/spring-hibernate/pom.xml
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/spring-hibernate/pom.xml?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/spring-hibernate/pom.xml (original)
+++ incubator/shiro/trunk/samples/spring-hibernate/pom.xml Wed May 26 18:34:28 2010
@@ -1,146 +1,146 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<!--suppress osmorcNonOsgiMavenDependency -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.apache.shiro.samples</groupId>
- <artifactId>shiro-samples</artifactId>
- <version>1.1.0-incubating-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>samples-sprhib</artifactId>
- <name>Apache Shiro :: Samples :: Spring-Hibernate</name>
- <packaging>war</packaging>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <version>${jetty.version}</version>
- <!-- <configuration>
- <contextPath>/shirosprhib</contextPath>
- <connectors>
- <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
- <port>9080</port>
- <maxIdleTime>60000</maxIdleTime>
- </connector>
- </connectors>
- <requestLog implementation="org.mortbay.jetty.NCSARequestLog">
- <filename>./target/yyyy_mm_dd.request.log</filename>
- <retainDays>90</retainDays>
- <append>true</append>
- <extended>false</extended>
- <logTimeZone>GMT</logTimeZone>
- </requestLog>
- <systemProperties>
- <systemProperty>
- <name>org.apache.commons.logging.Log</name>
- <value>org.apache.commons.logging.impl.SimpleLog</value>
- </systemProperty>
- <systemProperty>
- <name>java.util.logging.config.file</name>
- <value>./target/test-classes/logging.properties</value>
- </systemProperty>
- </systemProperties>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>${hsqldb.version}</version>
- </dependency>
- </dependencies> -->
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-spring</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-web</artifactId>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate</artifactId>
- <scope>compile</scope>
- <optional>false</optional>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-annotations</artifactId>
- <scope>compile</scope>
- <optional>false</optional>
- </dependency>
- <!-- needed by Hibernate at runtime: -->
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jta_1.1_spec</artifactId>
- </dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- </dependency>
- <dependency>
- <groupId>net.sf.ehcache</groupId>
- <artifactId>ehcache</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- </dependency>
- </dependencies>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<!--suppress osmorcNonOsgiMavenDependency -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.shiro.samples</groupId>
+ <artifactId>shiro-samples</artifactId>
+ <version>1.1.0-incubating-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>samples-sprhib</artifactId>
+ <name>Apache Shiro :: Samples :: Spring-Hibernate</name>
+ <packaging>war</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>${jetty.version}</version>
+ <!-- <configuration>
+ <contextPath>/shirosprhib</contextPath>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>9080</port>
+ <maxIdleTime>60000</maxIdleTime>
+ </connector>
+ </connectors>
+ <requestLog implementation="org.mortbay.jetty.NCSARequestLog">
+ <filename>./target/yyyy_mm_dd.request.log</filename>
+ <retainDays>90</retainDays>
+ <append>true</append>
+ <extended>false</extended>
+ <logTimeZone>GMT</logTimeZone>
+ </requestLog>
+ <systemProperties>
+ <systemProperty>
+ <name>org.apache.commons.logging.Log</name>
+ <value>org.apache.commons.logging.impl.SimpleLog</value>
+ </systemProperty>
+ <systemProperty>
+ <name>java.util.logging.config.file</name>
+ <value>./target/test-classes/logging.properties</value>
+ </systemProperty>
+ </systemProperties>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>${hsqldb.version}</version>
+ </dependency>
+ </dependencies> -->
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shiro</groupId>
+ <artifactId>shiro-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shiro</groupId>
+ <artifactId>shiro-spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shiro</groupId>
+ <artifactId>shiro-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate</artifactId>
+ <scope>compile</scope>
+ <optional>false</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <scope>compile</scope>
+ <optional>false</optional>
+ </dependency>
+ <!-- needed by Hibernate at runtime: -->
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.ehcache</groupId>
+ <artifactId>ehcache</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
Propchange: incubator/shiro/trunk/samples/spring-hibernate/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/dao/BootstrapDataPopulator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/dao/HibernateDao.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/dao/HibernateUserDAO.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/dao/UserDAO.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/model/Role.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/model/User.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/security/SampleRealm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/service/DefaultUserService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/service/UserService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/CurrentUserInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/EditUserCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/EditUserValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/HomeController.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/LoginCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/LoginValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/ManageUsersController.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/SecurityController.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/SignupCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/SignupController.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/SignupValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/resources/ehcache.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/resources/hibernate.cfg.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/webapp/WEB-INF/applicationContext.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/webapp/WEB-INF/jsp/editUser.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/webapp/WEB-INF/jsp/home.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/webapp/WEB-INF/jsp/login.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/webapp/WEB-INF/jsp/manageUsers.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/webapp/WEB-INF/jsp/signup.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/webapp/WEB-INF/sprhib-servlet.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/webapp/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/webapp/styles/sample.css
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring-hibernate/src/main/webapp/unauthorized.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/BootstrapDataPopulator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/DefaultSampleManager.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/DefaultSampleManager.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/DefaultSampleManager.java (original)
+++ incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/DefaultSampleManager.java Wed May 26 18:34:28 2010
@@ -1,106 +1,106 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.shiro.samples.spring;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.session.Session;
-import org.apache.shiro.subject.Subject;
-
-
-/**
- * Default implementation of the {@link SampleManager} interface that stores
- * and retrieves a value from the user's session.
- *
- * @author Jeremy Haile
- * @since 0.1
- */
-public class DefaultSampleManager implements SampleManager {
-
- /*--------------------------------------------
- | C O N S T A N T S |
- ============================================*/
- /**
- * Key used to store the value in the user's session.
- */
- private static final String VALUE_KEY = "sample_value";
-
- /*--------------------------------------------
- | I N S T A N C E V A R I A B L E S |
- ============================================*/
- private static final Logger log = LoggerFactory.getLogger(DefaultSampleManager.class);
-
- /*--------------------------------------------
- | C O N S T R U C T O R S |
- ============================================*/
-
- /*--------------------------------------------
- | A C C E S S O R S / M O D I F I E R S |
- ============================================*/
-
- /*--------------------------------------------
- | M E T H O D S |
- ============================================*/
-
- public String getValue() {
- String value = null;
-
- Subject subject = SecurityUtils.getSubject();
- Session session = subject.getSession(false);
- if (session != null) {
- value = (String) session.getAttribute(VALUE_KEY);
- if (log.isDebugEnabled()) {
- log.debug("retrieving session key [" + VALUE_KEY + "] with value [" + value + "] on session with id [" + session.getId() + "]");
- }
- }
-
- return value;
- }
-
- public void setValue(String newValue) {
- Subject subject = SecurityUtils.getSubject();
- Session session = subject.getSession();
-
- if (log.isDebugEnabled()) {
- log.debug("saving session key [" + VALUE_KEY + "] with value [" + newValue + "] on session with id [" + session.getId() + "]");
- }
-
- session.setAttribute(VALUE_KEY, newValue);
- }
-
- public void secureMethod1() {
- if (log.isInfoEnabled()) {
- log.info("Secure method 1 called...");
- }
- }
-
- public void secureMethod2() {
- if (log.isInfoEnabled()) {
- log.info("Secure method 2 called...");
- }
- }
-
- public void secureMethod3() {
- if (log.isInfoEnabled()) {
- log.info("Secure method 3 called...");
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.samples.spring;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.session.Session;
+import org.apache.shiro.subject.Subject;
+
+
+/**
+ * Default implementation of the {@link SampleManager} interface that stores
+ * and retrieves a value from the user's session.
+ *
+ * @author Jeremy Haile
+ * @since 0.1
+ */
+public class DefaultSampleManager implements SampleManager {
+
+ /*--------------------------------------------
+ | C O N S T A N T S |
+ ============================================*/
+ /**
+ * Key used to store the value in the user's session.
+ */
+ private static final String VALUE_KEY = "sample_value";
+
+ /*--------------------------------------------
+ | I N S T A N C E V A R I A B L E S |
+ ============================================*/
+ private static final Logger log = LoggerFactory.getLogger(DefaultSampleManager.class);
+
+ /*--------------------------------------------
+ | C O N S T R U C T O R S |
+ ============================================*/
+
+ /*--------------------------------------------
+ | A C C E S S O R S / M O D I F I E R S |
+ ============================================*/
+
+ /*--------------------------------------------
+ | M E T H O D S |
+ ============================================*/
+
+ public String getValue() {
+ String value = null;
+
+ Subject subject = SecurityUtils.getSubject();
+ Session session = subject.getSession(false);
+ if (session != null) {
+ value = (String) session.getAttribute(VALUE_KEY);
+ if (log.isDebugEnabled()) {
+ log.debug("retrieving session key [" + VALUE_KEY + "] with value [" + value + "] on session with id [" + session.getId() + "]");
+ }
+ }
+
+ return value;
+ }
+
+ public void setValue(String newValue) {
+ Subject subject = SecurityUtils.getSubject();
+ Session session = subject.getSession();
+
+ if (log.isDebugEnabled()) {
+ log.debug("saving session key [" + VALUE_KEY + "] with value [" + newValue + "] on session with id [" + session.getId() + "]");
+ }
+
+ session.setAttribute(VALUE_KEY, newValue);
+ }
+
+ public void secureMethod1() {
+ if (log.isInfoEnabled()) {
+ log.info("Secure method 1 called...");
+ }
+ }
+
+ public void secureMethod2() {
+ if (log.isInfoEnabled()) {
+ log.info("Secure method 2 called...");
+ }
+ }
+
+ public void secureMethod3() {
+ if (log.isInfoEnabled()) {
+ log.info("Secure method 3 called...");
+ }
+ }
+}
Propchange: incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/DefaultSampleManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/JnlpController.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/JnlpController.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/JnlpController.java (original)
+++ incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/JnlpController.java Wed May 26 18:34:28 2010
@@ -1,98 +1,98 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.shiro.samples.spring.web;
-
-import java.util.HashMap;
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.springframework.web.servlet.ModelAndView;
-import org.springframework.web.servlet.mvc.AbstractController;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.session.Session;
-import org.apache.shiro.subject.Subject;
-
-/**
- * Controller used to dynamically build a JNLP file used to launch the Shiro
- * Spring WebStart sample application.
- *
- * @author Jeremy Haile
- * @since 0.1
- */
-public class JnlpController extends AbstractController {
-
- /*--------------------------------------------
- | C O N S T A N T S |
- ============================================*/
-
- /*--------------------------------------------
- | I N S T A N C E V A R I A B L E S |
- ============================================*/
- private String jnlpView;
-
- /*--------------------------------------------
- | C O N S T R U C T O R S |
- ============================================*/
-
- /*--------------------------------------------
- | A C C E S S O R S / M O D I F I E R S |
- ============================================*/
-
- public void setJnlpView(String jnlpView) {
- this.jnlpView = jnlpView;
- }
-
- /*--------------------------------------------
- | M E T H O D S |
- ============================================*/
-
- protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
-
- Subject subject = SecurityUtils.getSubject();
- Session session = null;
-
- if (subject != null) {
- session = subject.getSession();
- }
- if (session == null) {
- String msg = "Expected a non-null Shiro session.";
- throw new IllegalArgumentException(msg);
- }
-
- StringBuilder sb = new StringBuilder();
- sb.append("http://");
- sb.append(request.getServerName());
- if (request.getServerPort() != 80) {
- sb.append(":");
- sb.append(request.getServerPort());
- }
- sb.append(request.getContextPath());
-
- // prevent JNLP caching by setting response headers
- response.setHeader("cache-control", "no-cache");
- response.setHeader("pragma", "no-cache");
-
- Map<String, Object> model = new HashMap<String, Object>();
- model.put("codebaseUrl", sb.toString());
- model.put("sessionId", session.getId());
- return new ModelAndView(jnlpView, model);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.samples.spring.web;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.AbstractController;
+
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.session.Session;
+import org.apache.shiro.subject.Subject;
+
+/**
+ * Controller used to dynamically build a JNLP file used to launch the Shiro
+ * Spring WebStart sample application.
+ *
+ * @author Jeremy Haile
+ * @since 0.1
+ */
+public class JnlpController extends AbstractController {
+
+ /*--------------------------------------------
+ | C O N S T A N T S |
+ ============================================*/
+
+ /*--------------------------------------------
+ | I N S T A N C E V A R I A B L E S |
+ ============================================*/
+ private String jnlpView;
+
+ /*--------------------------------------------
+ | C O N S T R U C T O R S |
+ ============================================*/
+
+ /*--------------------------------------------
+ | A C C E S S O R S / M O D I F I E R S |
+ ============================================*/
+
+ public void setJnlpView(String jnlpView) {
+ this.jnlpView = jnlpView;
+ }
+
+ /*--------------------------------------------
+ | M E T H O D S |
+ ============================================*/
+
+ protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
+
+ Subject subject = SecurityUtils.getSubject();
+ Session session = null;
+
+ if (subject != null) {
+ session = subject.getSession();
+ }
+ if (session == null) {
+ String msg = "Expected a non-null Shiro session.";
+ throw new IllegalArgumentException(msg);
+ }
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("http://");
+ sb.append(request.getServerName());
+ if (request.getServerPort() != 80) {
+ sb.append(":");
+ sb.append(request.getServerPort());
+ }
+ sb.append(request.getContextPath());
+
+ // prevent JNLP caching by setting response headers
+ response.setHeader("cache-control", "no-cache");
+ response.setHeader("pragma", "no-cache");
+
+ Map<String, Object> model = new HashMap<String, Object>();
+ model.put("codebaseUrl", sb.toString());
+ model.put("sessionId", session.getId());
+ return new ModelAndView(jnlpView, model);
+ }
+}
Propchange: incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/JnlpController.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/SessionValueCommand.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/SessionValueCommand.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/SessionValueCommand.java (original)
+++ incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/SessionValueCommand.java Wed May 26 18:34:28 2010
@@ -1,58 +1,58 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.shiro.samples.spring.web;
-
-/**
- * Command object used to bind parameters when submitting a value to be
- * stored in the user's session from the index page.
- *
- * @author Jeremy Haile
- * @since 0.1
- */
-public class SessionValueCommand {
-
- /*--------------------------------------------
- | C O N S T A N T S |
- ============================================*/
-
- /*--------------------------------------------
- | I N S T A N C E V A R I A B L E S |
- ============================================*/
- private String value;
-
- /*--------------------------------------------
- | C O N S T R U C T O R S |
- ============================================*/
-
- /*--------------------------------------------
- | A C C E S S O R S / M O D I F I E R S |
- ============================================*/
-
- /*--------------------------------------------
- | M E T H O D S |
- ============================================*/
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.samples.spring.web;
+
+/**
+ * Command object used to bind parameters when submitting a value to be
+ * stored in the user's session from the index page.
+ *
+ * @author Jeremy Haile
+ * @since 0.1
+ */
+public class SessionValueCommand {
+
+ /*--------------------------------------------
+ | C O N S T A N T S |
+ ============================================*/
+
+ /*--------------------------------------------
+ | I N S T A N C E V A R I A B L E S |
+ ============================================*/
+ private String value;
+
+ /*--------------------------------------------
+ | C O N S T R U C T O R S |
+ ============================================*/
+
+ /*--------------------------------------------
+ | A C C E S S O R S / M O D I F I E R S |
+ ============================================*/
+
+ /*--------------------------------------------
+ | M E T H O D S |
+ ============================================*/
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
Propchange: incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/SessionValueCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring/src/main/resources/ehcache.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/samples/spring/src/main/resources/sample-users.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/applicationContext.xml?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/applicationContext.xml (original)
+++ incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/applicationContext.xml Wed May 26 18:34:28 2010
@@ -1,134 +1,134 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
-
- <!-- Sample RDBMS data source that would exist in any application - not Shiro related. -->
- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
- <property name="url" value="jdbc:hsqldb:mem:shiro-spring"/>
- <property name="username" value="sa"/>
- </bean>
- <!-- Populates the sample database with sample users and roles. -->
- <bean id="bootstrapDataPopulator" class="org.apache.shiro.samples.spring.BootstrapDataPopulator">
- <property name="dataSource" ref="dataSource"/>
- </bean>
-
- <!-- Simulated business-tier "Manager", not Shiro related, just an example -->
- <bean id="sampleManager" class="org.apache.shiro.samples.spring.DefaultSampleManager"/>
-
- <!-- =========================================================
- Shiro Core Components - Not Spring Specific
- ========================================================= -->
- <!-- Shiro's main business-tier object for web-enabled applications
- (use DefaultSecurityManager instead when there is no web environment)-->
- <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
- <property name="cacheManager" ref="cacheManager"/>
- <!-- Single realm app. If you have multiple realms, use the 'realms' property instead. -->
- <property name="sessionMode" value="native"/>
- <property name="realm" ref="jdbcRealm"/>
- </bean>
-
- <!-- Let's use some enterprise caching support for better performance. You can replace this with any enterprise
- caching framework implementation that you like (Terracotta+Ehcache, Coherence, GigaSpaces, etc -->
- <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
- <!-- Set a net.sf.ehcache.CacheManager instance here if you already have one. If not, a new one
- will be creaed with a default config:
- <property name="cacheManager" ref="ehCacheManager"/> -->
- <!-- If you don't have a pre-built net.sf.ehcache.CacheManager instance to inject, but you want
- a specific Ehcache configuration to be used, specify that here. If you don't, a default
- will be used.:
- <property name="cacheManagerConfigFile" value="classpath:some/path/to/ehcache.xml"/> -->
- </bean>
-
- <!-- Used by the SecurityManager to access security data (users, roles, etc).
- Many other realm implementations can be used too (PropertiesRealm,
- LdapRealm, etc. -->
- <bean id="jdbcRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
- <property name="name" value="jdbcRealm"/>
- <property name="dataSource" ref="dataSource"/>
- <property name="credentialsMatcher">
- <!-- The 'bootstrapDataPopulator' Sha256 hashes the password
- (using the username as the salt) then base64 encodes it: -->
- <bean class="org.apache.shiro.authc.credential.Sha256CredentialsMatcher">
- <!-- true means hex encoded, false means base64 encoded -->
- <property name="storedCredentialsHexEncoded" value="false"/>
- <!-- We salt the password using the username, the most common practice: -->
- <property name="hashSalted" value="true"/>
- </bean>
- </property>
- </bean>
-
- <!-- =========================================================
- Shiro Spring-specific integration
- ========================================================= -->
- <!-- Post processor that automatically invokes init() and destroy() methods
- for Spring-configured Shiro objects so you don't have to
- 1) specify an init-method and destroy-method attributes for every bean
- definition and
- 2) even know which Shiro objects require these methods to be
- called. -->
- <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
-
- <!-- Enable Shiro Annotations for Spring-configured beans. Only run after
- the lifecycleBeanProcessor has run: -->
- <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
- depends-on="lifecycleBeanPostProcessor"/>
- <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
- <property name="securityManager" ref="securityManager"/>
- </bean>
-
- <!-- Secure Spring remoting: Ensure any Spring Remoting method invocations can be associated
- with a Subject for security checks. -->
- <bean id="secureRemoteInvocationExecutor" class="org.apache.shiro.spring.remoting.SecureRemoteInvocationExecutor">
- <property name="securityManager" ref="securityManager"/>
- </bean>
-
- <!-- Define the Shiro Filter here (as a FactoryBean) instead of directly in web.xml -
- web.xml uses the DelegatingFilterProxy to access this bean. This allows us
- to wire things with more control as well utilize nice Spring things such as
- PropertiesPlaceholderConfigurer and abstract beans or anything else we might need: -->
- <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
- <property name="securityManager" ref="securityManager"/>
- <property name="loginUrl" value="/s/login"/>
- <property name="successUrl" value="/s/index"/>
- <property name="unauthorizedUrl" value="/s/unauthorized"/>
- <!-- The 'filters' property is not necessary since any declared javax.servlet.Filter bean
- defined will be automatically acquired and available via its beanName in chain
- definitions, but you can perform overrides or parent/child consolidated configuration
- here if you like: -->
- <!-- <property name="filters">
- <util:map>
- <entry key="aName" value-ref="someFilterPojo"/>
- </util:map>
- </property> -->
- <property name="filterChainDefinitions">
- <value>
- /s/index = authc
- /s/shiro.jnlp = authc, user
- </value>
- </property>
- </bean>
-
-</beans>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
+
+ <!-- Sample RDBMS data source that would exist in any application - not Shiro related. -->
+ <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:mem:shiro-spring"/>
+ <property name="username" value="sa"/>
+ </bean>
+ <!-- Populates the sample database with sample users and roles. -->
+ <bean id="bootstrapDataPopulator" class="org.apache.shiro.samples.spring.BootstrapDataPopulator">
+ <property name="dataSource" ref="dataSource"/>
+ </bean>
+
+ <!-- Simulated business-tier "Manager", not Shiro related, just an example -->
+ <bean id="sampleManager" class="org.apache.shiro.samples.spring.DefaultSampleManager"/>
+
+ <!-- =========================================================
+ Shiro Core Components - Not Spring Specific
+ ========================================================= -->
+ <!-- Shiro's main business-tier object for web-enabled applications
+ (use DefaultSecurityManager instead when there is no web environment)-->
+ <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
+ <property name="cacheManager" ref="cacheManager"/>
+ <!-- Single realm app. If you have multiple realms, use the 'realms' property instead. -->
+ <property name="sessionMode" value="native"/>
+ <property name="realm" ref="jdbcRealm"/>
+ </bean>
+
+ <!-- Let's use some enterprise caching support for better performance. You can replace this with any enterprise
+ caching framework implementation that you like (Terracotta+Ehcache, Coherence, GigaSpaces, etc -->
+ <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
+ <!-- Set a net.sf.ehcache.CacheManager instance here if you already have one. If not, a new one
+ will be creaed with a default config:
+ <property name="cacheManager" ref="ehCacheManager"/> -->
+ <!-- If you don't have a pre-built net.sf.ehcache.CacheManager instance to inject, but you want
+ a specific Ehcache configuration to be used, specify that here. If you don't, a default
+ will be used.:
+ <property name="cacheManagerConfigFile" value="classpath:some/path/to/ehcache.xml"/> -->
+ </bean>
+
+ <!-- Used by the SecurityManager to access security data (users, roles, etc).
+ Many other realm implementations can be used too (PropertiesRealm,
+ LdapRealm, etc. -->
+ <bean id="jdbcRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
+ <property name="name" value="jdbcRealm"/>
+ <property name="dataSource" ref="dataSource"/>
+ <property name="credentialsMatcher">
+ <!-- The 'bootstrapDataPopulator' Sha256 hashes the password
+ (using the username as the salt) then base64 encodes it: -->
+ <bean class="org.apache.shiro.authc.credential.Sha256CredentialsMatcher">
+ <!-- true means hex encoded, false means base64 encoded -->
+ <property name="storedCredentialsHexEncoded" value="false"/>
+ <!-- We salt the password using the username, the most common practice: -->
+ <property name="hashSalted" value="true"/>
+ </bean>
+ </property>
+ </bean>
+
+ <!-- =========================================================
+ Shiro Spring-specific integration
+ ========================================================= -->
+ <!-- Post processor that automatically invokes init() and destroy() methods
+ for Spring-configured Shiro objects so you don't have to
+ 1) specify an init-method and destroy-method attributes for every bean
+ definition and
+ 2) even know which Shiro objects require these methods to be
+ called. -->
+ <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
+
+ <!-- Enable Shiro Annotations for Spring-configured beans. Only run after
+ the lifecycleBeanProcessor has run: -->
+ <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
+ depends-on="lifecycleBeanPostProcessor"/>
+ <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
+ <property name="securityManager" ref="securityManager"/>
+ </bean>
+
+ <!-- Secure Spring remoting: Ensure any Spring Remoting method invocations can be associated
+ with a Subject for security checks. -->
+ <bean id="secureRemoteInvocationExecutor" class="org.apache.shiro.spring.remoting.SecureRemoteInvocationExecutor">
+ <property name="securityManager" ref="securityManager"/>
+ </bean>
+
+ <!-- Define the Shiro Filter here (as a FactoryBean) instead of directly in web.xml -
+ web.xml uses the DelegatingFilterProxy to access this bean. This allows us
+ to wire things with more control as well utilize nice Spring things such as
+ PropertiesPlaceholderConfigurer and abstract beans or anything else we might need: -->
+ <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
+ <property name="securityManager" ref="securityManager"/>
+ <property name="loginUrl" value="/s/login"/>
+ <property name="successUrl" value="/s/index"/>
+ <property name="unauthorizedUrl" value="/s/unauthorized"/>
+ <!-- The 'filters' property is not necessary since any declared javax.servlet.Filter bean
+ defined will be automatically acquired and available via its beanName in chain
+ definitions, but you can perform overrides or parent/child consolidated configuration
+ here if you like: -->
+ <!-- <property name="filters">
+ <util:map>
+ <entry key="aName" value-ref="someFilterPojo"/>
+ </util:map>
+ </property> -->
+ <property name="filterChainDefinitions">
+ <value>
+ /s/index = authc
+ /s/shiro.jnlp = authc, user
+ </value>
+ </property>
+ </bean>
+
+</beans>
Propchange: incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/applicationContext.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/remoting-servlet.xml
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/remoting-servlet.xml?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/remoting-servlet.xml (original)
+++ incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/remoting-servlet.xml Wed May 26 18:34:28 2010
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
-
-<!--
- - Application context definition for "remoting" DispatcherServlet.
- -->
-<beans>
-
- <bean name="/sampleManager" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
- <property name="service" ref="sampleManager"/>
- <property name="serviceInterface" value="org.apache.shiro.samples.spring.SampleManager"/>
- <property name="remoteInvocationExecutor" ref="secureRemoteInvocationExecutor"/>
- </bean>
-
-</beans>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<!--
+ - Application context definition for "remoting" DispatcherServlet.
+ -->
+<beans>
+
+ <bean name="/sampleManager" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
+ <property name="service" ref="sampleManager"/>
+ <property name="serviceInterface" value="org.apache.shiro.samples.spring.SampleManager"/>
+ <property name="remoteInvocationExecutor" ref="secureRemoteInvocationExecutor"/>
+ </bean>
+
+</beans>