Search in sources :

Example 1 with CircleOfTrustDescriptor

use of com.sun.identity.cot.CircleOfTrustDescriptor in project OpenAM by OpenRock.

the class FederationViewBean method populateCOTTable.

private void populateCOTTable() {
    tablePopulated = true;
    FSAuthDomainsModel model = (FSAuthDomainsModel) getModel();
    Set circleOfTrustDescriptors = model.getCircleOfTrustDescriptors();
    CCActionTableModel tableModel = (CCActionTableModel) propertySheetModel.getModel(COT_TABLE);
    tableModel.clearAll();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    if ((circleOfTrustDescriptors != null) && (!circleOfTrustDescriptors.isEmpty())) {
        List cache = new ArrayList(circleOfTrustDescriptors.size());
        boolean first = true;
        for (Iterator iter = circleOfTrustDescriptors.iterator(); iter.hasNext(); ) {
            if (first) {
                first = false;
            } else {
                tableModel.appendRow();
            }
            CircleOfTrustDescriptor desc = (CircleOfTrustDescriptor) iter.next();
            String name = desc.getCircleOfTrustName();
            tableModel.setValue(COT_NAME_VALUE, name);
            tableModel.setValue(COT_NAME_HREF, stringToHex(name));
            // get entity/provider name
            Set entitySet = desc.getTrustedProviders();
            if ((entitySet != null) && (!entitySet.isEmpty())) {
                Iterator it = entitySet.iterator();
                StringBuffer sb = new StringBuffer();
                Encoder encoder = ESAPI.encoder();
                while (it.hasNext()) {
                    String entity = (String) it.next();
                    sb.append(encoder.encodeForHTML(entity)).append("<br>");
                }
                tableModel.setValue(COT_ENTITY_VALUE, sb.toString());
            } else {
                tableModel.setValue(COT_ENTITY_VALUE, "");
            }
            // get realm name
            String realm = desc.getCircleOfTrustRealm();
            tableModel.setValue(COT_REALM_VALUE, realm);
            // get cot status
            String status = desc.getCircleOfTrustStatus();
            if ((status != null) && status.equals("active")) {
                tableModel.setValue(COT_STATUS_VALUE, "label.active");
            } else {
                tableModel.setValue(COT_STATUS_VALUE, "label.inactive");
            }
            cache.add(name + "," + realm);
        }
        szCache.setValue((ArrayList) cache);
    } else {
        szCache.setValue(null);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CCActionTableModel(com.sun.web.ui.model.CCActionTableModel) SerializedField(com.sun.identity.console.components.view.html.SerializedField) Encoder(org.owasp.esapi.Encoder) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) FSAuthDomainsModel(com.sun.identity.console.federation.model.FSAuthDomainsModel) ArrayList(java.util.ArrayList) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor)

Example 2 with CircleOfTrustDescriptor

use of com.sun.identity.cot.CircleOfTrustDescriptor in project OpenAM by OpenRock.

the class FSAuthDomainsModelImpl method addProviders.

/**
     * Adds providers.
     * @param realm realm of circle of trust
     * @param cotName Name of circle of trust
     * @param names Names provider to be added.
     * @throws AMConsoleException if provider cannot be added.
     */
public void addProviders(String realm, String cotName, Collection names) throws AMConsoleException {
    String cotType = COTConstants.SAML2;
    String entityId = null;
    String providerNames = AMAdminUtils.getString(names, ",", false);
    String[] params = { realm, cotName, providerNames };
    logEvent("ATTEMPT_ADD_PROVIDERS_TO_AUTH_DOMAIN", params);
    try {
        CircleOfTrustManager manager = getCircleOfTrustManager();
        CircleOfTrustDescriptor cotDescriptor = manager.getCircleOfTrust(realm, cotName);
        Set existingEntity = cotDescriptor.getTrustedProviders();
        if (existingEntity != null) {
            Iterator it = existingEntity.iterator();
            while (it.hasNext()) {
                String entityString = (String) it.next();
                String delims = "|";
                StringTokenizer tokens = new StringTokenizer(entityString, delims);
                if (tokens.countTokens() == 2) {
                    entityId = tokens.nextToken();
                    cotType = tokens.nextToken();
                    manager.removeCircleOfTrustMember(realm, cotName, cotType, entityId);
                }
            }
        }
        if (names != null) {
            int sz = names.size();
            for (int i = 0; i < sz; i++) {
                String entityString = (String) ((ArrayList) names).get(i);
                String delims = "|";
                StringTokenizer tokens = new StringTokenizer(entityString, delims);
                if (tokens.countTokens() == 2) {
                    entityId = tokens.nextToken();
                    cotType = tokens.nextToken();
                    manager.addCircleOfTrustMember(realm, cotName, cotType, entityId);
                }
            }
        }
        logEvent("SUCCEED_ADD_PROVIDERS_TO_AUTH_DOMAIN", params);
    } catch (COTException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, cotName, providerNames, strError };
        logEvent("FEDERATION_EXCEPTION_ADD_PROVIDERS_TO_AUTH_DOMAIN", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 3 with CircleOfTrustDescriptor

use of com.sun.identity.cot.CircleOfTrustDescriptor in project OpenAM by OpenRock.

the class FSAuthDomainsModelImpl method getTrustedProviderNames.

/**
     * Returns a set of provider names under a authentication domain.
     *
     * @param name Name of authentication domain.
     * @return a set of provider names under a authentication domain.
     * @throws AMConsoleException if provider names cannot be obtained.
     */
public Set getTrustedProviderNames(String realm, String name) throws AMConsoleException {
    Set providers = null;
    try {
        String[] param = { realm, name };
        logEvent("ATTEMPT_GET_PROVIDER_NAMES_UNDER_AUTH_DOMAIN", param);
        CircleOfTrustManager manager = getCircleOfTrustManager();
        CircleOfTrustDescriptor desc = manager.getCircleOfTrust(realm, name);
        providers = desc.getTrustedProviders();
        logEvent("SUCCEED_GET_PROVIDER_NAMES_UNDER_AUTH_DOMAIN", param);
    } catch (COTException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, name, strError };
        logEvent("FEDERATION_EXCEPTION_GET_PROVIDER_NAMES_UNDER_AUTH_DOMAIN", paramsEx);
        throw new AMConsoleException(strError);
    }
    return (providers != null) ? providers : Collections.EMPTY_SET;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 4 with CircleOfTrustDescriptor

use of com.sun.identity.cot.CircleOfTrustDescriptor in project OpenAM by OpenRock.

the class FSAuthDomainsModelImpl method setAttributeValues.

/**
     * Set attribute values.
     *
     * @param name Name of authentication domain.
     * @param values Map of attribute name to value.
     * @throws IDFFMetaException if attribute values cannot be set.
     */
public void setAttributeValues(String realm, String name, Map values) throws AMConsoleException {
    String[] param = { realm, name };
    logEvent("ATTEMPT_MODIFY_AUTH_DOMAIN", param);
    try {
        CircleOfTrustManager manager = getCircleOfTrustManager();
        CircleOfTrustDescriptor desc = manager.getCircleOfTrust(realm, name);
        desc.setCircleOfTrustDescription((String) AMAdminUtils.getValue((Set) values.get(TF_DESCRIPTION)));
        desc.setIDFFWriterServiceURL((String) AMAdminUtils.getValue((Set) values.get(TF_IDFF_WRITER_SERVICE_URL)));
        desc.setIDFFReaderServiceURL((String) AMAdminUtils.getValue((Set) values.get(TF_IDFF_READER_SERVICE_URL)));
        desc.setSAML2WriterServiceURL((String) AMAdminUtils.getValue((Set) values.get(TF_SAML2_WRITER_SERVICE_URL)));
        desc.setSAML2ReaderServiceURL((String) AMAdminUtils.getValue((Set) values.get(TF_SAML2_READER_SERVICE_URL)));
        desc.setCircleOfTrustStatus((String) AMAdminUtils.getValue((Set) values.get(SINGLE_CHOICE_STATUS)));
        manager.modifyCircleOfTrust(realm, desc);
        logEvent("SUCCEED_MODIFY_AUTH_DOMAIN", param);
    } catch (COTException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, name, strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_AUTH_DOMAIN", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 5 with CircleOfTrustDescriptor

use of com.sun.identity.cot.CircleOfTrustDescriptor in project OpenAM by OpenRock.

the class CreateCircleOfTrust method handleRequest.

/**
     * Creates a circle of trust.
     *
     * @param rc Request Context.
     * @throws CLIException if unable to process this request.
     */
@Override
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    realm = getStringOptionValue(FedCLIConstants.ARGUMENT_REALM, "/");
    cot = getStringOptionValue(FedCLIConstants.ARGUMENT_COT);
    prefix = getStringOptionValue(FedCLIConstants.ARGUMENT_PREFIX);
    trustedProviders = (List) rc.getOption(FedCLIConstants.ARGUMENT_TRUSTED_PROVIDERS);
    Set providers = new HashSet();
    if (trustedProviders != null) {
        providers.addAll(trustedProviders);
    }
    String[] params = { realm, cot, providers.toString(), prefix };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_CREATE_COT", params);
    try {
        CircleOfTrustDescriptor descriptor = ((prefix == null) || (prefix.trim().length() == 0)) ? new CircleOfTrustDescriptor(cot, realm, COTConstants.ACTIVE, "", null, null, null, null, providers) : new CircleOfTrustDescriptor(cot, realm, COTConstants.ACTIVE, "", prefix + "/idffreader", prefix + "/idffwriter", prefix + "/saml2reader", prefix + "/saml2writer", providers);
        CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
        cotManager.createCircleOfTrust(realm, descriptor);
        Object[] objs = { cot, realm };
        getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("create-circle-of-trust-succeeded"), objs));
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_CREATE_COT", params);
    } catch (COTException e) {
        debug.warning("CreateCircleOfTrust.handleRequest", e);
        String[] args = { realm, cot, providers.toString(), prefix, e.getMessage() };
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_COT", args);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) CLIException(com.sun.identity.cli.CLIException) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) HashSet(java.util.HashSet)

Aggregations

CircleOfTrustDescriptor (com.sun.identity.cot.CircleOfTrustDescriptor)20 CircleOfTrustManager (com.sun.identity.cot.CircleOfTrustManager)16 COTException (com.sun.identity.cot.COTException)15 HashSet (java.util.HashSet)9 Set (java.util.Set)9 ArrayList (java.util.ArrayList)7 Iterator (java.util.Iterator)7 List (java.util.List)7 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)4 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)4 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)3 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)3 CLIRequest (com.sun.identity.cli.CLIRequest)2 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)2 SessionException (com.sun.identity.plugin.session.SessionException)2 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)2 IOException (java.io.IOException)2