Search in sources :

Example 26 with WSFederationMetaException

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

the class WSFedPropertiesModelImpl method setIDPSTDAttributeValues.

/**
     * Saves the standard attribute values for the IDP.
     *
     * @param entityName is entityid.
     * @param idpStdValues contain standard attribute values of idp.
     * @param realm to which the entity belongs.
     * @param idpExtValues contain extended attribute values.
     * @param location the information whether remote or hosted.
     * @throws AMConsoleException if saving of attribute value fails.
     */
public void setIDPSTDAttributeValues(String entityName, Map idpStdValues, String realm, Map idpExtValues, String location) throws AMConsoleException {
    FederationElement fedElem = getEntityDesc(realm, entityName);
    List claimList = null;
    ClaimType claimType = null;
    DisplayNameType displayName = null;
    String value = null;
    UriNamedClaimTypesOfferedElement UriNamedclaimTypes = null;
    try {
        UriNamedclaimTypes = getWSFederationMetaManager().getUriNamedClaimTypesOffered(fedElem);
    } catch (WSFederationMetaException we) {
        UriNamedclaimTypes = null;
    }
    if (UriNamedclaimTypes != null) {
        int iClaim = 0;
        claimList = UriNamedclaimTypes.getClaimType();
        for (iClaim = 0; iClaim < claimList.size(); iClaim += 1) {
            claimType = (ClaimType) claimList.get(iClaim);
            displayName = claimType.getDisplayName();
        }
    }
    HashSet set = (HashSet) idpStdValues.get(WSFedPropertiesModel.TFCLAIM_TYPES);
    Iterator i = set.iterator();
    while ((i != null) && (i.hasNext())) {
        value = (String) i.next();
    }
    if ((value.toString()).equals(WSFederationConstants.NAMED_CLAIM_DISPLAY_NAMES[WSFederationConstants.NAMED_CLAIM_COMMONNAME])) {
        displayName.setValue(WSFederationConstants.NAMED_CLAIM_DISPLAY_NAMES[WSFederationConstants.NAMED_CLAIM_COMMONNAME]);
        claimType.setUri(WSFederationConstants.NAMED_CLAIM_TYPES[WSFederationConstants.NAMED_CLAIM_COMMONNAME]);
    } else if (value.toString().equals(WSFederationConstants.NAMED_CLAIM_DISPLAY_NAMES[WSFederationConstants.NAMED_CLAIM_EMAILADDRESS])) {
        displayName.setValue(WSFederationConstants.NAMED_CLAIM_DISPLAY_NAMES[WSFederationConstants.NAMED_CLAIM_EMAILADDRESS]);
        claimType.setUri(WSFederationConstants.NAMED_CLAIM_TYPES[WSFederationConstants.NAMED_CLAIM_EMAILADDRESS]);
    } else if (value.toString().equals(WSFederationConstants.NAMED_CLAIM_DISPLAY_NAMES[WSFederationConstants.NAMED_CLAIM_UPN])) {
        displayName.setValue(WSFederationConstants.NAMED_CLAIM_DISPLAY_NAMES[WSFederationConstants.NAMED_CLAIM_UPN]);
        claimType.setUri(WSFederationConstants.NAMED_CLAIM_TYPES[WSFederationConstants.NAMED_CLAIM_UPN]);
    }
    try {
        if (location.equals("hosted")) {
            String idp_certalias = getResult(idpExtValues, TFSIGNCERT_ALIAS);
            WSFederationMetaSecurityUtils.updateProviderKeyInfo(realm, entityName, idp_certalias, true);
        }
        getWSFederationMetaManager().setFederation(realm, fedElem);
    } catch (WSFederationMetaException e) {
        debug.warning("WSFedPropertiesModelImpl.setIDPSTDAttributeValues", e);
        throw new AMConsoleException(e.getMessage());
    }
}
Also used : UriNamedClaimTypesOfferedElement(com.sun.identity.wsfederation.jaxb.wsfederation.UriNamedClaimTypesOfferedElement) Iterator(java.util.Iterator) List(java.util.List) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) DisplayNameType(com.sun.identity.wsfederation.jaxb.wsfederation.DisplayNameType) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement) ClaimType(com.sun.identity.wsfederation.jaxb.wsfederation.ClaimType) HashSet(java.util.HashSet)

Example 27 with WSFederationMetaException

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

the class WSFedPropertiesModelImpl method createExtendedObject.

/**
     * Creates the extended config object when it does not exist.
     * @param realm to which the entity belongs.
     * @param fedId is the entity id.
     * @param location is either hosted or remote
     * @param role is SP, IDP or SP/IDP.
     * @param keys which contain all extended attribute keys.
     * @throws WSFederationMetaException, JAXBException,
     *     AMConsoleException if saving of attribute value fails.
     */
private void createExtendedObject(String realm, String fedId, String location, String role, Map keys) throws WSFederationMetaException, JAXBException, AMConsoleException {
    try {
        ObjectFactory objFactory = new ObjectFactory();
        WSFederationMetaManager metaManager = getWSFederationMetaManager();
        FederationElement edes = metaManager.getEntityDescriptor(realm, fedId);
        if (edes == null) {
            if (debug.warningEnabled()) {
                debug.warning("WSFedPropertiesModelImpl.createExtendedObject: " + "No such entity: " + fedId);
            }
            String[] data = { realm, fedId };
            throw new WSFederationMetaException("fedId_invalid", data);
        }
        FederationConfigElement eConfig = metaManager.getEntityConfig(realm, fedId);
        if (eConfig == null) {
            BaseConfigType bctype = null;
            FederationConfigElement ele = objFactory.createFederationConfigElement();
            ele.setFederationID(fedId);
            if (location.equals("remote")) {
                ele.setHosted(false);
            }
            List ll = ele.getIDPSSOConfigOrSPSSOConfig();
            // Right now, it is either an SP or an IdP or dual role
            if (isDualRole(edes)) {
                //for dual role create both idp and sp config objects
                BaseConfigType bctype_idp = null;
                BaseConfigType bctype_sp = null;
                bctype_idp = objFactory.createIDPSSOConfigElement();
                bctype_idp = createAttributeElement(keys, bctype_idp);
                bctype_sp = objFactory.createSPSSOConfigElement();
                bctype_sp = createAttributeElement(keys, bctype_sp);
                ll.add(bctype_idp);
                ll.add(bctype_sp);
            } else if (role.equals(IDENTITY_PROVIDER)) {
                bctype = objFactory.createIDPSSOConfigElement();
                //bctype.getAttribute().add(atype);
                bctype = createAttributeElement(keys, bctype);
                ll.add(bctype);
            } else if (role.equals(SERVICE_PROVIDER)) {
                bctype = objFactory.createSPSSOConfigElement();
                bctype = createAttributeElement(keys, bctype);
                ll.add(bctype);
            }
            metaManager.setEntityConfig(realm, ele);
        }
    } catch (JAXBException e) {
        debug.warning("WSFedPropertiesModelImpl.createExtendedObject", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (WSFederationMetaException e) {
        debug.warning("WSFedPropertiesModelImpl.createExtendedObject", e);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : BaseConfigType(com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) ObjectFactory(com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory) JAXBException(javax.xml.bind.JAXBException) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) List(java.util.List) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)

Example 28 with WSFederationMetaException

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

the class WSFedPropertiesModelImpl method getClaimType.

/**
     * Returns display name of claim type.
     *
     * @param fedElem is the FederationElement Object.
     * @return display name of claim type.
     */
public String getClaimType(FederationElement fedElem) {
    List claimList = null;
    String displayName = null;
    UriNamedClaimTypesOfferedElement UriNamedclaimTypes = null;
    try {
        UriNamedclaimTypes = getWSFederationMetaManager().getUriNamedClaimTypesOffered(fedElem);
    } catch (WSFederationMetaException we) {
        UriNamedclaimTypes = null;
    }
    //assuming there is only 1 claim type object now
    if (UriNamedclaimTypes != null) {
        int iClaim = 0;
        int arr = 0;
        claimList = UriNamedclaimTypes.getClaimType();
        for (iClaim = 0; iClaim < claimList.size(); iClaim += 1) {
            ClaimType claimType = (ClaimType) claimList.get(iClaim);
            displayName = claimType.getDisplayName().getValue();
        }
    }
    return displayName;
}
Also used : UriNamedClaimTypesOfferedElement(com.sun.identity.wsfederation.jaxb.wsfederation.UriNamedClaimTypesOfferedElement) List(java.util.List) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) ClaimType(com.sun.identity.wsfederation.jaxb.wsfederation.ClaimType)

Example 29 with WSFederationMetaException

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

the class WSFedPropertiesModelImpl method getServiceProviderAttributes.

/**
     * Returns a map with service 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 SP based on realm and fedId passed.
     * @throws AMConsoleException if unable to retreive the Service Provider
     *     attrubutes based on the realm and fedId passed.
     */
public Map getServiceProviderAttributes(String realm, String fedId) throws AMConsoleException {
    Map SPAttributes = null;
    try {
        WSFederationMetaManager metaManager = getWSFederationMetaManager();
        SPSSOConfigElement spconfig = metaManager.getSPSSOConfig(realm, fedId);
        if (spconfig != null) {
            SPAttributes = WSFederationMetaUtils.getAttributes(spconfig);
        }
    } catch (WSFederationMetaException e) {
        debug.warning("WSFedPropertiesModelImpl.getServiceProviderAttributes", e);
        throw new AMConsoleException(getErrorString(e));
    }
    return (SPAttributes != null) ? SPAttributes : Collections.EMPTY_MAP;
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) SPSSOConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 30 with WSFederationMetaException

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

the class FSAuthDomainsModelImpl method getAllProviderNames.

/**
     * Returns a &lt;code>Set&lt;/code> of provider names that exist in the
     * specified realm.
     *
     * @param realm name of the realm to search.
     * @return a set of provider names.
     * @throws AMConsoleException if provider names cannot be obtained.
     */
public Set getAllProviderNames(String realm) throws AMConsoleException {
    String[] params = { realm };
    logEvent("ATTEMPT_GET_ALL_PROVIDER_NAMES", params);
    Set availableEntities = new HashSet();
    try {
        SAML2MetaManager saml2Mgr = new SAML2MetaManager();
        Set saml2Entities = saml2Mgr.getAllEntities(realm);
        Iterator it = saml2Entities.iterator();
        while (it.hasNext()) {
            String entityId = (String) it.next();
            availableEntities.add(entityId + "|saml2");
        }
    } catch (SAML2MetaException e) {
        String strError = getErrorString(e);
        throw new AMConsoleException(strError);
    }
    try {
        Set wsfedEntities = (new WSFederationMetaManager()).getAllEntities(realm);
        for (Iterator i = wsfedEntities.iterator(); i.hasNext(); ) {
            String tmp = (String) i.next();
            availableEntities.add(tmp + "|wsfed");
        }
    } catch (WSFederationMetaException e) {
        debug.warning("EntityModel.getWSFedEntities", e);
        throw new AMConsoleException(e.getMessage());
    }
    try {
        IDFFMetaManager idffManager = new IDFFMetaManager(null);
        Set entities = idffManager.getAllEntities(realm);
        for (Iterator i = entities.iterator(); i.hasNext(); ) {
            String tmp = (String) i.next();
            availableEntities.add(tmp + "|idff");
        }
    } catch (IDFFMetaException e) {
        debug.warning("FSAuthDomainModel.getAllProviderNames", e);
        throw new AMConsoleException(e.getMessage());
    }
    logEvent("SUCCEED_GET_ALL_PROVIDER_NAMES", params);
    return (availableEntities != null) ? availableEntities : Collections.EMPTY_SET;
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) Set(java.util.Set) HashSet(java.util.HashSet) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) Iterator(java.util.Iterator) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) HashSet(java.util.HashSet)

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