summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/authority/DefaultOidsPanel.java
blob: d52b99f9892cb9968ed8fecf1b71890538e614b1 (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
/*
 * Copyright 2012 gitblit.com.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.gitblit.authority;

import java.awt.GridLayout;

import javax.swing.JPanel;
import javax.swing.JTextField;

import com.gitblit.client.Translation;
import com.gitblit.utils.X509Utils.X509Metadata;

public class DefaultOidsPanel extends JPanel {

	private static final long serialVersionUID = 1L;

	private JTextField organizationalUnit;
	private JTextField organization;
	private JTextField locality;
	private JTextField stateProvince;
	private JTextField countryCode;

	public DefaultOidsPanel(X509Metadata metadata) {
		super();

		organizationalUnit = new JTextField(metadata.getOID("OU", ""), 20);
		organization = new JTextField(metadata.getOID("O", ""), 20);
		locality = new JTextField(metadata.getOID("L", ""), 20);
		stateProvince = new JTextField(metadata.getOID("ST", ""), 20);
		countryCode = new JTextField(metadata.getOID("C", ""), 20);

		setLayout(new GridLayout(0, 1, Utils.MARGIN, Utils.MARGIN));
		add(Utils.newFieldPanel(Translation.get("gb.organizationalUnit") + " (OU)", organizationalUnit));
		add(Utils.newFieldPanel(Translation.get("gb.organization") + " (O)", organization));
		add(Utils.newFieldPanel(Translation.get("gb.locality") + " (L)", locality));
		add(Utils.newFieldPanel(Translation.get("gb.stateProvince") + " (ST)", stateProvince));
		add(Utils.newFieldPanel(Translation.get("gb.countryCode") + " (C)", countryCode));
	}

	public void update(X509Metadata metadata) {
		metadata.setOID("OU", organizationalUnit.getText());
		metadata.setOID("O", organization.getText());
		metadata.setOID("L", locality.getText());
		metadata.setOID("ST", stateProvince.getText());
		metadata.setOID("C", countryCode.getText());
	}

	public String getOrganizationalUnit() {
		return organizationalUnit.getText();
	}

	public String getOrganization() {
		return organization.getText();
	}

	public String getLocality() {
		return locality.getText();
	}

	public String getStateProvince() {
		return stateProvince.getText();
	}

	public String getCountryCode() {
		return countryCode.getText();
	}
}