Search in sources :

Example 11 with WSFederationMetaException

use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.

the class WSFedPropertiesModelImpl method getIdentityProviderAttributes.

/**
     * Returns a <code>Map</code> with identity provider attributes and values.
     *
     * @param realm to which the entity belongs.
     * @param fedId is the Federation Id otherwise known as the entity id.
     * @return attribute values of IDP based on realm and fedId passed.
     * @throws AMConsoleException if unable to retreive the Identity Provider
     *     attrubutes based on the realm and fedId passed.
     */
public Map getIdentityProviderAttributes(String realm, String fedId) throws AMConsoleException {
    Map IDPAttributes = null;
    try {
        WSFederationMetaManager metaManager = getWSFederationMetaManager();
        IDPSSOConfigElement idpconfig = metaManager.getIDPSSOConfig(realm, fedId);
        if (idpconfig != null) {
            IDPAttributes = WSFederationMetaUtils.getAttributes(idpconfig);
        }
    } catch (WSFederationMetaException e) {
        debug.warning("WSFedPropertiesModelImpl.getIdentityProviderAttributes", e);
        throw new AMConsoleException(e.getMessage());
    }
    return (IDPAttributes != null) ? IDPAttributes : Collections.EMPTY_MAP;
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) IDPSSOConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 12 with WSFederationMetaException

use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.

the class WSFedPropertiesModelImpl method setSPExtAttributeValues.

/**
     * Saves the extended metadata attribute values for the SP.
     *
     * @param realm to which the entity belongs.
     * @param fedId is the entity id.
     * @param spExtvalues has the extended attribute value pairs of SP.
     * @param location has the information whether remote or hosted.
     * @throws AMConsoleException if saving of attribute value fails.
     */
public void setSPExtAttributeValues(String realm, String fedId, Map spExtvalues, String location) throws AMConsoleException {
    try {
        String role = EntityModel.SERVICE_PROVIDER;
        //fed is the extended entity configuration object under the realm
        WSFederationMetaManager metaManager = getWSFederationMetaManager();
        FederationConfigElement fed = metaManager.getEntityConfig(realm, fedId);
        if (fed == null) {
            SPEX_DATA_MAP.put(TF_DISPNAME, Collections.EMPTY_SET);
            createExtendedObject(realm, fedId, location, SERVICE_PROVIDER, SPEX_DATA_MAP);
            fed = metaManager.getEntityConfig(realm, fedId);
        }
        SPSSOConfigElement spsso = getspsso(fed);
        if (spsso != null) {
            BaseConfigType baseConfig = (BaseConfigType) spsso;
            updateBaseConfig(baseConfig, spExtvalues, role);
        }
        //saves the attributes by passing the new fed object
        metaManager.setEntityConfig(realm, fed);
    } catch (JAXBException e) {
        debug.warning("WSFedPropertiesModelImpl.setSPExtAttributeValues", e);
        throw new AMConsoleException(e.getMessage());
    } catch (WSFederationMetaException e) {
        debug.warning("WSFedPropertiesModelImpl.setSPExtAttributeValues", e);
        throw new AMConsoleException(e.getMessage());
    }
}
Also used : BaseConfigType(com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) JAXBException(javax.xml.bind.JAXBException) SPSSOConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 13 with WSFederationMetaException

use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.

the class UpdateMetadataKeyInfo method handleWSFedRequest.

private void handleWSFedRequest(RequestContext rc) throws CLIException {
    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("update-meta-keyinfo-exception-entity-not-exist"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
        if (!isEmpty(spSigningAliases)) {
            if (NULL_ALIAS.equals(getFirstItem(spSigningAliases))) {
                WSFederationMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, null, false);
            } else {
                WSFederationMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, getFirstItem(spSigningAliases), false);
            }
        }
        if (!isEmpty(idpSigningAliases)) {
            if (NULL_ALIAS.equals(getFirstItem(idpSigningAliases))) {
                WSFederationMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, null, true);
            } else {
                WSFederationMetaSecurityUtils.updateProviderKeyInfo(realm, entityID, getFirstItem(idpSigningAliases), true);
            }
        }
        if (!isEmpty(spEncryptionAliases)) {
            Object[] objs2 = { entityID, realm };
            throw new CLIException(MessageFormat.format(getResourceString("update-meta-keyinfo-exception-invalid-option"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
        if (!isEmpty(idpEncryptionAliases)) {
            Object[] objs2 = { entityID, realm };
            throw new CLIException(MessageFormat.format(getResourceString("update-meta-keyinfo-exception-invalid-option"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
        Object[] objs = { entityID };
        getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("update-keyinfo-succeeded"), objs));
    } catch (WSFederationMetaException e) {
        WSFederationMetaUtils.debug.error("UpdateMetaKey.handleIDFFRequest", e);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) CLIException(com.sun.identity.cli.CLIException) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)

Example 14 with WSFederationMetaException

use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.

the class ExportMetaData method runWSFedExportMeta.

private void runWSFedExportMeta() throws CLIException {
    PrintWriter pw = null;
    String out = (isWebBase) ? "web" : metadata;
    Object[] objs = { out };
    Object[] objs2 = { entityID, realm };
    try {
        WSFederationMetaManager metaManager = new WSFederationMetaManager(ssoToken);
        FederationElement federation = metaManager.getEntityDescriptor(realm, entityID);
        if (federation == null) {
            throw new CLIException(MessageFormat.format(getResourceString("export-entity-exception-entity-descriptor-not-exist"), objs2), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
        String xmlstr = WSFederationMetaUtils.convertJAXBToString(federation);
        xmlstr = WSFederationMetaSecurityUtils.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 (WSFederationMetaException e) {
        debugError("ExportMetaData.runExportMeta", e);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (IOException e) {
        debugError("ExportMetaData.runExportMeta", e);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (JAXBException e) {
        debugWarning("ExportMetaData.runExportMeta", 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 : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) FileWriter(java.io.FileWriter) JAXBException(javax.xml.bind.JAXBException) CLIException(com.sun.identity.cli.CLIException) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) IOException(java.io.IOException) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement) PrintWriter(java.io.PrintWriter)

Example 15 with WSFederationMetaException

use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.

the class ConfigFedMonitoring method getWSFedEntities.

private Map getWSFedEntities(String realm) {
    String classMethod = "ConfigFedMonitoring.getWSFedEntities:";
    Set wsEnts = null;
    // wsentMap: entity name => Map of ("location", "roles") -> values
    Map wsentMap = new HashMap();
    try {
        WSFederationMetaManager metaManager = new WSFederationMetaManager();
        wsEnts = metaManager.getAllEntities(realm);
        List hosted = metaManager.getAllHostedEntities(realm);
        for (Iterator it = wsEnts.iterator(); it.hasNext(); ) {
            Map wse = new HashMap();
            String entId = (String) it.next();
            if ((hosted != null) && hosted.contains(entId)) {
                wse.put("location", "hosted");
            } else {
                wse.put("location", "remote");
            }
            wse.put("roles", listToString(getWSFedRoles(entId, realm)));
            wsentMap.put(entId, wse);
        }
    } catch (WSFederationMetaException e) {
        debug.error(classMethod + "getting WSFed entities for realm " + realm + ": " + e.getMessage());
    }
    return wsentMap;
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) Set(java.util.Set) HashMap(java.util.HashMap) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

WSFederationMetaException (com.sun.identity.wsfederation.meta.WSFederationMetaException)30 WSFederationMetaManager (com.sun.identity.wsfederation.meta.WSFederationMetaManager)20 List (java.util.List)13 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)11 FederationElement (com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)10 Iterator (java.util.Iterator)10 Map (java.util.Map)9 HashMap (java.util.HashMap)8 JAXBException (javax.xml.bind.JAXBException)8 CLIException (com.sun.identity.cli.CLIException)7 HashSet (java.util.HashSet)7 BaseConfigType (com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType)6 IDPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement)5 ArrayList (java.util.ArrayList)5 Set (java.util.Set)5 FederationConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)4 UriNamedClaimTypesOfferedElement (com.sun.identity.wsfederation.jaxb.wsfederation.UriNamedClaimTypesOfferedElement)4 WSFederationException (com.sun.identity.wsfederation.common.WSFederationException)3 TokenIssuerEndpointElement (com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerEndpointElement)3 IOException (java.io.IOException)3