// Path: src/main/java/act/aaa/model/AuditBase.java
// @MappedSuperclass
// public abstract class AuditBase implements SimpleBean {
// 
//     public String message;
//     public String target;
//     public String principal;
//     public String privilege;
//     public boolean success;
//     public String permission;
// 
//     public AuditBase() {}
// 
//     public AuditBase(Object aTarget, Principal aPrincipal, String aPermission, String aPrivilege, boolean theSuccess, String aMessage) {
//         this.message = aMessage;
//         this.target = targetStr(aTarget);
//         this.principal = aPrincipal.getName();
//         this.permission = aPermission;
//         this.privilege = aPrivilege;
//         this.success = theSuccess;
//     }
// 
//     private String targetStr(Object target) {
//         if (target instanceof Auditor.Target) {
//             return ((Auditor.Target) target).auditTag();
//         } else if (target instanceof Model) {
//             return S.concat(target.getClass().getSimpleName(), "[", S.string(((Model) target)._id()), "]");
//         } else {
//             return S.string(target);
//         }
//     }
// 
// }


import org.osgl.util.S;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashSet;
import java.util.Set;
import act.aaa.model.AuditBase;
import act.app.App;
import act.app.event.SysEventId;
import act.conf.AppConfig;
import act.job.OnSysEvent;
import act.util.AnnotatedClassFinder;
import act.util.SubClassFinder;
import org.osgl.aaa.Principal;
import org.osgl.exception.ConfigurationException;
import org.osgl.util.E;
package act.aaa;

/*-
 * #%L
 * ACT AAA Plugin
 * %%
 * Copyright (C) 2015 - 2018 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%
 */



@Singleton
public class AAAMetaInfo {

    Class<?> principalEntityType;
    Method passwordVerifier;
    Method roleProvider;
    Method permissionProvider;
    Method privilegeProvider;

    Set<Class> userTypes = new HashSet<>();
    Set<Class> auditTypes = new HashSet<>();

    @Inject
    private AppConfig config;

    @Inject
    private App app;

    @AnnotatedClassFinder(PrincipalEntity.class)
    public void foundUserType(Class type) {
        if (config.possibleControllerClass(type.getName())) {
            userTypes.add(type);
        }
    }

    @SubClassFinder
    public void foundUserType2(Class<Principal> type) {
        String typeName = type.getName();
        if (config.possibleControllerClass(typeName) && !typeName.startsWith("act.")) {
            userTypes.add(type);
        }
    }

    @SubClassFinder
// Path: src/main/java/act/aaa/model/AuditBase.java
// @MappedSuperclass
// public abstract class AuditBase implements SimpleBean {
// 
//     public String message;
//     public String target;
//     public String principal;
//     public String privilege;
//     public boolean success;
//     public String permission;
// 
//     public AuditBase() {}
// 
//     public AuditBase(Object aTarget, Principal aPrincipal, String aPermission, String aPrivilege, boolean theSuccess, String aMessage) {
//         this.message = aMessage;
//         this.target = targetStr(aTarget);
//         this.principal = aPrincipal.getName();
//         this.permission = aPermission;
//         this.privilege = aPrivilege;
//         this.success = theSuccess;
//     }
// 
//     private String targetStr(Object target) {
//         if (target instanceof Auditor.Target) {
//             return ((Auditor.Target) target).auditTag();
//         } else if (target instanceof Model) {
//             return S.concat(target.getClass().getSimpleName(), "[", S.string(((Model) target)._id()), "]");
//         } else {
//             return S.string(target);
//         }
//     }
// 
// }


// Path: src/main/java/act/aaa/AAAMetaInfo.java
import org.osgl.util.S;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashSet;
import java.util.Set;
import act.aaa.model.AuditBase;
import act.app.App;
import act.app.event.SysEventId;
import act.conf.AppConfig;
import act.job.OnSysEvent;
import act.util.AnnotatedClassFinder;
import act.util.SubClassFinder;
import org.osgl.aaa.Principal;
import org.osgl.exception.ConfigurationException;
import org.osgl.util.E;

package act.aaa;

/*-
 * #%L
 * ACT AAA Plugin
 * %%
 * Copyright (C) 2015 - 2018 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%
 */



@Singleton
public class AAAMetaInfo {

    Class<?> principalEntityType;
    Method passwordVerifier;
    Method roleProvider;
    Method permissionProvider;
    Method privilegeProvider;

    Set<Class> userTypes = new HashSet<>();
    Set<Class> auditTypes = new HashSet<>();

    @Inject
    private AppConfig config;

    @Inject
    private App app;

    @AnnotatedClassFinder(PrincipalEntity.class)
    public void foundUserType(Class type) {
        if (config.possibleControllerClass(type.getName())) {
            userTypes.add(type);
        }
    }

    @SubClassFinder
    public void foundUserType2(Class<Principal> type) {
        String typeName = type.getName();
        if (config.possibleControllerClass(typeName) && !typeName.startsWith("act.")) {
            userTypes.add(type);
        }
    }

    @SubClassFinder
    public void foundAuditType(Class<AuditBase> type) {