View Javadoc

1   /* Copyright 2004, 2005 Acegi Technology Pty Limited
2    *
3    * Licensed under the Apache License, Version 2.0 (the "License");
4    * you may not use this file except in compliance with the License.
5    * You may obtain a copy of the License at
6    *
7    *     http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  
16  package org.acegisecurity.annotation;
17  
18  import java.lang.annotation.ElementType;
19  import java.lang.annotation.Retention;
20  import java.lang.annotation.RetentionPolicy;
21  import java.lang.annotation.Target;
22  
23  /***
24   * Java 5 annotation for describing service layer security attributes.
25   * 
26   * <p>The <code>Secured</code> annotation is used to define a list of security 
27   * configuration attributes for business methods.  This annotation can be used 
28   * as a Java 5 alternative to XML configuration.
29   * <p>For example:
30   * <pre>
31   *     &#64;Secured ({"ROLE_USER"})
32   *     public void create(Contact contact);
33   *     
34   *     &#64;Secured ({"ROLE_USER", "ROLE_ADMIN"})
35   *     public void update(Contact contact);
36   *     
37   *     &#64;Secured ({"ROLE_ADMIN"})
38   *     public void delete(Contact contact);
39   * </pre> 
40   * @author Mark St.Godard
41   * @version $Id: Secured.java,v 1.2 2005/11/17 00:55:48 benalex Exp $
42   */
43  @Target({ElementType.METHOD, ElementType.TYPE})
44  @Retention(RetentionPolicy.RUNTIME)
45  public @interface Secured {
46      //~ Methods ================================================================
47  
48      /***
49       * Returns the list of security configuration attributes. 
50       *   (i.e. ROLE_USER, ROLE_ADMIN etc.)
51       * @return String[] The secure method attributes 
52       */
53      public String[] value();
54  }