Search in sources :

Example 16 with IDFFMetaManager

use of com.sun.identity.federation.meta.IDFFMetaManager in project OpenAM by OpenRock.

the class IDFFModelImpl method getAffiliateProfileAttributeValues.

/**
     * Returns affiliate profile attribute values.
     *
     * @param realm the realm in which the entity resides.
     * @param entityName name of Entity Descriptor.
     * @return affiliate profile attribute values.
     * @throws AMConsoleException if attribute values cannot be obtained.
     */
public Map getAffiliateProfileAttributeValues(String realm, String entityName) throws AMConsoleException {
    String[] params = { realm, entityName, "IDFF", "IDP" };
    logEvent("ATTEMPT_GET_AFFILIATE_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    Map values = new HashMap();
    try {
        IDFFMetaManager idffManager = getIDFFMetaManager();
        AffiliationDescriptorType aDesc = (AffiliationDescriptorType) idffManager.getAffiliationDescriptor(realm, entityName);
        if (aDesc != null) {
            values.put(ATTR_AFFILIATE_ID, returnEmptySetIfValueIsNull(aDesc.getAffiliationID()));
            values.put(ATTR_AFFILIATE_OWNER_ID, returnEmptySetIfValueIsNull(aDesc.getAffiliationOwnerID()));
            BaseConfigType affiliationConfig = idffManager.getAffiliationDescriptorConfig(realm, entityName);
            if (affiliationConfig != null) {
                Map map = IDFFMetaUtils.getAttributes(affiliationConfig);
                if (map.containsKey(ATTR_AFFILIATE_SIGNING_CERT_ALIAS)) {
                    values.put(ATTR_AFFILIATE_SIGNING_CERT_ALIAS, returnEmptySetIfValueIsNull(convertListToSet((List) map.get(ATTR_AFFILIATE_SIGNING_CERT_ALIAS))));
                } else {
                    values.put(ATTR_AFFILIATE_SIGNING_CERT_ALIAS, Collections.EMPTY_SET);
                }
                if (map.containsKey(ATTR_AFFILIATE_ENCRYPTION_CERT_ALIAS)) {
                    values.put(ATTR_AFFILIATE_ENCRYPTION_CERT_ALIAS, returnEmptySetIfValueIsNull(convertListToSet((List) map.get(ATTR_AFFILIATE_ENCRYPTION_CERT_ALIAS))));
                } else {
                    values.put(ATTR_AFFILIATE_ENCRYPTION_CERT_ALIAS, Collections.EMPTY_SET);
                }
            }
        } else {
            values.put(ATTR_AFFILIATE_ID, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_OWNER_ID, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_VALID_UNTIL, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_CACHE_DURATION, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_SIGNING_CERT_ALIAS, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_ENCRYPTION_CERT_ALIAS, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_ENCRYPTION_KEY_SIZE, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_ENCRYPTION_KEY_ALGORITHM, Collections.EMPTY_SET);
        }
        logEvent("SUCCEED_GET_AFFILIATE_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    } catch (IDFFMetaException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "IDFF", "SP", strError };
        logEvent("FEDERATION_EXCEPTION_GET_AFFILIATE_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    }
    return (values != null) ? values : Collections.EMPTY_MAP;
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) HashMap(java.util.HashMap) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) AffiliationDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.AffiliationDescriptorType) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with IDFFMetaManager

use of com.sun.identity.federation.meta.IDFFMetaManager in project OpenAM by OpenRock.

the class IDFFModelImpl method getIDPAuthenticationContexts.

/**
     * Returns the object of Auththentication Contexts in IDP.
     *
     * @param realm Realm of Entity
     * @param entityName Name of Entity Descriptor.       
     * @return attributes values of provider.
     */
public IDFFAuthContexts getIDPAuthenticationContexts(String realm, String entityName) throws AMConsoleException {
    String str = null;
    IDFFAuthContexts cxt = new IDFFAuthContexts();
    try {
        List tmpList = new ArrayList();
        IDFFMetaManager manager = getIDFFMetaManager();
        Map map = new HashMap();
        BaseConfigType idpConfig = manager.getIDPDescriptorConfig(realm, entityName);
        if (idpConfig != null) {
            map = IDFFMetaUtils.getAttributes(idpConfig);
        } else {
            throw new AMConsoleException("invalid.entity.name");
        }
        List list = (List) map.get(ATTR_IDP_AUTHN_CONTEXT_MAPPING);
        for (int i = 0; i < list.size(); i++) {
            String tmp = (String) list.get(i);
            int index = tmp.lastIndexOf("|");
            String level = removeKey(tmp.substring(index + 1));
            tmp = tmp.substring(0, index);
            index = tmp.lastIndexOf("|");
            String value = removeKey(tmp.substring(index + 1));
            tmp = tmp.substring(0, index);
            index = tmp.indexOf("|");
            String key = removeKey(tmp.substring(index + 1));
            String name = removeKey(tmp.substring(0, index));
            cxt.put(name, "true", key, value, level);
        }
    } catch (IDFFMetaException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (AMConsoleException e) {
        throw new AMConsoleException(getErrorString(e));
    }
    return (cxt != null) ? cxt : new IDFFAuthContexts();
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) HashMap(java.util.HashMap) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) IDFFAuthContexts(com.sun.identity.console.federation.IDFFAuthContexts)

Example 18 with IDFFMetaManager

use of com.sun.identity.federation.meta.IDFFMetaManager in project OpenAM by OpenRock.

the class BulkFederation method getEntityRoleAndIdIDFF.

private void getEntityRoleAndIdIDFF() throws CLIException {
    try {
        IDFFMetaManager idffMgr = new IDFFMetaManager(ssoToken);
        String role = idffMgr.getProviderRoleByMetaAlias(metaAlias);
        if (role == null) {
            Object[] param = { metaAlias };
            throw new CLIException(MessageFormat.format(getResourceString("bulk-federation-unknown-metaalias"), param), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
        isIDP = role.equals(IFSConstants.IDP);
        localEntityId = idffMgr.getEntityIDByMetaAlias(metaAlias);
    } catch (IDFFMetaException e) {
        debugError("BulkFederation.getEntityRoleAndIdIDFF", e);
        Object[] param = { metaAlias };
        throw new CLIException(MessageFormat.format(getResourceString("bulk-federation-unknown-metaalias"), param), 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 19 with IDFFMetaManager

use of com.sun.identity.federation.meta.IDFFMetaManager in project OpenAM by OpenRock.

the class ExportMetaData method runIDFFExportMetaSign.

private void runIDFFExportMetaSign() throws CLIException {
    PrintWriter pw = null;
    String out = (isWebBase) ? "web" : metadata;
    Object[] objs = { out };
    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("export-entity-exception-entity-descriptor-not-exist"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
        SPDescriptorConfigElement spConfig = metaManager.getSPDescriptorConfig(realm, entityID);
        IDPDescriptorConfigElement idpConfig = metaManager.getIDPDescriptorConfig(realm, entityID);
        Document doc = null;
        /*
 * TODO: Signing
 * Document doc = SAML2MetaSecurityUtils.sign(
                descriptor, spConfig, idpConfig);
 */
        if (doc == null) {
            runIDFFExportMeta();
            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 (IDFFMetaException e) {
        debugError("ExportMetaData.runIDFFExportMetaSign", e);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (IOException e) {
        debugError("ExportMetaData.runIDFFExportMetaSign", e);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } finally {
        if (pw != null) {
            pw.close();
        }
    }
}
Also used : IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) FileWriter(java.io.FileWriter) SPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement) IOException(java.io.IOException) Document(org.w3c.dom.Document) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) CLIException(com.sun.identity.cli.CLIException) IDPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement) PrintWriter(java.io.PrintWriter)

Example 20 with IDFFMetaManager

use of com.sun.identity.federation.meta.IDFFMetaManager in project OpenAM by OpenRock.

the class CreateMetaDataModelImpl method createIDFFProvider.

/**
     * Creates a IDFF provider.
     *
     * @param realm Realm Name.
     * @param entityId Entity Id.
     * @param values   Map of property name to values.
     */
public void createIDFFProvider(String realm, String entityId, Map values) throws AMConsoleException {
    try {
        IDFFMetaManager metaManager = new IDFFMetaManager(null);
        String metadata = CreateIDFFMetaDataTemplate.createStandardMetaTemplate(entityId, values, requestURL);
        String extendedData = CreateIDFFMetaDataTemplate.createExtendedMetaTemplate(entityId, values);
        EntityDescriptorElement descriptor = (EntityDescriptorElement) IDFFMetaUtils.convertStringToJAXB(metadata);
        EntityConfigElement configElt = (EntityConfigElement) IDFFMetaUtils.convertStringToJAXB(extendedData);
        metaManager.createEntityDescriptor(realm, descriptor);
        metaManager.createEntityConfig(realm, configElt);
    } catch (JAXBException ex) {
        throw new AMConsoleException(ex.getMessage());
    } catch (IDFFMetaException ex) {
        throw new AMConsoleException(ex.getMessage());
    }
}
Also used : IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) JAXBException(javax.xml.bind.JAXBException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) EntityDescriptorElement(com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

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