Пример #1
0
 /**
  * Constructs a legacy response provider based on the information in this adapter.
  *
  * @return the legacy response provider
  * @throws EntitlementException if an error occurs constructing the response provider.
  */
 @JsonIgnore
 public ResponseProvider getResponseProvider() throws EntitlementException {
   try {
     ResponseProvider rp =
         Class.forName(className).asSubclass(ResponseProvider.class).newInstance();
     Map<String, Set<String>> properties = new HashMap<String, Set<String>>();
     properties.put(propertyName, propertyValues);
     rp.setProperties(properties);
     return rp;
   } catch (Exception ex) {
     throw new EntitlementException(510, ex);
   }
 }
Пример #2
0
  /**
   * Called by the entitlements framework to fetch its resource attributes; cascades the call
   * through to the configured response provider implementation
   *
   * @param adminSubject The admin user executing the policy eval
   * @param realm The realm of the policy eval
   * @param subject The user who is subject to the policy eval
   * @param resourceName The resource name of the policy eval
   * @param environment environment map from the policy eval client
   * @return The attributes (only one since resource attributes are singled)
   * @throws EntitlementException
   */
  public Map<String, Set<String>> evaluate(
      Subject adminSubject,
      String realm,
      Subject subject,
      String resourceName,
      Map<String, Set<String>> environment)
      throws EntitlementException {
    try {
      ResponseProvider rp = getResponseProvider();
      SSOToken token = (subject != null) ? getSSOToken(subject) : null;
      Map<String, Set<String>> result = rp.getResponseDecision(token, environment);

      return result;
    } catch (SSOException ex) {
      throw new EntitlementException(510, ex);
    } catch (PolicyException ex) {
      throw new EntitlementException(510, ex);
    }
  }