Search in sources :

Example 6 with ConsumerRecordVO

use of org.entando.entando.aps.system.services.oauth2.model.ConsumerRecordVO in project entando-core by entando.

the class ConsumerAction method validate.

public void validate() {
    super.validate();
    try {
        ConsumerRecordVO consumer = this.getOauthConsumerManager().getConsumerRecord(this.getConsumerKey());
        if (this.getStrutsAction() == ApsAdminSystemConstants.ADD && null != consumer) {
            String[] args = { this.getConsumerKey() };
            this.addFieldError("consumerKey", this.getText("error.consumer.duplicated", args));
        } else if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT && null == consumer) {
            this.addActionError(this.getText("error.consumer.notExist"));
        }
    } catch (Throwable t) {
        _logger.error("Error validating consumer", t);
        this.addActionError(this.getText("error.consumer.systemError"));
    }
}
Also used : ConsumerRecordVO(org.entando.entando.aps.system.services.oauth2.model.ConsumerRecordVO)

Example 7 with ConsumerRecordVO

use of org.entando.entando.aps.system.services.oauth2.model.ConsumerRecordVO in project entando-core by entando.

the class ConsumerAction method save.

public String save() {
    ConsumerRecordVO consumer = null;
    try {
        if (this.getStrutsAction() == ApsAdminSystemConstants.ADD) {
            consumer = new ConsumerRecordVO();
            consumer.setKey(this.getConsumerKey());
        } else if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT) {
            consumer = this.getOauthConsumerManager().getConsumerRecord(this.getConsumerKey());
        }
        consumer.setCallbackUrl(this.getCallbackUrl());
        consumer.setDescription(this.getDescription());
        consumer.setName(this.getName());
        consumer.setExpirationDate(this.getExpirationDate());
        consumer.setIssuedDate(Calendar.getInstance().getTime());
        consumer.setScope(this.getScope());
        consumer.setAuthorizedGrantTypes(this.getAuthorizedGrantTyped());
        consumer.setSecret(this.getSecret());
        if (this.getStrutsAction() == ApsAdminSystemConstants.ADD) {
            this.getOauthConsumerManager().addConsumer(consumer);
        } else if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT) {
            this.getOauthConsumerManager().updateConsumer(consumer);
        }
    } catch (Throwable t) {
        _logger.error("error in save", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : ConsumerRecordVO(org.entando.entando.aps.system.services.oauth2.model.ConsumerRecordVO)

Aggregations

ConsumerRecordVO (org.entando.entando.aps.system.services.oauth2.model.ConsumerRecordVO)7 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)2 IOException (java.io.IOException)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Date (java.util.Date)1 IOAuthConsumerManager (org.entando.entando.aps.system.services.oauth2.IOAuthConsumerManager)1