コード例 #1
0
ファイル: SecurityAspect.java プロジェクト: jj-umn/TINT
 @Before(value = "@annotation(serviceMethod)", argNames = "serviceMethod")
 public void doAccessCheck(final JoinPoint joinPoint, final ServiceMethod serviceMethod) {
   if (serviceMethod.secure() && !userSession.isLoggedIn()) {
     LOG.warn("Invalid access attempting on method [" + joinPoint.toLongString() + "]");
     throw new IllegalStateException(
         "Attempt to call secure method by an user who is not logged in.");
   } else if (serviceMethod.adminOnly()) {
     final String gridId = userSession.getGridId();
     if (gridId == null || !userSession.isAdmin()) {
       LOG.warn("Invalid access attempting on method [" + joinPoint.toLongString() + "]");
       throw new IllegalStateException(
           "Attempt to call an admin method by a user who is not an admin.");
     }
   }
 }
コード例 #2
0
ファイル: DefaultRopContext.java プロジェクト: wukele/rop
 private ServiceMethodDefinition buildServiceMethodDefinition(ServiceMethod serviceMethod) {
   ServiceMethodDefinition definition = new ServiceMethodDefinition();
   definition.setMethod(serviceMethod.value());
   definition.setMethodTitle(serviceMethod.title());
   definition.setMethodGroup(serviceMethod.group());
   definition.setMethodGroupTitle(serviceMethod.groupTitle());
   definition.setTags(serviceMethod.tags());
   definition.setTimeout(serviceMethod.timeout());
   definition.setIgnoreSign(IgnoreSignType.isIgnoreSign(serviceMethod.ignoreSign()));
   definition.setVersion(serviceMethod.version());
   definition.setNeedInSession(NeedInSessionType.isNeedInSession(serviceMethod.needInSession()));
   return definition;
 }
コード例 #3
0
ファイル: DefaultRopContext.java プロジェクト: wukele/rop
  private ServiceMethodDefinition buildServiceMethodDefinition(
      ServiceMethodGroup serviceMethodGroup, ServiceMethod serviceMethod) {
    ServiceMethodDefinition definition = new ServiceMethodDefinition();
    definition.setMethodGroup(serviceMethodGroup.value());
    definition.setMethodGroupTitle(serviceMethodGroup.title());
    definition.setTags(serviceMethodGroup.tags());
    definition.setTimeout(serviceMethodGroup.timeout());
    definition.setIgnoreSign(IgnoreSignType.isIgnoreSign(serviceMethodGroup.ignoreSign()));
    definition.setVersion(serviceMethodGroup.version());
    definition.setNeedInSession(
        NeedInSessionType.isNeedInSession(serviceMethodGroup.needInSession()));

    // 如果ServiceMethod所提供的值和ServiceMethodGroup不一样,覆盖之
    definition.setMethod(serviceMethod.value());
    definition.setMethodTitle(serviceMethod.title());

    if (!ServiceMethodDefinition.DEFAULT_GROUP.equals(serviceMethod.group())) {
      definition.setMethodGroup(serviceMethod.group());
    }

    if (!ServiceMethodDefinition.DEFAULT_GROUP_TITLE.equals(serviceMethod.groupTitle())) {
      definition.setMethodGroupTitle(serviceMethod.groupTitle());
    }

    if (serviceMethod.tags() != null && serviceMethod.tags().length > 0) {
      definition.setTags(serviceMethod.tags());
    }

    if (serviceMethod.timeout() != -100) {
      definition.setTimeout(serviceMethod.timeout());
    }

    if (serviceMethod.ignoreSign() != IgnoreSignType.INVALID) {
      definition.setIgnoreSign(IgnoreSignType.isIgnoreSign(serviceMethod.ignoreSign()));
    }

    if (StringUtils.hasText(serviceMethod.version())) {
      definition.setVersion(serviceMethod.version());
    }

    if (serviceMethod.needInSession() != NeedInSessionType.INVALID) {
      definition.setNeedInSession(NeedInSessionType.isNeedInSession(serviceMethod.needInSession()));
    }

    return definition;
  }