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;
}
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;
}
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());
}
}
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());
}
}
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());
}
}
Aggregations