OpenLDAP не проверяет сертификат TLS

Существует много способов добиться того, что вам нужно. Хотя мне было бы интересно , почему вам нужно.

  1. Переопределить метод toString(). см.: http://www.javapractices.com/topic/TopicAction.do?Id=55
  2. Если алгоритм генерации слишком длинный, тогда рассмотрим отдельный класс, скажем UserPrettyPrinter.
    public interface UserPrettyPrinter {
      string print(User);
    }
    
    public class PrintUserInJSON implements UserPrettyPrinter {
      string print(User user) {
        //implement the algo here
      }
    }
    
    вы также можете реализовать:
    public class PrintUserInXML implements UserPrettyPrinter {
      string print(User user) {
        //implement the algo here
      }
    }
    
  3. Либо в спряжении с number-2 , либо в качестве отдельного класса вы можете написать
    public class PrintObjectBasicAlgo {
      String print(Object obj) {
        /* i write pseudo code here. just ask if you cannot implement this
        this would help: http://docs.oracle.com/javase/tutorial/reflect/class/classMembers.html
    
        Class class = Obj.getClass();
    
        Filed[] allVariables = class.getAllFieldsByReflection();
    
        ArrayList keys = new ArrayList;
        ArrayList values = new ArrayList;
    
        for(Field field : allVariables) {
            Object value = reflectionGetValueOfField( field, obj );
            keys.add( field.getName());
            values.add(value.toString());
        }
    
        now that you have the keys and values, you can generate a string in anyway you like
    
        */
      }
    }
    
  4. Вы можете увидеть шаблон посетителя . это может быть полезно.

1
задан Kevin Keane 17 January 2019 в 20:56
поделиться