2 * Copyright 2005-2010 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.security.authorization;
18 import javax.persistence.Access;
19 import javax.persistence.AccessType;
20 import javax.persistence.Column;
21 import javax.persistence.DiscriminatorValue;
22 import javax.persistence.Entity;
25 * Determiens if an operation is a subclass of a specified operation.
28 @DiscriminatorValue("ISA")
29 @Access(AccessType.PROPERTY)
30 public class IsaOperationCondition extends AbstractOperationCondition {
32 * Operation that the other operation must be a subclass of.
34 private Class<? extends Operation> operation;
37 * Constructs the condition.
40 * Operation that an operation must be an instance of.
42 public IsaOperationCondition(Class<? extends Operation> aOperation) {
43 operation = aOperation;
50 public IsaOperationCondition() {
58 * org.wamblee.security.authorization.OperationCondition#matches(org.wamblee
59 * .security.authorization.Operation)
61 public boolean matches(Operation aOperation) {
62 return operation.isInstance(aOperation);
66 * Gets the operation as a string. For OR mapping only.
68 * @return Operation string.
70 @Column(name = "CLASSNAME")
71 protected String getOperationString() {
72 if (operation == null) {
76 return operation.getName();
80 * Sets the operation as a string. For OR mapping only.
86 protected void setOperationString(String aOperation) {
87 if (aOperation == null) {
92 operation = (Class<? extends Operation>) Class.forName(aOperation);
93 } catch (Exception e) {
94 throw new IllegalArgumentException("Unknown class '" + aOperation +
102 * @see java.lang.Object#toString()
105 public String toString() {
106 return "IsaOperationCondition(operation=" + operation.getName() + ")";