aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/otr/authdialog/SecretQuestionAuthenticationPanel.java
blob: aa6542f9963e0856a3a51b270e1d670df85e0700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.plugin.otr.authdialog;

import java.awt.*;

import javax.swing.*;

import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.plugin.otr.*;

/**
 * @author Marin Dzhigarov
 */
@SuppressWarnings("serial")
public class SecretQuestionAuthenticationPanel
    extends TransparentPanel
{
    /**
     * The text field where the authentication initiator will type his question.
     */
    private final JTextField question = new JTextField();

    /**
     * The text field where the authentication initiator will type his answer.
     */
    private final JTextField answer = new JTextField();


    /**
     * Creates an instance SecretQuestionAuthenticationPanel.
     */
    SecretQuestionAuthenticationPanel()
    {
        initComponents();
    }

    /**
     * Initializes the {@link SecretQuestionAuthenticationPanel} components.
     */
    private void initComponents()
    {
        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

        JTextArea generalInformation = new CustomTextArea();
        generalInformation.setText(
            OtrActivator.resourceService
                .getI18NString(
                    "plugin.otr.authbuddydialog.AUTH_BY_QUESTION_INFO_INIT"));
        this.add(generalInformation);

        this.add(Box.createVerticalStrut(10));

        JPanel questionAnswerPanel = new JPanel(new GridBagLayout());
        questionAnswerPanel.setBorder(BorderFactory.createEtchedBorder());

        GridBagConstraints c = new GridBagConstraints();
        c.gridx = 0;
        c.gridy = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.insets = new Insets(5, 5, 0, 5);
        c.weightx = 1;

        JLabel questionLabel =
            new JLabel(
                OtrActivator.resourceService
                    .getI18NString(
                        "plugin.otr.authbuddydialog.QUESTION_INIT"));
        questionAnswerPanel.add(questionLabel, c);

        c.gridy = 1;
        c.insets = new Insets(0, 5, 5, 5);
        questionAnswerPanel.add(question, c);

        c.gridy = 2;
        c.insets = new Insets(5, 5, 0, 5);
        JLabel answerLabel =
            new JLabel(
                OtrActivator.resourceService
                    .getI18NString(
                        "plugin.otr.authbuddydialog.ANSWER"));
        questionAnswerPanel.add(answerLabel, c);

        c.gridy = 3;
        c.insets = new Insets(0, 5, 5, 5);
        questionAnswerPanel.add(answer, c);

        this.add(questionAnswerPanel);
        this.add(new Box.Filler(
            new Dimension(300, 100),
            new Dimension(300, 100),
            new Dimension(300, 100)));
    }

    /**
     * Returns the secret answer text.
     * 
     * @return The secret answer text.
     */
    String getSecret()
    {
        return answer.getText();
    }

    /**
     * Returns the secret question text.
     * 
     * @return The secret question text.
     */
    String getQuestion()
    {
        return question.getText();
    }
}