SAPAccessControlPolicy extends BaseAccessControlPolicy { protected boolean matches( String className, String methodName, String allowedServiceSignature) { String allowedClassName = null; String allowedMethodName = null; int index = allowedServiceSignature.indexOf(CharPool.POUND); if (index > -1) { allowedClassName = allowedServiceSignature.substring(0, index); allowedMethodName = allowedServiceSignature.substring(index + 1); } else { allowedClassName = allowedServiceSignature; } boolean wildcardMatchClass = false; if (Validator.isNotNull(allowedClassName) && allowedClassName.endsWith(StringPool.STAR)) { allowedClassName = allowedClassName.substring( 0, allowedClassName.length() - 1); wildcardMatchClass = true; } boolean wildcardMatchMethod = false; if (Validator.isNotNull(allowedMethodName) && allowedMethodName.endsWith(StringPool.STAR)) { allowedMethodName = allowedMethodName.substring( 0, allowedMethodName.length() - 1); wildcardMatchMethod = true; } if (Validator.isNotNull(allowedClassName) && Validator.isNotNull(allowedMethodName)) { if (wildcardMatchClass && !className.startsWith(allowedClassName)) { return false; } else if (!wildcardMatchClass && !className.equals(allowedClassName)) { return false; } if (wildcardMatchMethod && !methodName.startsWith(allowedMethodName)) { return false; } else if (!wildcardMatchMethod && !methodName.equals(allowedMethodName)) { return false; } return true; } else if (Validator.isNotNull(allowedClassName)) { if (wildcardMatchClass && !className.startsWith(allowedClassName)) { return false; } else if (!wildcardMatchClass && !className.equals(allowedClassName)) { return false; } return true; } else if (Validator.isNotNull(allowedMethodName)) { if (wildcardMatchMethod && !methodName.startsWith(allowedMethodName)) { return false; } else if (!wildcardMatchMethod && !methodName.equals(allowedMethodName)) { return false; } return true; } else if (wildcardMatchClass && Validator.isNull(allowedClassName)) { return true; } return false; }  @Override void onServiceRemoteAccess(
			Method method, Object[] arguments,
			AccessControlled accessControlled);  }
@Test public void testMatches() { Assert.assertTrue( _sapAccessControlPolicy.matches( "com.liferay.portal.kernel.service.UserService", "getUserById", "*")); Assert.assertTrue( _sapAccessControlPolicy.matches( "com.liferay.portal.kernel.service.UserService", "getUserById", "com.liferay.portal.kernel.service.*")); Assert.assertTrue( _sapAccessControlPolicy.matches( "com.liferay.portal.kernel.service.UserService", "getUserById", "com.liferay.portal.kernel.service.UserService")); Assert.assertTrue( _sapAccessControlPolicy.matches( "com.liferay.portal.kernel.service.UserService", "getUserById", "com.liferay.portal.kernel.service.UserService#getUserById")); Assert.assertTrue( _sapAccessControlPolicy.matches( "com.liferay.portal.kernel.service.UserService", "getUserById", "com.liferay.portal.kernel.service.UserService#get*")); Assert.assertTrue( _sapAccessControlPolicy.matches( "com.liferay.portal.kernel.service.UserService", "getUserById", "com.liferay.portal.kernel.service.*#get*")); Assert.assertTrue( _sapAccessControlPolicy.matches( "com.liferay.portal.kernel.service.UserService", "getUserById", "#get*")); Assert.assertFalse( _sapAccessControlPolicy.matches( "com.liferay.portal.kernel.service.UserService", "getUserById", "com.liferay.portlet.*#get*")); Assert.assertFalse( _sapAccessControlPolicy.matches( "com.liferay.portal.kernel.service.UserService", "getUserById", "com.liferay.portal.service.*#update*")); }