ConfigureSocialAuthN.java revision 3fc1b5e9b2ff286cd528a06154cc998198de1e70
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2014 ForgeRock AS.
*/
public class ConfigureSocialAuthN extends Task {
String providerName = getValidatedField(type, params, attrs, P_PROVIDER_NAME, "missing-provider-name");
}
}
return MessageFormat.format(messageTemplate, providerName, authModuleName, authChainName, SERVICE_NAME);
}
/**
* Grab the value specified from the incoming map, throwing a WorkflowException with the specified error key if the
* value is null or empty.
*
* @param params The incoming map.
* @param name The specified value to retrieve.
* @param errorKey Error key used if the retrieved value is null or empty.
* @return
* @throws WorkflowException thrown if the value found in the map is null or empty
*/
private String getNonEmptyString(Map<String, ?> params, String name, String errorKey) throws WorkflowException {
}
return value;
}
String clientSecretConfirm = getNonEmptyString(params, P_CLIENT_SECRET_CONFIRM, "missing-clientSecretConfirm");
}
return clientSecret;
}
try {
} catch (MalformedURLException murle) {
}
return redirectUrl;
}
String getValidatedField(String type, Map<String, ?> params, Map<String, Set<String>> attrs, String field,
} else {
}
return value;
}
}
try {
return true;
}
}
return false;
} catch (AMConfigurationException e) {
}
}
try {
} catch (SMSException e) {
} catch (SSOException e) {
}
}
// If the wizard didn't provide a discoveryUrl, see if it was in the properties file
if (discoveryUrl == null) {
}
if (discoveryUrl != null) {
}
return attrs;
}
/**
* Find a properties file, if it exists, and read its contents into a Map.
* @param type The type of provider we're setting up e.g. "google", "facebook", "microsoft", or "other"
* @return A map containing the property file contents. The empty map if the file could not be found.
*/
try {
} catch (IOException ioe) {
return Collections.emptyMap();
}
}
/**
* Gets the discovery URL from the map, fetches the well known config and adds appropriate values to the map.
* @param locale
* @param url The discovery url.
*/
throws WorkflowException {
return attrs;
}
/**
* Mockable method to fetch URL content.
* @param locale Error message locale.
* @param url Url to fetch content from.
* @return The content.
* @throws WorkflowException
*/
}
throws WorkflowException {
try {
Map<String, Set<String>> moduleAttrs = mgr.getAuthenticationSchema(AUTH_MODULE_TYPE).getAttributeValues();
// Override default attributes using the provided attrs, but skip any the auth module doesn't expect
}
}
} catch (AMConfigurationException e) {
}
}
private void createSocialAuthenticationChain(String realm, String authModuleName, String authChainName)
throws WorkflowException {
try {
} catch (SMSException e) {
} catch (SSOException e) {
} catch (AMConfigurationException e) {
}
}
/**
* Create a social service given the attributes specified.
* @param realm The realm/organisation
* @param chainName
* @param providerName
* @param icon
* @throws WorkflowException if there are problems modifying or assigning the service.
*/
private void createOrModifySocialService(String realm, String chainName, String providerName, String icon)
throws WorkflowException {
try {
} else {
}
} catch (SMSException smse) {
} catch (SSOException ssoe) {
DEBUG.warning("A session error occurred while creating/modifying social authentication service", ssoe);
}
}
/**
* @return The SSO token.
*/
private SSOToken getAdminToken() {
}
/**
* Carefully merge the values in two maps. The existing ("base") attributes are added first, then values in
* newAttrs.
*
* @param existingAttrs The "base" attributes.
* @param newAttrs Coinciding attributes from here overwrite ones in existing attributes.
* @return A map containing a combination of the two maps.
*/
if (existingValues == null) {
existingValues = new CaseInsensitiveHashSet();
}
}
return mergedAttrs;
}
}