Class ConfigurablePasswordProvider

    • Field Detail

      • log

        protected final org.slf4j.Logger log
      • hash

        protected final java.lang.String hash
        Hash implementation to use for encoding passwords to check and changed passwords. Default value: MD5 (For the moment, the only supported value!)
      • salt

        protected final boolean salt
        Whether or not salting based on the user ID should be attempted.
      • ignoreUnknown

        protected final boolean ignoreUnknown
        If true, this implementation should return a null on checkPassword(String, String, boolean) if the user is unknown, otherwise a Boolean.FALSE. Default value: false
      • legacyUtil

        protected PasswordUtil legacyUtil
        Possibly null PasswordUtil instance which will be used as a fallback for password checks if the util instance fails.
      • ctx

        protected ome.system.OmeroContext ctx
    • Method Detail

      • setApplicationContext

        public void setApplicationContext​(org.springframework.context.ApplicationContext ctx)
                                   throws org.springframework.beans.BeansException
        Specified by:
        setApplicationContext in interface org.springframework.context.ApplicationContextAware
        Throws:
        org.springframework.beans.BeansException
      • setLegacyUtil

        public void setLegacyUtil​(PasswordUtil legacy)
      • loginAttempt

        protected java.lang.Boolean loginAttempt​(java.lang.String user,
                                                 java.lang.Boolean success)
      • hasPassword

        public boolean hasPassword​(java.lang.String user)
        Always returns false, override with specific logic.
        Specified by:
        hasPassword in interface PasswordProvider
      • checkPassword

        public java.lang.Boolean checkPassword​(java.lang.String user,
                                               java.lang.String password,
                                               boolean readOnly)
        If this was constructed with the ignoreUnknown argument set to true, returns null, since the base class knows no users. Otherwise, returns Boolean.FALSE specifying that authentication should fail.
        Specified by:
        checkPassword in interface PasswordProvider
      • encodeSaltedPassword

        public java.lang.String encodeSaltedPassword​(java.lang.Long userId,
                                                     java.lang.String newPassword)
        Encodes the password as it would be encoded for a check by comparePasswords(String, String) salting the password with the given userId if it's provided.
        Parameters:
        userId - a user ID (may be null)
        newPassword - a password
        Returns:
        the encoded password
      • encodePassword

        protected java.lang.String encodePassword​(java.lang.Long userId,
                                                  java.lang.String newPassword,
                                                  boolean salt,
                                                  PasswordUtil util)
      • comparePasswords

        public java.lang.Boolean comparePasswords​(java.lang.String trusted,
                                                  java.lang.String provided)
        Compares the password provided by the user (unhashed) against the given trusted password. A return value of null, however, is also possible with the same semantics as a null from checkPassword(String, String, boolean). For this implementation, if the trusted password is null, return Boolean.FALSE. If the trusted password is empty (only whitespace), return Boolean.TRUE. Otherwise return the result of String.equals(Object).
        Specified by:
        comparePasswords in interface PasswordUtility
      • comparePasswords

        public java.lang.Boolean comparePasswords​(java.lang.Long userId,
                                                  java.lang.String trusted,
                                                  java.lang.String provided)
        Compares the password provided by the user (unhashed) against the given trusted password. In general, if the trusted password is null, return Boolean.FALSE. If the trusted password is empty (only whitespace), return Boolean.TRUE. Otherwise return the results of String.equals(Object). If necessary, falls back to using a legacy password utility class if one was set by setLegacyUtil(PasswordUtil).
        Parameters:
        userId - a user ID
        trusted - the user's trusted password
        provided - the provided password
        Returns:
        if the provided password matches the trusted password (for which blank matches anything)
      • comparePasswords

        protected boolean comparePasswords​(java.lang.Long userId,
                                           java.lang.String trusted,
                                           java.lang.String provided,
                                           PasswordUtil util)