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.activemq.shiro.authz; 018 019import org.apache.shiro.authz.Permission; 020import org.apache.shiro.authz.permission.WildcardPermission; 021import org.apache.shiro.authz.permission.WildcardPermissionResolver; 022 023/** 024 * {@link WildcardPermissionResolver} that can create case-sensitive (or case-insensitive) 025 * {@link WildcardPermission} instances as expected for ActiveMQ. 026 * 027 * @since 5.10.0 028 */ 029public class ActiveMQPermissionResolver extends WildcardPermissionResolver { 030 031 private boolean caseSensitive; 032 033 public ActiveMQPermissionResolver() { 034 caseSensitive = true; 035 } 036 037 public boolean isCaseSensitive() { 038 return caseSensitive; 039 } 040 041 public void setCaseSensitive(boolean caseSensitive) { 042 this.caseSensitive = caseSensitive; 043 } 044 045 /** 046 * Creates a new {@link WildcardPermission} instance, with case-sensitivity determined by the 047 * {@link #isCaseSensitive() caseSensitive} setting. 048 * 049 * @param permissionString the wildcard permission-formatted string. 050 * @return a new {@link WildcardPermission} instance, with case-sensitivity determined by the 051 * {@link #isCaseSensitive() caseSensitive} setting. 052 */ 053 @Override 054 public Permission resolvePermission(String permissionString) { 055 return new ActiveMQWildcardPermission(permissionString, isCaseSensitive()); 056 } 057}