001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.authroles.authorization.strategies.role.annotations; 018 019import java.lang.annotation.Documented; 020import java.lang.annotation.ElementType; 021import java.lang.annotation.Inherited; 022import java.lang.annotation.Retention; 023import java.lang.annotation.RetentionPolicy; 024import java.lang.annotation.Target; 025 026/** 027 * Annotation for configuring what roles are allowed for instantiation the annotated component or 028 * package. This annotation can be used for classes and packages. For classes it can be used like this: 029 * 030 * <pre> 031 * // only users with role ADMIN are allowed to create instances of this page, whether it is 032 * // either bookmarkable or not 033 * @AuthorizeInstantiation("ADMIN") 034 * public class AdminAnnotationsBookmarkablePage extends WebPage 035 * </pre> 036 * 037 * For packages the annotation needs to be specified in the <code>package-info.java</code> file: 038 * 039 * <pre> 040 * // only users with role ADMIN are allowed to create instances of pages in this package 041 * @AuthorizeInstantiation("ADMIN") 042 * package package_name; 043 * 044 * import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation; 045 * </pre> 046 * 047 * @see org.apache.wicket.authorization.IAuthorizationStrategy 048 * @see AnnotationsRoleAuthorizationStrategy 049 * @see AuthorizeActions 050 * @see AuthorizeAction 051 * 052 * @author Eelco hillenius 053 */ 054@Retention(RetentionPolicy.RUNTIME) 055@Target({ ElementType.PACKAGE, ElementType.TYPE }) 056@Documented 057@Inherited 058public @interface AuthorizeInstantiation { 059 060 /** 061 * Gets the roles that are allowed to take the action. 062 * 063 * @return the roles that are allowed. Returns a zero length array by default 064 */ 065 String[] value() default { }; 066}