Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

TestSSLCertificateDialogModel.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.harness.ui;
  23. import com.dmdirc.ui.core.dialogs.sslcertificate.CertificateAction;
  24. import com.dmdirc.ui.core.dialogs.sslcertificate.CertificateChainEntry;
  25. import com.dmdirc.ui.core.dialogs.sslcertificate.CertificateInformationEntry;
  26. import com.dmdirc.ui.core.dialogs.sslcertificate.CertificateSummaryEntry;
  27. import com.dmdirc.ui.core.dialogs.sslcertificate.SSLCertificateDialogModel;
  28. import java.util.ArrayList;
  29. import java.util.Arrays;
  30. import java.util.List;
  31. public class TestSSLCertificateDialogModel extends SSLCertificateDialogModel {
  32. public CertificateAction action = null;
  33. public boolean needsResponse = true;
  34. public TestSSLCertificateDialogModel() {
  35. super(null, null, null);
  36. }
  37. @Override
  38. public List<CertificateChainEntry> getCertificateChain() {
  39. return Arrays.asList(new CertificateChainEntry[]{
  40. new CertificateChainEntry("first cert", false, false),
  41. new CertificateChainEntry("second cert", false, false),
  42. new CertificateChainEntry("invalid cert", false, true),
  43. new CertificateChainEntry("trusted cert", true, false),
  44. new CertificateChainEntry("invalid+trusted", true, true),
  45. });
  46. }
  47. @Override
  48. public List<List<CertificateInformationEntry>> getCertificateInfo(int index) {
  49. final List<List<CertificateInformationEntry>> res
  50. = new ArrayList<List<CertificateInformationEntry>>();
  51. res.add(Arrays.asList(new CertificateInformationEntry[]{
  52. new CertificateInformationEntry("G1 T1", "value", false, false),
  53. new CertificateInformationEntry("G1 T2 missing", "value", false, true),
  54. new CertificateInformationEntry("G1 T3 invalid", "value", true, false),
  55. }));
  56. res.add(Arrays.asList(new CertificateInformationEntry[]{
  57. new CertificateInformationEntry("G2 T1", "value", false, false),
  58. new CertificateInformationEntry("G2 T2 missing", "value", false, true),
  59. new CertificateInformationEntry("G2 T3 invalid", "value", true, false),
  60. }));
  61. res.add(Arrays.asList(new CertificateInformationEntry[]{
  62. new CertificateInformationEntry("G3 T1", "value", false, false),
  63. new CertificateInformationEntry("G3 T2 missing", "value", false, true),
  64. new CertificateInformationEntry("G3 T3 invalid", "value", true, false),
  65. }));
  66. return res;
  67. }
  68. @Override
  69. public List<CertificateSummaryEntry> getSummary() {
  70. return Arrays.asList(new CertificateSummaryEntry[]{
  71. new CertificateSummaryEntry("Valid entry one", true),
  72. new CertificateSummaryEntry("Valid entry two", true),
  73. new CertificateSummaryEntry("INVALID ENTRY!!1111one", false),
  74. });
  75. }
  76. @Override
  77. public boolean needsResponse() {
  78. return needsResponse;
  79. }
  80. @Override
  81. public void performAction(CertificateAction action) {
  82. this.action = action;
  83. }
  84. @Override
  85. public String getServerName() {
  86. return "server.name";
  87. }
  88. }