use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class ImportMetaData method handleWSFedRequest.
private void handleWSFedRequest(RequestContext rc) throws CLIException {
try {
String federationID = null;
List<String> newMetaAliases = null;
com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement configElt = null;
if (extendedData != null) {
configElt = getWSFedEntityConfigElement();
/*
* see note at the end of this class for how we decide
* the realm value
*/
if (configElt != null && configElt.isHosted()) {
List config = configElt.getIDPSSOConfigOrSPSSOConfig();
if (!config.isEmpty()) {
com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType bConfig = (com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) config.iterator().next();
realm = WSFederationMetaUtils.getRealmByMetaAlias(bConfig.getMetaAlias());
newMetaAliases = getMetaAliases(config);
}
}
}
WSFederationMetaManager metaManager = new WSFederationMetaManager(ssoToken);
if (metadata != null) {
federationID = importWSFedMetaData();
}
if (configElt != null) {
if (null != newMetaAliases && !newMetaAliases.isEmpty()) {
metaManager.validateMetaAliasForNewEntity(realm, newMetaAliases);
}
metaManager.createEntityConfig(realm, configElt);
String out = (webAccess) ? "web" : extendedData;
Object[] objs = { out };
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("import-entity-succeeded"), objs));
}
if ((cot != null) && (cot.length() > 0) && (federationID != null)) {
CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
if (!cotManager.isInCircleOfTrust(realm, cot, spec, federationID)) {
cotManager.addCircleOfTrustMember(realm, cot, spec, federationID);
}
}
} catch (COTException e) {
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (WSFederationMetaException 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 ListEntities method handleWSFedRequest.
private void handleWSFedRequest(RequestContext rc) throws CLIException {
IOutput outputWriter = getOutputWriter();
Object[] objs = { realm };
try {
WSFederationMetaManager metaManager = new WSFederationMetaManager(ssoToken);
Set entities = metaManager.getAllEntities(realm);
if ((entities == null) || entities.isEmpty()) {
outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-entities-no-entities"), objs));
} else {
outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-entities-entity-listing"), objs));
for (Iterator i = entities.iterator(); i.hasNext(); ) {
String name = (String) i.next();
outputWriter.printlnMessage(" " + name);
}
}
} catch (WSFederationMetaException e) {
debugWarning("ListEntities.handleRequest", e);
String[] args = { realm, e.getMessage() };
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_ENTITIES", args);
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 runWSFedExportMetaSign.
private void runWSFedExportMetaSign() throws CLIException {
PrintWriter pw = null;
String out = (isWebBase) ? "web" : metadata;
Object[] objs = { out };
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("export-entity-exception-entity-descriptor-not-exist"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement spConfig = metaManager.getSPSSOConfig(realm, entityID);
com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement idpConfig = metaManager.getIDPSSOConfig(realm, entityID);
Document doc = WSFederationMetaSecurityUtils.sign(descriptor, spConfig, idpConfig);
if (doc == null) {
runWSFedExportMeta();
return;
} else {
String xmlstr = XMLUtils.print(doc);
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.runExportMetaSign", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (JAXBException jaxbe) {
Object[] objs3 = { entityID, realm };
throw new CLIException(MessageFormat.format(getResourceString("export-entity-exception-invalid_descriptor"), objs3), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IOException e) {
debugError("ExportMetaData.runExportMetaSign", e);
throw new CLIException(e.getMessage(), 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 ExportMetaData method runWSFedExportExtended.
private void runWSFedExportExtended() throws CLIException {
OutputStream os = null;
String out = (isWebBase) ? "web" : extendedData;
Object[] objs = { out };
Object[] objs2 = { entityID, realm };
try {
WSFederationMetaManager metaManager = new WSFederationMetaManager(ssoToken);
com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement config = metaManager.getEntityConfig(realm, entityID);
if (config == null) {
throw new CLIException(MessageFormat.format(getResourceString("export-entity-exception-entity-config-not-exist"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
if (isWebBase) {
os = new ByteArrayOutputStream();
} else {
os = new FileOutputStream(extendedData);
}
WSFederationMetaUtils.convertJAXBToOutputStream(config, os);
if (isWebBase) {
getOutputWriter().printlnMessage(os.toString());
}
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("export-entity-export-config-succeeded"), objs));
} catch (WSFederationMetaException e) {
debugError("ExportMetaData.runExportExtended", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (FileNotFoundException e) {
debugWarning("ExportMetaData.runExportExtended", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (JAXBException e) {
debugWarning("ExportMetaData.runExportExtended", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IllegalArgumentException e) {
debugWarning("ExportMetaData.runExportExtended", e);
throw new CLIException(MessageFormat.format(getResourceString("export-entity-exception-invalid-config"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
// ignore
}
}
}
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class DeleteMetaData method handleWSFedRequest.
private void handleWSFedRequest(RequestContext rc) throws CLIException {
try {
WSFederationMetaManager metaManager = new WSFederationMetaManager(ssoToken);
if (metaManager.getEntityDescriptor(realm, entityID) == null) {
Object[] param = { entityID };
throw new CLIException(MessageFormat.format(getResourceString("delete-entity-entity-not-exist"), param), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
if (extendedOnly) {
metaManager.deleteEntityConfig(realm, entityID);
Object[] objs = { entityID };
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("delete-entity-config-deleted"), objs));
} else {
metaManager.deleteFederation(realm, entityID);
Object[] objs = { entityID };
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("delete-entity-descriptor-deleted"), objs));
}
} catch (WSFederationMetaException e) {
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
Aggregations