use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class WSFedPropertiesModelImpl method getIdentityProviderAttributes.
/**
* Returns a <code>Map</code> with identity provider attributes and values.
*
* @param realm to which the entity belongs.
* @param fedId is the Federation Id otherwise known as the entity id.
* @return attribute values of IDP based on realm and fedId passed.
* @throws AMConsoleException if unable to retreive the Identity Provider
* attrubutes based on the realm and fedId passed.
*/
public Map getIdentityProviderAttributes(String realm, String fedId) throws AMConsoleException {
Map IDPAttributes = null;
try {
WSFederationMetaManager metaManager = getWSFederationMetaManager();
IDPSSOConfigElement idpconfig = metaManager.getIDPSSOConfig(realm, fedId);
if (idpconfig != null) {
IDPAttributes = WSFederationMetaUtils.getAttributes(idpconfig);
}
} catch (WSFederationMetaException e) {
debug.warning("WSFedPropertiesModelImpl.getIdentityProviderAttributes", e);
throw new AMConsoleException(e.getMessage());
}
return (IDPAttributes != null) ? IDPAttributes : Collections.EMPTY_MAP;
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class WSFedPropertiesModelImpl method setSPExtAttributeValues.
/**
* Saves the extended metadata attribute values for the SP.
*
* @param realm to which the entity belongs.
* @param fedId is the entity id.
* @param spExtvalues has the extended attribute value pairs of SP.
* @param location has the information whether remote or hosted.
* @throws AMConsoleException if saving of attribute value fails.
*/
public void setSPExtAttributeValues(String realm, String fedId, Map spExtvalues, String location) throws AMConsoleException {
try {
String role = EntityModel.SERVICE_PROVIDER;
//fed is the extended entity configuration object under the realm
WSFederationMetaManager metaManager = getWSFederationMetaManager();
FederationConfigElement fed = metaManager.getEntityConfig(realm, fedId);
if (fed == null) {
SPEX_DATA_MAP.put(TF_DISPNAME, Collections.EMPTY_SET);
createExtendedObject(realm, fedId, location, SERVICE_PROVIDER, SPEX_DATA_MAP);
fed = metaManager.getEntityConfig(realm, fedId);
}
SPSSOConfigElement spsso = getspsso(fed);
if (spsso != null) {
BaseConfigType baseConfig = (BaseConfigType) spsso;
updateBaseConfig(baseConfig, spExtvalues, role);
}
//saves the attributes by passing the new fed object
metaManager.setEntityConfig(realm, fed);
} catch (JAXBException e) {
debug.warning("WSFedPropertiesModelImpl.setSPExtAttributeValues", e);
throw new AMConsoleException(e.getMessage());
} catch (WSFederationMetaException e) {
debug.warning("WSFedPropertiesModelImpl.setSPExtAttributeValues", e);
throw new AMConsoleException(e.getMessage());
}
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class UpdateMetadataKeyInfo method handleWSFedRequest.
private void handleWSFedRequest(RequestContext rc) throws CLIException {
try {
WSFederationMetaManager metaManager = new WSFederationMetaManager(ssoToken);
FederationElement descriptor = metaManager.getEntityDescriptor(realm, entityID);
if (descriptor == null) {
Object[] objs2 = { entityID, realm };
throw new CLIException(MessageFormat.format(getResourceString("update-meta-keyinfo-exception-entity-not-exist"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
if (!isEmpty(spSigningAliases)) {
if (NULL_ALIAS.equals(getFirstItem(spSigningAliases))) {
WSFederationMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, null, false);
} else {
WSFederationMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, getFirstItem(spSigningAliases), false);
}
}
if (!isEmpty(idpSigningAliases)) {
if (NULL_ALIAS.equals(getFirstItem(idpSigningAliases))) {
WSFederationMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, null, true);
} else {
WSFederationMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, getFirstItem(idpSigningAliases), true);
}
}
if (!isEmpty(spEncryptionAliases)) {
Object[] objs2 = { entityID, realm };
throw new CLIException(MessageFormat.format(getResourceString("update-meta-keyinfo-exception-invalid-option"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
if (!isEmpty(idpEncryptionAliases)) {
Object[] objs2 = { entityID, realm };
throw new CLIException(MessageFormat.format(getResourceString("update-meta-keyinfo-exception-invalid-option"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
Object[] objs = { entityID };
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("update-keyinfo-succeeded"), objs));
} catch (WSFederationMetaException e) {
WSFederationMetaUtils.debug.error("UpdateMetaKey.handleIDFFRequest", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class ExportMetaData method runWSFedExportMeta.
private void runWSFedExportMeta() throws CLIException {
PrintWriter pw = null;
String out = (isWebBase) ? "web" : metadata;
Object[] objs = { out };
Object[] objs2 = { entityID, realm };
try {
WSFederationMetaManager metaManager = new WSFederationMetaManager(ssoToken);
FederationElement federation = metaManager.getEntityDescriptor(realm, entityID);
if (federation == null) {
throw new CLIException(MessageFormat.format(getResourceString("export-entity-exception-entity-descriptor-not-exist"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
String xmlstr = WSFederationMetaUtils.convertJAXBToString(federation);
xmlstr = WSFederationMetaSecurityUtils.formatBase64BinaryElement(xmlstr);
if (isWebBase) {
getOutputWriter().printlnMessage(xmlstr);
} else {
pw = new PrintWriter(new FileWriter(metadata));
pw.print(xmlstr);
}
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("export-entity-export-descriptor-succeeded"), objs));
} catch (WSFederationMetaException e) {
debugError("ExportMetaData.runExportMeta", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IOException e) {
debugError("ExportMetaData.runExportMeta", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (JAXBException e) {
debugWarning("ExportMetaData.runExportMeta", e);
throw new CLIException(MessageFormat.format(getResourceString("export-entity-exception-invalid_descriptor"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IllegalArgumentException e) {
debugWarning("ExportMetaData.runExportMeta", e);
throw new CLIException(MessageFormat.format(getResourceString("export-entity-exception-invalid_descriptor"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} finally {
if (pw != null) {
pw.close();
}
}
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class ConfigFedMonitoring method getWSFedEntities.
private Map getWSFedEntities(String realm) {
String classMethod = "ConfigFedMonitoring.getWSFedEntities:";
Set wsEnts = null;
// wsentMap: entity name => Map of ("location", "roles") -> values
Map wsentMap = new HashMap();
try {
WSFederationMetaManager metaManager = new WSFederationMetaManager();
wsEnts = metaManager.getAllEntities(realm);
List hosted = metaManager.getAllHostedEntities(realm);
for (Iterator it = wsEnts.iterator(); it.hasNext(); ) {
Map wse = new HashMap();
String entId = (String) it.next();
if ((hosted != null) && hosted.contains(entId)) {
wse.put("location", "hosted");
} else {
wse.put("location", "remote");
}
wse.put("roles", listToString(getWSFedRoles(entId, realm)));
wsentMap.put(entId, wse);
}
} catch (WSFederationMetaException e) {
debug.error(classMethod + "getting WSFed entities for realm " + realm + ": " + e.getMessage());
}
return wsentMap;
}
Aggregations