コード例 #1
0
  public Object invoke(MethodInvocation invocation) throws Throwable {
    String userId = getUserId();

    boolean setUser = false;
    if (!StringUtils.isEmpty(userId)) {
      final PropertyLayer layer = PropertyLayerProviderInterceptor.getCurrent();

      Map loginProperties = new HashMap();
      LoginUtils.mergeDefaultCredentials(loginProperties);
      /*
               loginProperties.put(SecurityProperties.PARTITION, partitionId);
               loginProperties.put(SecurityProperties.REALM, realmId);
               loginProperties.put(SecurityProperties.DOMAIN, domainId);
      */
      IAuditTrailPartition partition =
          LoginUtils.findPartition(invocation.getParameters(), loginProperties);
      IUserDomain domain =
          LoginUtils.findUserDomain(invocation.getParameters(), partition, loginProperties);

      layer.setProperty(SecurityProperties.CURRENT_PARTITION, partition);
      layer.setProperty(SecurityProperties.CURRENT_PARTITION_OID, new Short(partition.getOID()));
      layer.setProperty(SecurityProperties.CURRENT_DOMAIN, domain);
      layer.setProperty(SecurityProperties.CURRENT_DOMAIN_OID, new Long(domain.getOID()));

      IModel model = ModelManagerFactory.getCurrent().findActiveModel();
      if (model == null) {
        model = ModelManagerFactory.getCurrent().findLastDeployedModel();
      }

      IUser user =
          SynchronizationService.synchronize(
              userId,
              model,
              invocation
                  .getParameters()
                  .getBoolean(SecurityProperties.AUTHORIZATION_SYNC_LOGIN_PROPERTY, true),
              loginProperties);

      layer.setProperty(SecurityProperties.CURRENT_USER, user);

      // clean thread, so nested calls won't reuse the user ID
      setUser = true;
      resetUserId();
    }

    try {
      return invocation.proceed();
    } finally {
      if (setUser) {
        // restore thread status
        setUserId(userId);
      }
    }
  }
コード例 #2
0
  private static ServiceFactory __get__(Map credentials, Map properties) throws PublicException {
    try {
      ServiceFactory result =
          (ServiceFactory)
              Reflect.createInstance(
                  Parameters.instance()
                      .getString(
                          WebProperties.WEB_SERVICE_FACTORY,
                          PredefinedConstants.PLAIN_WEB_SERVICEFACTORY_CLASS),
                  ServiceFactoryLocator.class.getClassLoader());
      result.setCredentials(credentials);

      Map mergedProps = new HashMap(properties);
      LoginUtils.mergeCredentialProperties(mergedProps, credentials);
      LoginUtils.mergeDefaultCredentials(mergedProps);

      result.setProperties(mergedProps);

      return result;
    } catch (InternalException e) {
      throw new PublicException(
          BpmRuntimeError.EJB_INVALID_SERVICE_FACTORY_CONFIGURATION.raise(e.getMessage()));
    }
  }