Search in sources :

Example 1 with IDFFMetaManager

use of com.sun.identity.federation.meta.IDFFMetaManager 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);
    }
}
Also used : Set(java.util.Set) IOutput(com.sun.identity.cli.IOutput) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) Iterator(java.util.Iterator) CLIException(com.sun.identity.cli.CLIException)

Example 2 with IDFFMetaManager

use of com.sun.identity.federation.meta.IDFFMetaManager 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);
    }
}
Also used : IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) CLIException(com.sun.identity.cli.CLIException)

Example 3 with IDFFMetaManager

use of com.sun.identity.federation.meta.IDFFMetaManager 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();
        }
    }
}
Also used : IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) FileWriter(java.io.FileWriter) JAXBException(javax.xml.bind.JAXBException) IOException(java.io.IOException) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) CLIException(com.sun.identity.cli.CLIException) PrintWriter(java.io.PrintWriter)

Example 4 with IDFFMetaManager

use of com.sun.identity.federation.meta.IDFFMetaManager 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
            }
        }
    }
}
Also used : IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) JAXBException(javax.xml.bind.JAXBException) IOException(java.io.IOException) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) FileOutputStream(java.io.FileOutputStream) CLIException(com.sun.identity.cli.CLIException)

Example 5 with IDFFMetaManager

use of com.sun.identity.federation.meta.IDFFMetaManager 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);
    }
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) SPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement) COTException(com.sun.identity.cot.COTException) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) CLIException(com.sun.identity.cli.CLIException) IDPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)

Aggregations

IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)69 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)63 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)27 Iterator (java.util.Iterator)24 List (java.util.List)21 Set (java.util.Set)20 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)18 Map (java.util.Map)18 HashMap (java.util.HashMap)16 FSException (com.sun.identity.federation.common.FSException)15 ArrayList (java.util.ArrayList)15 HashSet (java.util.HashSet)14 IDPDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType)10 SAMLException (com.sun.identity.saml.common.SAMLException)10 IOException (java.io.IOException)10 CLIException (com.sun.identity.cli.CLIException)9 ProviderDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)9 IDPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)8 SPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement)7 EntityDescriptorElement (com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement)7