use of com.sun.identity.workflow.WorkflowException in project OpenAM by OpenRock.
the class CreateMetaDataModelImpl method createSAMLv2Provider.
/**
* Creates a SAMLv2 provider.
*
* @param realm Realm Name.
* @param entityId Entity Id.
* @param values Map of property name to values.
*
* @throws AMConsoleException if duplicate metaAliases provided or unable to create or import metadata.
*/
public void createSAMLv2Provider(String realm, String entityId, Map values) throws AMConsoleException {
try {
// validate hosted entities to check that metaAliases are unique
List<String> metaAliases = getFederationAlias(values, MetaTemplateParameters.P_SAML_ALIASES);
Set<String> duplicateCheck = new HashSet<String>(metaAliases);
if (duplicateCheck.size() < metaAliases.size()) {
throw new AMConsoleException(getLocalizedString("federation.create.provider.duplicate.metaAlias"));
}
SAML2MetaManager mgr = new SAML2MetaManager();
mgr.validateMetaAliasForNewEntity(realm, metaAliases);
String metadata = CreateSAML2HostedProviderTemplate.buildMetaDataTemplate(entityId, values, requestURL);
String extendedData = CreateSAML2HostedProviderTemplate.createExtendedDataTemplate(entityId, values, requestURL);
ImportSAML2MetaData.importData(realm, metadata, extendedData);
} catch (WorkflowException ex) {
throw new AMConsoleException(getErrorString(ex));
} catch (SAML2MetaException ex) {
throw new AMConsoleException(getErrorString(ex));
}
}
use of com.sun.identity.workflow.WorkflowException in project OpenAM by OpenRock.
the class ImportEntityModelImpl method importEntity.
/**
* Import one of the following entity types: SAMLv2, IDFF, or WSFed. The
* parameters are the file names containing the standard and
* extended metadata. The standard is required, while the extended is
* optional.
*
* @param requestData is a Map containing the name of the standard meta
* data file name, and the name of the extended meta data file name.
*
* @throws AMConsoleException if unable to process this request.
*/
@Override
public void importEntity(Map requestData) throws AMConsoleException {
try {
// standardFile is the name of the file containing the metada. This
// is a required parameter. If we don't find it in the request throw
// an exception.
String standardFile = (String) requestData.get(STANDARD_META);
if (standardFile == null) {
throw new AMConsoleException("missing.metadata");
}
standardMetaData = Task.getContent(standardFile, getUserLocale());
String protocol = getProtocol(standardMetaData);
// try loading the extended metadata, which is optional
String extendedFile = (String) requestData.get(EXTENDED_META);
if ((extendedFile != null) && (extendedFile.length() > 0)) {
extendedMetaData = Task.getContent(extendedFile, getUserLocale());
String tmp = getProtocol(standardMetaData);
// must be the same.
if (!protocol.equals(tmp)) {
throw new AMConsoleException("protocol.mismatch");
}
}
// the realm is used by the createXXX commands for storing the entity
realm = (String) requestData.get(REALM_NAME);
if (realm == null) {
realm = DEFAULT_ROOT;
}
if (protocol.equals(SAML2Constants.PROTOCOL_NAMESPACE)) {
createSAMLv2Entity();
} else if (protocol.equals(IDFF)) {
createIDFFEntity();
} else {
createWSFedEntity();
}
} catch (WorkflowException ex) {
throw new AMConsoleException(ex);
}
}
Aggregations