Skip to content

Commit

Permalink
[REST-3] #resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Jan 30, 2018
1 parent a4b4c03 commit 0ea16b3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ public void setPassword(GuardedString password) {
this.password = password;
}

private String bearer;

@ConfigurationProperty(displayMessageKey = "bearer.display",
helpMessageKey = "bearer.help", order = 2)
public String getBearer() {
return bearer;
}

public void setBearer(final String bearer) {
this.bearer = bearer;
}

@Override
public void validate() {
LOG.info("Validate " + getClass().getName());
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/net/tirasa/connid/bundles/rest/RESTConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
package net.tirasa.connid.bundles.rest;

import static net.tirasa.connid.commons.scripted.Constants.MSG_OBJECT_CLASS_REQUIRED;

import java.util.HashMap;
import java.util.Map;
import javax.ws.rs.core.HttpHeaders;
import net.tirasa.connid.commons.scripted.AbstractScriptedConnector;
import net.tirasa.connid.commons.scripted.Constants;
import org.apache.cxf.jaxrs.client.WebClient;
import org.identityconnectors.common.security.SecurityUtil;
import org.identityconnectors.framework.common.objects.ObjectClass;
Expand All @@ -42,8 +42,11 @@ public void init(final Configuration cfg) {
config.getUsername(),
config.getPassword() == null ? null : SecurityUtil.decrypt(config.getPassword()),
null).
accept(this.getConfiguration().getAccept()).
type(this.getConfiguration().getContentType());
accept(config.getAccept()).
type(config.getContentType());
if (config.getBearer() != null) {
this.client.header(HttpHeaders.AUTHORIZATION, "Bearer " + config.getBearer());
}

super.init(cfg);
}
Expand All @@ -61,7 +64,7 @@ public FilterTranslator<Map<String, Object>> createFilterTranslator(
final ObjectClass objectClass, final OperationOptions options) {

if (objectClass == null) {
throw new IllegalArgumentException(config.getMessage(MSG_OBJECT_CLASS_REQUIRED));
throw new IllegalArgumentException(config.getMessage(Constants.MSG_OBJECT_CLASS_REQUIRED));
}
LOG.ok("ObjectClass: {0}", objectClass.getObjectClassValue());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@
# limitations under the License.
#

sampleProperty.display=Sample Property
sampleProperty.help=Only a sample property
rest.connector.display=REST Connector
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@
# limitations under the License.
#

sampleProperty.display=Propriet\u00e0 d'esempio
sampleProperty.help=Solo una propriet\u00e0 d'esempio
sample.connector.display=Connettore d'esempio
rest.connector.display=Connettore REST

0 comments on commit 0ea16b3

Please sign in to comment.