Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
574974 - RFE: Add option of pasting key into textarea
  • Loading branch information
dyordano authored and tkasparek committed Jun 6, 2014
1 parent ca7fe1b commit 17921bf
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 34 deletions.
Expand Up @@ -16,6 +16,7 @@

import com.redhat.rhn.common.localization.LocalizationService;
import com.redhat.rhn.common.security.PermissionException;
import com.redhat.rhn.common.util.StringUtil;
import com.redhat.rhn.common.validator.ValidatorError;
import com.redhat.rhn.domain.kickstart.KickstartFactory;
import com.redhat.rhn.frontend.struts.RequestContext;
Expand Down Expand Up @@ -49,6 +50,7 @@ public abstract class BaseCryptoKeyEditAction extends RhnAction {
public static final String KEY = "cryptoKey";
public static final String DESCRIPTION = "description";
public static final String CONTENTS = "contents";
public static final String CONTENTS_EDIT = "contents_edit";
public static final String TYPE = "type";
public static final String TYPES = "types";
public static final String CSRF_TOKEN = "csrfToken";
Expand Down Expand Up @@ -91,23 +93,21 @@ public ActionForward execute(ActionMapping mapping,
if (isSubmitted(form)) {
ActionErrors errors = RhnValidationHelper.validateDynaActionForm(
this, form);

String contents = strutsDelegate.getFormFileString(form, CONTENTS);
String contentFileName = strutsDelegate.getFormFileName(form, CONTENTS);
if (StringUtils.isEmpty(contentFileName)) {
if (cmd.getCryptoKey().getKey() == null) {
strutsDelegate.addError(
"configmanager.filedetails.path.empty", errors);
}
if (StringUtils.isEmpty(contents)) {
contents = StringUtil.nullIfEmpty((String) form
.get(CONTENTS_EDIT));
}
else if (StringUtils.isEmpty(contents)) {
strutsDelegate.addError("crypto.key.nokey", errors);
if (contents == null) {
strutsDelegate.addError("crypto.key.nokey", errors);
}
if (!errors.isEmpty()) {
strutsDelegate.saveMessages(request, errors);
}
else {
cmd.setDescription(form.getString(DESCRIPTION));
if (!StringUtils.isEmpty(contentFileName)) {
if (!StringUtils.isEmpty(contents)) {
cmd.setContents(contents);
}
cmd.setType(form.getString(TYPE));
Expand All @@ -126,6 +126,7 @@ else if (StringUtils.isEmpty(contents)) {
else {
if (cmd.getCryptoKey() != null) {
form.set(DESCRIPTION, cmd.getCryptoKey().getDescription());
form.set(CONTENTS_EDIT, cmd.getCryptoKey().getKeyString());
}
form.set(TYPE, cmd.getType());
}
Expand Down
Expand Up @@ -5511,7 +5511,7 @@ user before attempting to deactivate their account.</source>
</context-group>
</trans-unit>
<trans-unit id="crypto.key.nokey">
<source>No file contents found. Please select a proper key file from your local machine to upload.</source>
<source>No GPL/SSL key content was provided.</source>
<context-group name="ctx">
<context context-type="sourcefile">/rhn/keys/CryptoKeysCreate.do</context>
</context-group>
Expand Down
Expand Up @@ -9980,7 +9980,7 @@ Please note that some manual configuration of these scripts may still be require
</context-group>
</trans-unit>
<trans-unit id="keycreate.jsp.summary">
<source>Please enter the information for your key in the form provided below. Entries marked with an (&lt;span class="required-form-field"&gt;*&lt;/span&gt;) are &lt;strong&gt;required&lt;/strong&gt; and must be unique.</source>
<source>Please enter the information for your key in the form provided below. Entries marked with an (&lt;span class="required-form-field"&gt;*&lt;/span&gt;) are &lt;strong&gt;required&lt;/strong&gt; and must be unique. The actual key content can be provided by uploading a file or by filling out the dedicated text area. In case both ways were used, the file selected for upload takes precedence.</source>
<context-group name="ctx">
<context context-type="sourcefile">/rhn/keys/CryptoKeysCreate.do</context>
</context-group>
Expand Down Expand Up @@ -10015,12 +10015,6 @@ Please note that some manual configuration of these scripts may still be require
<context context-type="sourcefile">/rhn/keys/CryptoKeysCreate.do</context>
</context-group>
</trans-unit>
<trans-unit id="keycreate.jsp.nokey">
<source>&lt;span class="required-form-field"&gt;Neither a GPG or SSL Certificate is currently attached to this cryptokey. Please attach a GPG key or SSL Certificate to this crypto key using the form above.&lt;/span&gt;</source>
<context-group name="ctx">
<context context-type="sourcefile">/rhn/keys/CryptoKeysCreate.do</context>
</context-group>
</trans-unit>
<trans-unit id="keycreate.jsp.submit">
<source>Create Key</source>
<context-group name="ctx">
Expand Down
11 changes: 3 additions & 8 deletions java/code/webapp/WEB-INF/pages/keys/key-form-disabled.jspf
Expand Up @@ -23,14 +23,9 @@
<bean:message key="keycreate.jsp.filecontents"/>
</label>
<div class="col-md-6">
<c:if test="${cryptoKey.keyString != null}">
<textarea class="form-control" rows="10" disabled>
<c:out escapeXml="true" value="${cryptoKey.keyString}" />
</textarea>
</c:if>
<c:if test="${cryptoKey.keyString == null}">
<p class="form-control-static"><bean:message key="keycreate.jsp.nokey"/></p>
</c:if>
<html:textarea property="contents_edit"
cols="40" rows="20"
styleClass="form-control" readonly="true"/>
</div>
</div>
<html:hidden property="submitted" value="true"/>
Expand Down
11 changes: 3 additions & 8 deletions java/code/webapp/WEB-INF/pages/keys/key-form.jspf
Expand Up @@ -49,13 +49,8 @@
<bean:message key="keycreate.jsp.filecontents"/>
</label>
<div class="col-lg-6" id="filecontents">
<c:if test="${cryptoKey.keyString != null}">
<pre style="overflow: scroll;">
<c:out escapeXml="true" value="${cryptoKey.keyString}" />
</pre>
</c:if>
<c:if test="${cryptoKey.keyString == null}">
<bean:message key="keycreate.jsp.nokey"/>
</c:if>
<html:textarea property="contents_edit"
cols="40" rows="20"
styleClass="form-control"/>
</div>
</div>
5 changes: 4 additions & 1 deletion java/code/webapp/WEB-INF/struts-config.xml
Expand Up @@ -540,14 +540,17 @@
<form-property name="description" type="java.lang.String"/>
<form-property name="type" type="java.lang.String"/>
<form-property name="contents" type="org.apache.struts.upload.FormFile"/>
<form-property name="contents_edit" type="java.lang.String"/>
<form-property name="submitted" type="java.lang.Boolean"/>
<form-property name="no_scrub" type="java.lang.String" initial="contents"/>
<form-property name="no_scrub" type="java.lang.String"
initial="contents, contents_edit"/>
</form-bean>

<form-bean name="cryptoKeyDeleteForm"
type="com.redhat.rhn.frontend.struts.ScrubbingDynaActionForm">
<form-property name="description" type="java.lang.String"/>
<form-property name="type" type="java.lang.String"/>
<form-property name="contents_edit" type="java.lang.String"/>
<form-property name="submitted" type="java.lang.Boolean"/>
</form-bean>

Expand Down

0 comments on commit 17921bf

Please sign in to comment.