// Path: src/main/java/act/aaa/event/AAAInitialized.java
// public class AAAInitialized extends ActEvent<AAAInitialized> {
// }
// 
// Path: src/main/java/act/aaa/util/AAAAdaptor.java
// public class AAAAdaptor extends ActAAAService.Base {
// 
//     private boolean passwordTypeIsCharArray;
//     private Method passwordVerifier;
//     private Method roleProviderMethod;
//     private Method permissionProviderMethod;
//     private Method privilegeProviderMethod;
// 
//     public AAAAdaptor(Class userType, boolean passwordTypeIsCharArray, Method passwordVerifier, Method roleProviderMethod, Method permissionProviderMethod, Method privilegeProviderMethod) {
//         super(userType);
//         this.passwordTypeIsCharArray = passwordTypeIsCharArray;
//         this.passwordVerifier = passwordVerifier;
//         this.roleProviderMethod = roleProviderMethod;
//         this.permissionProviderMethod = permissionProviderMethod;
//         this.privilegeProviderMethod = privilegeProviderMethod;
//     }
// 
//     @Override
//     protected boolean verifyPassword(Object user, char[] password) {
//         if (passwordTypeIsCharArray) {
//             return $.invokeVirtual(user, passwordVerifier, password);
//         } else {
//             String passwordStr = new String(password);
//             return $.invokeVirtual(user, passwordVerifier, passwordStr);
//         }
//     }
// 
//     @Override
//     protected Set<String> rolesOf(Object user) {
//         if (null == roleProviderMethod) {
//             return C.Set();
//         }
//         String roles = $.invokeVirtual(user, roleProviderMethod);
//         if (S.blank(roles)) {
//             return C.Set();
//         }
//         return C.Set(S.fastSplit(roles, StringTokenSet.SEPARATOR));
//     }
// 
//     @Override
//     protected Set<String> permissionsOf(Object user) {
//         if (null == permissionProviderMethod) {
//             return C.Set();
//         }
//         String permissions = $.invokeVirtual(user, permissionProviderMethod);
//         if (S.blank(permissions)) {
//             return C.Set();
//         }
//         return C.Set(S.fastSplit(permissions, StringTokenSet.SEPARATOR));
//     }
// 
//     @Override
//     protected Integer privilegeOf(Object user) {
//         if (null == privilegeProviderMethod) {
//             return null;
//         }
//         Object o = $.invokeVirtual(user, privilegeProviderMethod);
//         if (null == o) {
//             return null;
//         }
//         if (o instanceof Integer) {
//             return (Integer) o;
//         }
//         Privilege p = AAALookup.privilege((String) o);
//         return null == p ? null : p.getLevel();
//     }
// 
// }


import org.osgl.aaa.*;
import org.osgl.aaa.impl.DumbAuditor;
import org.osgl.util.E;
import javax.inject.Inject;
import java.lang.reflect.Method;
import java.util.EventObject;
import act.Act;
import act.aaa.event.AAAInitialized;
import act.aaa.util.AAAAdaptor;
import act.app.App;
import act.app.event.SysEventId;
import act.event.ActEventListenerBase;
import act.job.OnAppStart;
import act.util.LogSupport;
import act.util.Stateless;
import act.util.SubClassFinder;
package act.aaa;

/*-
 * #%L
 * ACT AAA Plugin
 * %%
 * Copyright (C) 2015 - 2017 ActFramework
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */



@SuppressWarnings("unused")
@Stateless
public class AAAServiceFinder<T> extends LogSupport {

    private App app;

    @Inject
    public AAAServiceFinder(App app) {
        this.app = app;
    }

    @SubClassFinder(callOn = SysEventId.PRE_START)
    public void foundActAAAService(Class<? extends ActAAAService> serviceType) {
// Path: src/main/java/act/aaa/event/AAAInitialized.java
// public class AAAInitialized extends ActEvent<AAAInitialized> {
// }
// 
// Path: src/main/java/act/aaa/util/AAAAdaptor.java
// public class AAAAdaptor extends ActAAAService.Base {
// 
//     private boolean passwordTypeIsCharArray;
//     private Method passwordVerifier;
//     private Method roleProviderMethod;
//     private Method permissionProviderMethod;
//     private Method privilegeProviderMethod;
// 
//     public AAAAdaptor(Class userType, boolean passwordTypeIsCharArray, Method passwordVerifier, Method roleProviderMethod, Method permissionProviderMethod, Method privilegeProviderMethod) {
//         super(userType);
//         this.passwordTypeIsCharArray = passwordTypeIsCharArray;
//         this.passwordVerifier = passwordVerifier;
//         this.roleProviderMethod = roleProviderMethod;
//         this.permissionProviderMethod = permissionProviderMethod;
//         this.privilegeProviderMethod = privilegeProviderMethod;
//     }
// 
//     @Override
//     protected boolean verifyPassword(Object user, char[] password) {
//         if (passwordTypeIsCharArray) {
//             return $.invokeVirtual(user, passwordVerifier, password);
//         } else {
//             String passwordStr = new String(password);
//             return $.invokeVirtual(user, passwordVerifier, passwordStr);
//         }
//     }
// 
//     @Override
//     protected Set<String> rolesOf(Object user) {
//         if (null == roleProviderMethod) {
//             return C.Set();
//         }
//         String roles = $.invokeVirtual(user, roleProviderMethod);
//         if (S.blank(roles)) {
//             return C.Set();
//         }
//         return C.Set(S.fastSplit(roles, StringTokenSet.SEPARATOR));
//     }
// 
//     @Override
//     protected Set<String> permissionsOf(Object user) {
//         if (null == permissionProviderMethod) {
//             return C.Set();
//         }
//         String permissions = $.invokeVirtual(user, permissionProviderMethod);
//         if (S.blank(permissions)) {
//             return C.Set();
//         }
//         return C.Set(S.fastSplit(permissions, StringTokenSet.SEPARATOR));
//     }
// 
//     @Override
//     protected Integer privilegeOf(Object user) {
//         if (null == privilegeProviderMethod) {
//             return null;
//         }
//         Object o = $.invokeVirtual(user, privilegeProviderMethod);
//         if (null == o) {
//             return null;
//         }
//         if (o instanceof Integer) {
//             return (Integer) o;
//         }
//         Privilege p = AAALookup.privilege((String) o);
//         return null == p ? null : p.getLevel();
//     }
// 
// }


// Path: src/main/java/act/aaa/AAAServiceFinder.java
import org.osgl.aaa.*;
import org.osgl.aaa.impl.DumbAuditor;
import org.osgl.util.E;
import javax.inject.Inject;
import java.lang.reflect.Method;
import java.util.EventObject;
import act.Act;
import act.aaa.event.AAAInitialized;
import act.aaa.util.AAAAdaptor;
import act.app.App;
import act.app.event.SysEventId;
import act.event.ActEventListenerBase;
import act.job.OnAppStart;
import act.util.LogSupport;
import act.util.Stateless;
import act.util.SubClassFinder;

package act.aaa;

/*-
 * #%L
 * ACT AAA Plugin
 * %%
 * Copyright (C) 2015 - 2017 ActFramework
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */



@SuppressWarnings("unused")
@Stateless
public class AAAServiceFinder<T> extends LogSupport {

    private App app;

    @Inject
    public AAAServiceFinder(App app) {
        this.app = app;
    }

    @SubClassFinder(callOn = SysEventId.PRE_START)
    public void foundActAAAService(Class<? extends ActAAAService> serviceType) {
        if (AAAAdaptor.class == serviceType) {