use of javax.xml.bind.JAXBException in project OpenAM by OpenRock.
the class ImportMetaData method importIDFFMetaData.
private String importIDFFMetaData(String realm, IDFFMetaManager metaManager) throws IDFFMetaException, CLIException {
InputStream is = null;
String out = (webAccess) ? "web" : metadata;
Object[] objs = { out };
String entityID = null;
try {
Object obj;
if (webAccess) {
obj = IDFFMetaUtils.convertStringToJAXB(metadata);
} else {
is = new FileInputStream(metadata);
Document doc = XMLUtils.toDOMDocument(is, CommandManager.getDebugger());
obj = IDFFMetaUtils.convertNodeToJAXB(doc);
}
if (obj instanceof com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement) {
com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement descriptor = (com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement) obj;
entityID = descriptor.getProviderID();
//TODO: signature
//SAML2MetaSecurityUtils.verifySignature(doc);
//
metaManager.createEntityDescriptor(realm, descriptor);
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("import-entity-succeeded"), objs));
}
return entityID;
} catch (FileNotFoundException e) {
throw new CLIException(MessageFormat.format(getResourceString("file-not-found"), objs), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (JAXBException e) {
debugWarning("ImportMetaData.importMetaData", e);
throw new CLIException(MessageFormat.format(getResourceString("import-entity-exception-invalid-descriptor-file"), objs), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IllegalArgumentException e) {
debugWarning("ImportMetaData.importMetaData", e);
throw new CLIException(MessageFormat.format(getResourceString("import-entity-exception-invalid-descriptor-file"), objs), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
//do not if the file cannot be closed.
}
}
}
}
use of javax.xml.bind.JAXBException in project OpenAM by OpenRock.
the class ImportMetaData method getIDFFEntityConfigElement.
private com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement getIDFFEntityConfigElement() throws IDFFMetaException, CLIException {
String out = (webAccess) ? "web" : extendedData;
Object[] objs = { out };
try {
Object obj;
if (webAccess) {
obj = IDFFMetaUtils.convertStringToJAXB(extendedData);
} else {
obj = IDFFMetaUtils.convertStringToJAXB(getFileContent(extendedData));
}
return (obj instanceof com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement) ? (com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement) obj : null;
} catch (IOException e) {
throw new CLIException(MessageFormat.format(getResourceString("file-not-found"), objs), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (JAXBException e) {
debugWarning("ImportMetaData.importExtendedData", e);
throw new CLIException(MessageFormat.format(getResourceString("import-entity-exception-invalid-config-file"), objs), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IllegalArgumentException e) {
debugWarning("ImportMetaData.importExtendedData", e);
throw new CLIException(MessageFormat.format(getResourceString("import-entity-exception-invalid-config-file"), objs), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of javax.xml.bind.JAXBException in project OpenAM by OpenRock.
the class IDFFModelImpl method updateIDPEntityConfig.
/**
* Modifies a identity provider's extended metadata.
*
* @param entityName name of Entity Descriptor.
* @param realm where entity exists.
* @param attrValues Map of attribute name to set of values.
* @throws AMConsoleException if provider cannot be modified.
* @throws JAXBException if provider cannot be retrieved.
*/
public void updateIDPEntityConfig(String realm, String entityName, Map attrValues) throws AMConsoleException {
String[] params = { realm, entityName, "IDFF", "IDP-Extended Metadata" };
logEvent("ATTEMPT_MODIFY_ENTITY_DESCRIPTOR", params);
try {
IDFFMetaManager idffMetaMgr = getIDFFMetaManager();
EntityConfigElement entityConfig = idffMetaMgr.getEntityConfig(realm, entityName);
if (entityConfig == null) {
throw new AMConsoleException("invalid.entity.name");
}
IDPDescriptorConfigElement idpDecConfigElement = idffMetaMgr.getIDPDescriptorConfig(realm, entityName);
if (idpDecConfigElement == null) {
throw new AMConsoleException("invalid.config.element");
} else {
updateAttrInConfig(idpDecConfigElement, attrValues, EntityModel.IDENTITY_PROVIDER);
}
//saves the attributes by passing the new entityConfig object
idffMetaMgr.setEntityConfig(realm, entityConfig);
logEvent("SUCCEED_MODIFY_ENTITY_DESCRIPTOR", params);
} catch (IDFFMetaException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, entityName, "IDFF", "IDP-Extended Metadata", strError };
logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
throw new AMConsoleException(strError);
} catch (JAXBException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, entityName, "IDFF", "IDP-Extended Metadata", strError };
logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
throw new AMConsoleException(strError);
}
}
use of javax.xml.bind.JAXBException in project OpenAM by OpenRock.
the class ImportEntityModelImpl method importSAML2MetaData.
private void importSAML2MetaData(SAML2MetaManager metaManager, String realm) throws SAML2MetaException, AMConsoleException {
try {
Document doc = XMLUtils.toDOMDocument(standardMetaData, debug);
SAML2MetaUtils.importSAML2Document(metaManager, realm, doc);
} catch (JAXBException e) {
debug.error("ImportEntityModel.importSAML2MetaData", e);
throw new AMConsoleException(e);
} catch (IllegalArgumentException e) {
debug.warning("ImportEntityModel.importSAML2MetaData", e);
throw new AMConsoleException(e);
}
}
use of javax.xml.bind.JAXBException in project OpenAM by OpenRock.
the class ImportEntityModelImpl method importWSFedMetaData.
private void importWSFedMetaData() throws WSFederationMetaException, AMConsoleException {
try {
Object obj = WSFederationMetaUtils.convertStringToJAXB(standardMetaData);
if (obj instanceof com.sun.identity.wsfederation.jaxb.wsfederation.FederationMetadataElement) {
obj = ((com.sun.identity.wsfederation.jaxb.wsfederation.FederationMetadataElement) obj).getAny().get(0);
}
if (obj instanceof com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement) {
com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement federation = (com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement) obj;
// TBD
//Document doc = XMLUtils.toDOMDocument(standardMetadata, debug);
// WSFederationMetaSecurityUtils.verifySignature(doc);
(new WSFederationMetaManager()).createFederation(realm, federation);
}
} catch (JAXBException e) {
debug.error("ImportEntityModel.importWSFedMetaData", e);
throw new AMConsoleException(e);
} catch (IllegalArgumentException e) {
debug.error("ImportEntityModel.importWSFedMetaData", e);
throw new AMConsoleException(e);
}
}
Aggregations