/*
- * Copyright (c) 2014, 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ * Copyright (c) 2014, 2017 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.aaa.sssd;
+import java.io.IOException;
import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Path;
private RuleProcessor ruleProcessor = null;
// Called by DM when all required dependencies are satisfied.
- void init(Component c) {
+ void init(Component componet) {
LOG.info("Initializing SSSD Plugin");
- Map<String, Object> properties = new HashMap<String, Object>(1);
+ Map<String, Object> properties = new HashMap<>(1);
properties.put(JsonGenerator.PRETTY_PRINTING, true);
generatorFactory = Json.createGeneratorFactory(properties);
Path mappingRulesPath = Paths.get(mappingRulesFile);
if (!Files.exists(mappingRulesPath)) {
- LOG.warn(String.format("mapping rules file (%s) "
- + "does not exist, SssdClaimAuth will be disabled", mappingRulesFile));
+ LOG.warn(String.format("mapping rules file (%s) " + "does not exist, SssdClaimAuth will be disabled",
+ mappingRulesFile));
return;
}
try {
ruleProcessor = new RuleProcessor(mappingRulesPath, null);
- } catch (Exception e) {
- LOG.error(String.format("mapping rules file (%s) "
- + "could not be loaded, SssdClaimAuth will be disabled. " + "error = %s",
+ } catch (IOException e) {
+ LOG.error(String.format(
+ "mapping rules file (%s) " + "could not be loaded, SssdClaimAuth will be disabled. " + "error = %s",
mappingRulesFile, e));
}
}
* Transform a Map of assertions into a {@link Claim} via a set of mapping
* rules.
*
+ * <p>
* A set of mapping rules have been previously loaded. the incoming
* assertion is converted to a JSON document and presented to the
* {@link RuleProcessor}. If the RuleProcessor can successfully transform
* the assertion given the site specific set of rules it will return a Map
* of values which will then be used to build a {@link Claim}. The rule
- * should return one or more of the following which will be used to populate
- * the Claim.
+ * should return one or more of the following which will be used to
+ * populate.
*
- * <dl>
- * <dt>ClientId</dt>
- * <dd>A string.
+ * <p>
+ * ClientId:a string.
*
- * @see org.opendaylight.aaa.api.Claim#clientId() </dd>
+ * @see org.opendaylight.aaa.api.Claim#clientId()
*
- * <dt>UserId</dt> <dd>A string.
- * @see org.opendaylight.aaa.api.Claim#userId() </dd>
+ * UserId: a string
+ * @see org.opendaylight.aaa.api.Claim#userId()
*
- * <dt>User</dt> <dd>A string.
- * @see org.opendaylight.aaa.api.Claim#user() </dd>
+ * User: a string.
+ * @see org.opendaylight.aaa.api.Claim#user()
*
- * <dt>Domain</dt> <dd>A string.
- * @see org.opendaylight.aaa.api.Claim#domain() </dd>
+ * Domain: a string.
+ * @see org.opendaylight.aaa.api.Claim#domain()
*
- * <dt>Roles</dt> <dd>An array of strings.
- * @see org.opendaylight.aaa.api.Claim#roles() </dd>
- *
- * </dl>
+ * Roles: an array of strings.
+ * @see org.opendaylight.aaa.api.Claim#roles()
*
* @param assertion
* A Map of name/value assertions provided by an external IdP
* @return A {@link Claim} if successful, null otherwise.
*/
-
@Override
public Claim transform(Map<String, Object> assertion) {
String assertionJson;
- Map<String, Object> mapped;
assertionJson = claimToJson(assertion);
if (ruleProcessor == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("assertionJson=\n{}", assertionJson);
}
-
+ Map<String, Object> mapped;
mapped = ruleProcessor.process(assertionJson);
if (mapped == null) {
if (LOG.isDebugEnabled()) {
/**
* Convert a Claim Map into a JSON object.
*
+ * <p>
* Given a Map of name/value pairs convert it into a JSON object and return
* it as a string. This is not a general purpose routine used to convert any
* Map into JSON because a claim has the restriction that each value must be
* <li>Boolean</li>
* <li>null</li>
* </ul>
- *
* See also {@link ClaimAuth}.
*
* @param claim
} else if (value == null) {
generator.write(name, JsonValue.NULL);
} else {
- LOG.warn(String.format("ignoring claim unsupported value type "
- + "entry %s has type %s", name, value.getClass().getSimpleName()));
+ LOG.warn(String.format("ignoring claim unsupported value type " + "entry %s has type %s", name,
+ value.getClass().getSimpleName()));
}
}
generator.writeEnd();