Search in sources :

Example 71 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.

the class TaskModelImpl method getConfigureGoogleAppsURLs.

public Map getConfigureGoogleAppsURLs(String realm, String entityId) throws AMConsoleException {
    Map map = new HashMap();
    IDPSSODescriptorElement idpssoDescriptor = null;
    try {
        SAML2MetaManager samlManager = new SAML2MetaManager();
        idpssoDescriptor = samlManager.getIDPSSODescriptor(realm, entityId);
        String signinPageURL = null;
        if (idpssoDescriptor != null) {
            List signonList = idpssoDescriptor.getSingleSignOnService();
            for (int i = 0; i < signonList.size(); i++) {
                SingleSignOnServiceElement signElem = (SingleSignOnServiceElement) signonList.get(i);
                String tmp = signElem.getBinding();
                if (tmp.contains("HTTP-Redirect")) {
                    signinPageURL = signElem.getLocation();
                    map.put("SigninPageURL", returnEmptySetIfValueIsNull(signinPageURL));
                }
            }
        }
        URL aURL = new URL(signinPageURL);
        String signoutPageURL = null;
        String protocol = aURL.getProtocol();
        String host = aURL.getHost();
        int port = aURL.getPort();
        if (port == -1) {
            port = (aURL.getProtocol().equals("https")) ? 443 : 80;
        }
        String deploymentURI = SystemPropertiesManager.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR);
        String url = protocol + "://" + host + ":" + port + deploymentURI;
        signoutPageURL = url + "/UI/Logout?goto=" + url;
        map.put("SignoutPageURL", returnEmptySetIfValueIsNull(signoutPageURL));
        map.put("ChangePasswordURL", returnEmptySetIfValueIsNull(url + "/idm/EndUser"));
        // get pubkey                 
        Map extValueMap = new HashMap();
        IDPSSOConfigElement idpssoConfig = samlManager.getIDPSSOConfig(realm, entityId);
        if (idpssoConfig != null) {
            BaseConfigType baseConfig = (BaseConfigType) idpssoConfig;
            extValueMap = SAML2MetaUtils.getAttributes(baseConfig);
        }
        List aList = (List) extValueMap.get("signingCertAlias");
        String signingCertAlias = null;
        if (aList != null) {
            signingCertAlias = (String) aList.get(0);
        }
        String publickey = SAML2MetaSecurityUtils.buildX509Certificate(signingCertAlias);
        String str = "-----BEGIN CERTIFICATE-----\n" + publickey + "-----END CERTIFICATE-----\n";
        map.put("PubKey", returnEmptySetIfValueIsNull(str));
    } catch (SAML2MetaException ex) {
        throw new AMConsoleException(ex.getMessage());
    } catch (MalformedURLException ex) {
        throw new AMConsoleException(ex.getMessage());
    }
    return map;
}
Also used : MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) SingleSignOnServiceElement(com.sun.identity.saml2.jaxb.metadata.SingleSignOnServiceElement) URL(java.net.URL) BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) IDPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)

Example 72 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.

the class TaskModelImpl method getConfigureSalesForceAppsURLs.

public Map getConfigureSalesForceAppsURLs(String realm, String entityId, String attrMapping) throws AMConsoleException {
    Map map = new HashMap();
    String attributeNames = getAttributeNames(attrMapping);
    IDPSSODescriptorElement idpssoDescriptor = null;
    try {
        SAML2MetaManager samlManager = new SAML2MetaManager();
        idpssoDescriptor = samlManager.getIDPSSODescriptor(realm, entityId);
        String signinPageURL = null;
        // get pubkey
        Map extValueMap = new HashMap();
        IDPSSOConfigElement idpssoConfig = samlManager.getIDPSSOConfig(realm, entityId);
        if (idpssoConfig != null) {
            BaseConfigType baseConfig = (BaseConfigType) idpssoConfig;
            extValueMap = SAML2MetaUtils.getAttributes(baseConfig);
        }
        List aList = (List) extValueMap.get("signingCertAlias");
        String signingCertAlias = null;
        if (aList != null) {
            signingCertAlias = (String) aList.get(0);
        }
        String publickey = SAML2MetaSecurityUtils.buildX509Certificate(signingCertAlias);
        String str = "-----BEGIN CERTIFICATE-----\n" + publickey + "\n-----END CERTIFICATE-----\n";
        map.put("PubKey", returnEmptySetIfValueIsNull(str));
        map.put("IssuerID", returnEmptySetIfValueIsNull(entityId));
        map.put("AttributeName", returnEmptySetIfValueIsNull(attributeNames));
    } catch (SAML2MetaException ex) {
        throw new AMConsoleException(ex.getMessage());
    }
    return map;
}
Also used : BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) HashMap(java.util.HashMap) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) List(java.util.List) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) IDPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)

Example 73 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.

the class CreateHostedIDPViewBean method beginDisplay.

public void beginDisplay(DisplayEvent e) {
    String value = (String) getDisplayFieldValue(HAS_META_DATA);
    if ((value == null) || value.equals("")) {
        setDisplayFieldValue(HAS_META_DATA, "no");
    }
    value = (String) getDisplayFieldValue(SELECT_COT);
    if ((value == null) || value.equals("")) {
        setDisplayFieldValue(SELECT_COT, "no");
    }
    value = (String) getDisplayFieldValue(RADIO_EXTENDED);
    if ((value == null) || value.equals("")) {
        setDisplayFieldValue(RADIO_EXTENDED, "file");
    }
    value = (String) getDisplayFieldValue(RADIO_META);
    if ((value == null) || value.equals("")) {
        setDisplayFieldValue(RADIO_META, "file");
    }
    setDisplayFieldValue(ENTITY_ID, (AMSystemConfig.isConsoleRemote) ? SystemProperties.getServerInstanceName() : getRequestURL());
    populateTableModel();
    Set userAttrNames = AMAdminUtils.getUserAttributeNames();
    userAttrNames.remove("iplanet-am-user-account-life");
    CCDropDownMenu menuUserAttribute = (CCDropDownMenu) getChild("menuUserAttributes");
    OptionList optList = createOptionList(userAttrNames);
    optList.add(0, "name.attribute.mapping.select", "");
    menuUserAttribute.setOptions(optList);
    try {
        TaskModel model = (TaskModel) getModel();
        Set realms = model.getRealms();
        CCDropDownMenu menuRealm = (CCDropDownMenu) getChild(REALM);
        menuRealm.setOptions(createOptionList(realms));
        String realm = getRequestContext().getRequest().getParameter("realm");
        if (realm != null && !realm.trim().isEmpty()) {
            setDisplayFieldValue(REALM, realm);
        }
        Set keys = model.getSigningKeys();
        OptionList optionList = createOptionList(keys);
        optionList.add(0, model.getLocalizedString("configure.provider.keys.none"), "");
        CCDropDownMenu menuSignKeys = (CCDropDownMenu) getChild(SIGN_KEY);
        menuSignKeys.setOptions(optionList);
    } catch (AMConsoleException ex) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", ex.getMessage());
    }
}
Also used : Set(java.util.Set) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) CCDropDownMenu(com.sun.web.ui.view.html.CCDropDownMenu) OptionList(com.iplanet.jato.view.html.OptionList) TaskModel(com.sun.identity.console.task.model.TaskModel)

Example 74 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.

the class ConfigureSocialAuthNViewBean method beginDisplay.

@Override
public void beginDisplay(DisplayEvent event) throws ModelControlException {
    HttpServletRequest req = getRequestContext().getRequest();
    try {
        super.beginDisplay(event);
        SocialAuthNModel model = (SocialAuthNModel) getModel();
        // If provider is known then use the simplified property sheet
        if (model.isKnownProvider()) {
            propertySheetModel.setDocument(openPropertySheetXml(KNOWN_PROVIDER_PROPERTIES));
            final String titleMessage = model.getLocalizedString(TITLE_MESSAGE);
            ptModel.setPageTitleText(MessageFormat.format(titleMessage, model.getProviderDisplayName()));
            ptModel.setPageTitleHelpMessage(model.getLocalizedProviderHelpMessage());
        }
        SortedSet<String> realms = model.getRealms();
        CCDropDownMenu menuRealm = (CCDropDownMenu) getChild(REALM_FIELD);
        menuRealm.setOptions(createOptionList(realms));
        String realm = req.getParameter("realm");
        if (realm != null && !realm.trim().isEmpty()) {
            setDisplayFieldValue(REALM_FIELD, realm);
        }
        setDisplayFieldValue(REDIRECT_URL_FIELD, model.getDefaultRedirectUrl());
        String provider = req.getParameter("type");
        if (provider != null && !provider.trim().isEmpty()) {
            setPageSessionAttribute(PROVIDER_ATTR, provider.trim());
        }
    } catch (AMConsoleException ex) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", ex.getMessage());
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SocialAuthNModel(com.sun.identity.console.task.model.SocialAuthNModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) CCDropDownMenu(com.sun.web.ui.view.html.CCDropDownMenu)

Example 75 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.

the class CreateSoapSTSDeploymentViewBean method beginDisplay.

public void beginDisplay(DisplayEvent e) {
    try {
        TaskModel model = (TaskModel) getModel();
        Set realms = model.getRealms();
        CCDropDownMenu menuRealm = (CCDropDownMenu) getChild(REALM);
        menuRealm.setOptions(createOptionList(realms));
        String realm = getRequestContext().getRequest().getParameter("realm");
        if (realm != null && !realm.trim().isEmpty()) {
            setDisplayFieldValue(REALM, realm);
        }
    } catch (AMConsoleException ex) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", ex.getMessage());
    }
}
Also used : Set(java.util.Set) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) CCDropDownMenu(com.sun.web.ui.view.html.CCDropDownMenu) TaskModel(com.sun.identity.console.task.model.TaskModel)

Aggregations

AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)701 Map (java.util.Map)255 Set (java.util.Set)206 HashMap (java.util.HashMap)193 HashSet (java.util.HashSet)148 SSOException (com.iplanet.sso.SSOException)126 Iterator (java.util.Iterator)122 List (java.util.List)97 SMSException (com.sun.identity.sm.SMSException)83 ArrayList (java.util.ArrayList)78 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)76 IdRepoException (com.sun.identity.idm.IdRepoException)58 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)47 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)46 AMIdentity (com.sun.identity.idm.AMIdentity)44 SAMLv2Model (com.sun.identity.console.federation.model.SAMLv2Model)41 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)41 CCActionTable (com.sun.web.ui.view.table.CCActionTable)40 TreeSet (java.util.TreeSet)39 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)38