Skip to content

Commit

Permalink
Add default strategy fields #1020
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrydy committed Jun 26, 2018
1 parent 822b95b commit 1207a1e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
Expand Up @@ -66,6 +66,10 @@
public class ManagePersonAuthenticationAction
implements SimplePropertiesListModel, SimpleCustomPropertiesListModel, LdapConfigurationModel, Serializable {

private static final String CLIENT_SECRET = "clientSecret";

private static final String CLIENT_ID = "clientID";

private static final long serialVersionUID = -4470460481895022468L;

@Inject
Expand Down Expand Up @@ -130,8 +134,8 @@ public String modify() {
String outcome = modifyImpl();

if (OxTrustConstants.RESULT_FAILURE.equals(outcome)) {
facesMessages.add(FacesMessage.SEVERITY_ERROR,
facesMessages.evalResourceAsString("#{msg['configuration.manageAuthentication.failToPrepareUpdate']}"));
facesMessages.add(FacesMessage.SEVERITY_ERROR, facesMessages
.evalResourceAsString("#{msg['configuration.manageAuthentication.failToPrepareUpdate']}"));
conversationService.endConversation();
}

Expand Down Expand Up @@ -227,8 +231,9 @@ public String save() throws JsonParseException, JsonMappingException, IOExceptio

reset();

facesMessages.add(FacesMessage.SEVERITY_INFO, facesMessages.evalResourceAsString("#{msg['configuration.manageAuthentication.updateSucceed']}"));

facesMessages.add(FacesMessage.SEVERITY_INFO,
facesMessages.evalResourceAsString("#{msg['configuration.manageAuthentication.updateSucceed']}"));

conversationService.endConversation();

return OxTrustConstants.RESULT_SUCCESS;
Expand All @@ -252,7 +257,8 @@ private GluuLdapConfiguration mapLdapConfig(String config)
}

public String cancel() {
facesMessages.add(FacesMessage.SEVERITY_INFO, facesMessages.evalResourceAsString("#{msg['configuration.manageAuthentication.updateFailed']}"));
facesMessages.add(FacesMessage.SEVERITY_INFO,
facesMessages.evalResourceAsString("#{msg['configuration.manageAuthentication.updateFailed']}"));
conversationService.endConversation();

return OxTrustConstants.RESULT_SUCCESS;
Expand Down Expand Up @@ -352,7 +358,8 @@ public String testLdapConnection(GluuLdapConfiguration ldapConfig) {
if (connectionProvider.isConnected()) {
connectionProvider.closeConnectionPool();

facesMessages.add(FacesMessage.SEVERITY_INFO, facesMessages.evalResourceAsString("#{msg['configuration.manageAuthentication.ldap.testSucceed']}"));
facesMessages.add(FacesMessage.SEVERITY_INFO, facesMessages
.evalResourceAsString("#{msg['configuration.manageAuthentication.ldap.testSucceed']}"));

return OxTrustConstants.RESULT_SUCCESS;

Expand All @@ -364,7 +371,8 @@ public String testLdapConnection(GluuLdapConfiguration ldapConfig) {
log.error("Could not connect to LDAP", ex);
}

facesMessages.add(FacesMessage.SEVERITY_ERROR, facesMessages.evalResourceAsString("#{msg['configuration.manageAuthentication.ldap.testFailed']}"));
facesMessages.add(FacesMessage.SEVERITY_ERROR,
facesMessages.evalResourceAsString("#{msg['configuration.manageAuthentication.ldap.testFailed']}"));

return OxTrustConstants.RESULT_FAILURE;
}
Expand Down Expand Up @@ -461,10 +469,21 @@ public String getId(Object obj) {
}

public void addStrategy() {
PassportConfiguration passportConfiguration = new PassportConfiguration();
if (ldapPassportConfigurations == null) {
ldapPassportConfigurations = new ArrayList<PassportConfiguration>();
}
SimpleExtendedCustomProperty clientIDField = new SimpleExtendedCustomProperty();
clientIDField.setValue1(CLIENT_ID);
clientIDField.setValue2(facesMessages
.evalResourceAsString("#{msg['manageAuthentication.passport.strategy.clientIDFieldHint']}"));
SimpleExtendedCustomProperty clientSecretField = new SimpleExtendedCustomProperty();
clientSecretField.setValue1(CLIENT_SECRET);
clientSecretField.setValue2(facesMessages
.evalResourceAsString("#{msg['manageAuthentication.passport.strategy.clientSecretFieldHint']}"));
PassportConfiguration passportConfiguration = new PassportConfiguration();
passportConfiguration.setFieldset(new ArrayList<SimpleExtendedCustomProperty>());
passportConfiguration.getFieldset().add(clientIDField);
passportConfiguration.getFieldset().add(clientSecretField);
this.ldapPassportConfigurations.add(passportConfiguration);
}

Expand Down
2 changes: 2 additions & 0 deletions server/src/main/resources/oxtrust.properties
Expand Up @@ -149,6 +149,8 @@ manageAuthentication.testLDAPConnection = Test LDAP Connection

manageAuthentication.passport.strategy.addProperty = Add new property
manageAuthentication.passport.strategy.deleteStrategy = Delete Strategy
manageAuthentication.passport.strategy.clientIDFieldHint = Enter your client id here
manageAuthentication.passport.strategy.clientSecretFieldHint = Enter your client secret here

ldapConfig.name = Name
ldapConfig.useAnonymousBind = Use Anonymous Bind
Expand Down
2 changes: 2 additions & 0 deletions server/src/main/resources/oxtrust_en.properties
Expand Up @@ -149,6 +149,8 @@ manageAuthentication.testLDAPConnection = Test LDAP Connection

manageAuthentication.passport.strategy.addProperty = Add new property
manageAuthentication.passport.strategy.deleteStrategy = Delete Strategy
manageAuthentication.passport.strategy.clientIDFieldHint = Enter your client id here
manageAuthentication.passport.strategy.clientSecretFieldHint = Enter your client secret here

ldapConfig.name = Name
ldapConfig.useAnonymousBind = Use Anonymous Bind
Expand Down
Expand Up @@ -61,7 +61,7 @@
<h:panelGrid columns="1" width="100%" border="0" cellpadding="0" cellspacing="0" >
<h:panelGroup >
<div >
<h:inputText id="fInput" style = "margin-right:5px;margin-bottom:10px;width:35%;float:left;" styleClass="col-md-4 form-control" value="#{_property.value1}" size="#{cc.attrs.inputWidth}" required="#{cc.attrs.requiredName and empty param['sv']}"/>
<h:inputText id="fInput" style = "margin-right:5px;margin-bottom:10px;width:35%;float:left;" styleClass="col-md-4 form-control" value="#{_property.value1}" size="#{cc.attrs.inputWidth}" required="#{cc.attrs.requiredName and empty param['sv']}" readonly="#{(_property.value1) eq 'clientID' or (_property.value1) eq 'clientSecret'}"/>
<h:message for="fInput" errorClass="invalid"/>

<h:inputText id="sInput1" styleClass="col-md-4 form-control togglefield" style = "width:35%;float:left;" value="#{_property.value2}" size="#{cc.attrs.inputWidth}" required="#{cc.attrs.requiredValue and empty param['sv']}" rendered="#{(cc.attrs.hideValue eq false) or (_property.hideValue eq false)}" />
Expand All @@ -79,7 +79,7 @@
<f:param name="sv" value="1" />
</a4j:commandLink>

<a4j:commandLink styleClass="glyphicon glyphicon-remove col-md-3" rendered="#{cc.attrs.showRemoveDialogue eq true}" style="float:left;margin-top: 8px;" onclick="#{rich:component('deleteConfirmation:acceptRemovalModalPanel')}.show();"
<a4j:commandLink styleClass="glyphicon glyphicon-remove col-md-3" rendered="#{(cc.attrs.showRemoveDialogue) eq true and (_property.value1) ne 'clientID' and (_property.value1) ne 'clientSecret'}" style="float:left;margin-top: 8px;" onclick="#{rich:component('deleteConfirmation:acceptRemovalModalPanel')}.show();"
execute="@region">
<!-- <h:graphicImage value="/img/remove.gif" /> -->
<f:param name="sv" value="1" />
Expand Down

0 comments on commit 1207a1e

Please sign in to comment.