1 package org.codehaus.redback.integration.interceptor;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import java.util.ArrayList;
23 import java.util.List;
25 import org.apache.archiva.redback.rbac.Resource;
30 * @author: Jesse McConnell <jesse@codehaus.org>
33 public class SecureActionBundle
35 private boolean requiresAuthentication = false;
37 private List<AuthorizationTuple> authorizationTuples = new ArrayList<AuthorizationTuple>();
39 public static final SecureActionBundle OPEN;
41 public static final SecureActionBundle AUTHONLY;
45 OPEN = new SecureActionBundle();
46 AUTHONLY = new SecureActionBundle();
47 AUTHONLY.setRequiresAuthentication( true );
51 * Add an authorization tuple
55 * @throws SecureActionException
57 public void addRequiredAuthorization( String operation, String resource )
58 throws SecureActionException
60 if ( operation != null && resource != null )
62 authorizationTuples.add( new AuthorizationTuple( operation, resource ) );
66 throw new SecureActionException( "operation and resource are required to be non-null" );
71 * add an authorization tuple, assuming the resource part of it is Resource.GLOBAL
74 * @throws SecureActionException
76 public void addRequiredAuthorization( String operation )
77 throws SecureActionException
79 if ( operation != null )
81 authorizationTuples.add( new AuthorizationTuple( operation, Resource.GLOBAL ) );
85 throw new SecureActionException( "operation is required to be non-null" );
89 public List<AuthorizationTuple> getAuthorizationTuples()
91 return authorizationTuples;
94 public boolean requiresAuthentication()
96 return requiresAuthentication;
99 public void setRequiresAuthentication( boolean requiresAuthentication )
101 this.requiresAuthentication = requiresAuthentication;
104 public static class AuthorizationTuple
106 private String operation;
108 private String resource;
110 public AuthorizationTuple( String operation, String resource )
112 this.operation = operation;
113 this.resource = resource;
116 public String getOperation()
121 public String getResource()
127 public String toString()
129 return "AuthorizationTuple[" + operation + "," + resource + "]";