- static String allow = "allow";
- String dClass = null;
- private boolean useAuthClass;
- ApiAuthorizationCheckInterface perm = null;
-
- public ApiPolicy() {
- DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
- dClass = p.getProperty( "ApiPermission.Class", allow );
- logger.info( "ApiPolicy implements " + dClass);
- if ( dClass.equalsIgnoreCase( allow )) {
- useAuthClass = false;
- return;
- }
- useAuthClass = true;
- logger.info( "dClass=" + dClass + " useAuthClass=" + useAuthClass );
- try {
- perm = (ApiAuthorizationCheckInterface) (Class.forName(dClass).newInstance());
- } catch (Exception ee ) {
- errorLogger.error(DmaapbcLogMessageEnum.UNEXPECTED_CONDITION, "attempting to instantiate " + dClass );
- errorLogger.error( "trace is: " + ee );
- }
- }
-
- public void check( String mechid, String pwd, DmaapPerm p ) throws AuthenticationErrorException {
- if ( dClass.equalsIgnoreCase( allow )) {
- return;
- }
-
- // execute check of loaded class
- perm.check( mechid, pwd, p );
-
- }
-
- public boolean getUseAuthClass() {
- return useAuthClass;
- }