use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.
the class ListEntities method handleIDFFRequest.
private void handleIDFFRequest(RequestContext rc) throws CLIException {
IOutput outputWriter = getOutputWriter();
Object[] objs = { realm };
try {
IDFFMetaManager metaManager = new IDFFMetaManager(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 (IDFFMetaException e) {
debugWarning("ListEntities.handleIDFFRequest", 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.federation.meta.IDFFMetaException in project OpenAM by OpenRock.
the class UpdateMetadataKeyInfo method handleIDFFRequest.
private void handleIDFFRequest(RequestContext rc) throws CLIException {
try {
IDFFMetaManager metaManager = new IDFFMetaManager(ssoToken);
com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement 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))) {
IDFFMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, null, true, false, null, 0);
} else {
IDFFMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, getFirstItem(spSigningAliases), true, false, null, 0);
}
}
if (!isEmpty(idpSigningAliases)) {
if (NULL_ALIAS.equals(getFirstItem(idpSigningAliases))) {
IDFFMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, null, true, true, null, 0);
} else {
IDFFMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, getFirstItem(idpSigningAliases), true, true, null, 0);
}
}
if (!isEmpty(spEncryptionAliases)) {
if (NULL_ALIAS.equals(getFirstItem(spEncryptionAliases))) {
IDFFMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, null, false, false, XMLCipher.AES_128, 128);
} else {
IDFFMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, getFirstItem(spEncryptionAliases), false, false, XMLCipher.AES_128, 128);
}
}
if (!isEmpty(idpEncryptionAliases)) {
if (NULL_ALIAS.equals(getFirstItem(idpEncryptionAliases))) {
IDFFMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, null, false, true, XMLCipher.AES_128, 128);
} else {
IDFFMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, getFirstItem(idpEncryptionAliases), false, true, XMLCipher.AES_128, 128);
}
}
Object[] objs = { entityID };
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("update-keyinfo-succeeded"), objs));
} catch (IDFFMetaException e) {
IDFFMetaUtils.debug.error("UpdateMetaKey.handleIDFFRequest", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.
the class ExportMetaData method runIDFFExportMeta.
private void runIDFFExportMeta() throws CLIException {
PrintWriter pw = null;
String out = (isWebBase) ? "web" : metadata;
Object[] objs = { out };
Object[] objs2 = { entityID, realm };
try {
IDFFMetaManager metaManager = new IDFFMetaManager(ssoToken);
com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement descriptor = metaManager.getEntityDescriptor(realm, entityID);
if (descriptor == null) {
throw new CLIException(MessageFormat.format(getResourceString("export-entity-exception-entity-descriptor-not-exist"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
String xmlstr = IDFFMetaUtils.convertJAXBToString(descriptor);
xmlstr = SAML2MetaSecurityUtils.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 (IDFFMetaException e) {
debugError("ExportMetaData.runIDFFExportMeta", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IOException e) {
debugError("ExportMetaData.runIDFFExportMeta", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (JAXBException e) {
debugWarning("ExportMetaData.runIDFFExportMeta", 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.federation.meta.IDFFMetaException in project OpenAM by OpenRock.
the class ExportMetaData method runIDFFExportExtended.
private void runIDFFExportExtended() throws CLIException {
OutputStream os = null;
String out = (isWebBase) ? "web" : extendedData;
Object[] objs = { out };
Object[] objs2 = { entityID, realm };
try {
IDFFMetaManager metaManager = new IDFFMetaManager(ssoToken);
com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement 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);
}
String xmlString = IDFFMetaUtils.convertJAXBToString(config);
if (isWebBase) {
getOutputWriter().printlnMessage(xmlString);
} else {
os = new FileOutputStream(extendedData);
os.write(xmlString.getBytes());
}
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("export-entity-export-config-succeeded"), objs));
} catch (IDFFMetaException e) {
debugWarning("ExportMetaData.runIDFFExportExtended", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IOException e) {
debugWarning("ExportMetaData.runIDFFExportExtended", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (JAXBException e) {
debugWarning("ExportMetaData.runIDFFExportExtended", e);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IllegalArgumentException e) {
debugWarning("ExportMetaData.runIDFFExportExtended", 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.federation.meta.IDFFMetaException in project OpenAM by OpenRock.
the class ImportMetaData method handleIDFFRequest.
private void handleIDFFRequest(RequestContext rc) throws CLIException {
try {
IDFFMetaManager metaManager = new IDFFMetaManager(ssoToken);
String entityID = null;
com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement configElt = null;
if (extendedData != null) {
configElt = getIDFFEntityConfigElement();
/*
* see note at the end of this class for how we decide
* the realm value
*/
if ((configElt != null) && configElt.isHosted()) {
IDPDescriptorConfigElement idpConfig = IDFFMetaUtils.getIDPDescriptorConfig(configElt);
if (idpConfig != null) {
realm = SAML2MetaUtils.getRealmByMetaAlias(idpConfig.getMetaAlias());
} else {
SPDescriptorConfigElement spConfig = IDFFMetaUtils.getSPDescriptorConfig(configElt);
if (spConfig != null) {
realm = SAML2MetaUtils.getRealmByMetaAlias(spConfig.getMetaAlias());
}
}
}
}
if (metadata != null) {
entityID = importIDFFMetaData(realm, metaManager);
}
if (configElt != null) {
String out = (webAccess) ? "web" : extendedData;
Object[] objs = { out };
metaManager.createEntityConfig(realm, configElt);
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("import-entity-succeeded"), objs));
}
if ((cot != null) && (cot.length() > 0) && (entityID != null) && (entityID.length() > 0)) {
CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
if (!cotManager.isInCircleOfTrust(realm, cot, spec, entityID)) {
cotManager.addCircleOfTrustMember(realm, cot, spec, entityID);
}
}
} catch (IDFFMetaException e) {
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (COTException e) {
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
Aggregations