public Map<String, String> getStoredPasswordsProviders() {
   Map<String, String> results = new HashMap<String, String>();
   results.put(null, user.getUsername());
   for (JCRStoreProvider provider : sessionFactory.getProviders().values()) {
     if ("storedPasswords".equals(provider.getAuthenticationType())) {
       results.put(provider.getKey(), user.getProperty("storedUsername_" + provider.getKey()));
     }
   }
   return results;
 }
Beispiel #2
0
  /**
   * Transform a REST hook subscription JCR node to its memory representation
   *
   * @param hookSubscriptionNode the JCR node
   * @return the memory representation of a JCR subscription node
   * @throws JahiaRestHooksException
   * @throws RepositoryException
   */
  public static JahiaHooksSubscription jcrRestHooksSubcriptionToJahiaHooksSubscription(
      JCRNodeWrapper hookSubscriptionNode) throws RepositoryException {
    if (hookSubscriptionNode == null) {
      return null;
    }

    if (!hookSubscriptionNode.getPrimaryNodeTypeName().equals(HOOKS_SUBS_JCR_NODE_TYPE_NAME)) {
      throw new RepositoryException("Given node type is not a Jahia hook subscription.", null);
    }

    JahiaHooksSubscription hookSubs = new JahiaHooksSubscriptionImpl();
    hookSubs.setId(hookSubscriptionNode.getIdentifier());
    hookSubs.setCallbackURL(
        hookSubscriptionNode.getPropertyAsString(HOOKS_SUBS_CALLBACK_URL_PROP_NAME));

    String[] topics =
        getMultivaluedStringProp(hookSubscriptionNode.getProperty(HOOKS_SUBS_EVENT_PROP_NAME));
    hookSubs.setEvents(topics);
    JCRUserNode user =
        (JCRUserNode)
            hookSubscriptionNode
                .getSession()
                .getNodeByUUID(hookSubscriptionNode.getPropertyAsString(HOOKS_SUBS_USER_PROP_NAME));
    JahiaUser jusr = user.getJahiaUser();
    User owner =
        new User(
            jusr.getUsername(),
            UserPreferencesHelper.getEmailAddress(user),
            UserPreferencesHelper.getFirstName(user),
            UserPreferencesHelper.getLastName(user));
    hookSubs.setUser(owner);
    hookSubs.setMaxRetry(
        Integer.parseInt(hookSubscriptionNode.getPropertyAsString(HOOKS_SUBS_RETRY_PROP_NAME)));
    // by default
    SubscriptionStatus status = SubscriptionStatus.INACTIVE;
    try {
      status =
          SubscriptionStatus.valueOf(
              hookSubscriptionNode.getPropertyAsString(HOOKS_SUBS_STATUS_PROP_NAME));
    } catch (IllegalArgumentException iaex) {
      // TODO: log a warn
    }
    hookSubs.setStatus(status);
    return hookSubs;
  }