use of com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType in project OpenAM by OpenRock.
the class FSLoginHelper method getIDPs.
private Set getIDPs(String metaAlias) {
Set idpSet = new HashSet();
try {
String provider = "";
String providerStatus = "";
String role = IFSConstants.IDP.toLowerCase();
IDPDescriptorType providerDesc = null;
BaseConfigType providerConfig = null;
Set trustedProviders = metaManager.getAllTrustedProviders(metaAlias);
if (trustedProviders != null && !trustedProviders.isEmpty()) {
Iterator it = trustedProviders.iterator();
while (it.hasNext()) {
provider = (String) it.next();
providerDesc = metaManager.getIDPDescriptor(realm, provider);
providerConfig = metaManager.getIDPDescriptorConfig(realm, provider);
if (providerDesc == null || providerConfig == null) {
continue;
}
providerStatus = IDFFMetaUtils.getFirstAttributeValueFromConfig(providerConfig, IFSConstants.PROVIDER_STATUS);
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSLoginHelper::getIDPs For " + "providerId " + provider + " status is " + providerStatus);
}
if (providerStatus == null || providerStatus.length() == 0 || (providerStatus != null && providerStatus.equalsIgnoreCase(IFSConstants.ACTIVE))) {
idpSet.add(provider);
}
}
}
} catch (IDFFMetaException ame) {
FSUtils.debug.error("FSLoginHelper::getIDPs Error in getting idp List:", ame);
}
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSLoginHelper::getIDPs returing idpset as " + idpSet);
}
return idpSet;
}
use of com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType in project OpenAM by OpenRock.
the class IDFFMetaSecurityUtils method updateProviderKeyInfo.
/**
* Updates signing or encryption key info for SP or IDP.
* This will update both signing/encryption alias on extended metadata and
* certificates in standard metadata.
* @param realm Realm the entity resides.
* @param entityID ID of the entity to be updated.
* @param certAlias Alias of the certificate to be set to the entity. If
* null, will remove existing key information from the SP or IDP.
* @param isSigning true if this is signing certificate alias, false if
* this is encryption certification alias.
* @param isIDP true if this is for IDP signing/encryption alias, false
* if this is for SP signing/encryption alias
* @param encAlgo Encryption algorithm URI, this is applicable for
* encryption cert only.
* @param keySize Encryption key size, this is applicable for
* encryption cert only.
* @throws IDFFMetaException if failed to update the certificate alias for
* the entity.
*/
public static void updateProviderKeyInfo(String realm, String entityID, String certAlias, boolean isSigning, boolean isIDP, String encAlgo, int keySize) throws IDFFMetaException {
IDFFMetaManager metaManager = FSUtils.getIDFFMetaManager();
EntityConfigElement config = metaManager.getEntityConfig(realm, entityID);
if (!config.isHosted()) {
String[] args = { entityID, realm };
throw new IDFFMetaException("entityNotHosted", args);
}
EntityDescriptorElement desp = metaManager.getEntityDescriptor(realm, entityID);
if (isIDP) {
IDPDescriptorConfigElement idpConfig = IDFFMetaUtils.getIDPDescriptorConfig(config);
IDPDescriptorType idpDesp = IDFFMetaUtils.getIDPDescriptor(desp);
if ((idpConfig == null) || (idpDesp == null)) {
String[] args = { entityID, realm };
throw new IDFFMetaException("entityNotIDP", args);
}
// update standard metadata
if ((certAlias == null) || (certAlias.length() == 0)) {
// remove key info
removeKeyDescriptor(idpDesp, isSigning);
if (isSigning) {
setExtendedAttributeValue(idpConfig, IFSConstants.SIGNING_CERT_ALIAS, null);
} else {
setExtendedAttributeValue(idpConfig, IFSConstants.ENCRYPTION_CERT_ALIAS, null);
}
} else {
KeyDescriptorElement kde = getKeyDescriptor(certAlias, isSigning, encAlgo, keySize);
updateKeyDescriptor(idpDesp, kde);
// update extended metadata
Set value = new HashSet();
value.add(certAlias);
if (isSigning) {
setExtendedAttributeValue(idpConfig, IFSConstants.SIGNING_CERT_ALIAS, value);
} else {
setExtendedAttributeValue(idpConfig, IFSConstants.ENCRYPTION_CERT_ALIAS, value);
}
}
metaManager.setEntityDescriptor(realm, desp);
metaManager.setEntityConfig(realm, config);
} else {
SPDescriptorConfigElement spConfig = IDFFMetaUtils.getSPDescriptorConfig(config);
SPDescriptorType spDesp = IDFFMetaUtils.getSPDescriptor(desp);
if ((spConfig == null) || (spDesp == null)) {
String[] args = { entityID, realm };
throw new IDFFMetaException("entityNotSP", args);
}
// update standard metadata
if ((certAlias == null) || (certAlias.length() == 0)) {
// remove key info
removeKeyDescriptor(spDesp, isSigning);
if (isSigning) {
setExtendedAttributeValue(spConfig, IFSConstants.SIGNING_CERT_ALIAS, null);
} else {
setExtendedAttributeValue(spConfig, IFSConstants.ENCRYPTION_CERT_ALIAS, null);
}
} else {
KeyDescriptorElement kde = getKeyDescriptor(certAlias, isSigning, encAlgo, keySize);
updateKeyDescriptor(spDesp, kde);
// update extended metadata
Set value = new HashSet();
value.add(certAlias);
if (isSigning) {
setExtendedAttributeValue(spConfig, IFSConstants.SIGNING_CERT_ALIAS, value);
} else {
setExtendedAttributeValue(spConfig, IFSConstants.ENCRYPTION_CERT_ALIAS, value);
}
}
metaManager.setEntityDescriptor(realm, desp);
metaManager.setEntityConfig(realm, config);
}
}
use of com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType in project OpenAM by OpenRock.
the class IDFFModelImpl method getEntityIDPDescriptor.
/**
* Returns a map of IDP key/value pairs.
*
* @param realm where the entity exists.
* @param entityName of entity descriptor.
* @return map of IDP key/value pairs
*/
public Map getEntityIDPDescriptor(String realm, String entityName) throws AMConsoleException {
String[] params = { realm, entityName, "IDFF", "IDP-Standard Metadata" };
logEvent("ATTEMPT_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
Map map = new HashMap();
try {
IDFFMetaManager manager = getIDFFMetaManager();
IDPDescriptorType pDesc = manager.getIDPDescriptor(realm, entityName);
// common attributes
map.put(ATTR_PROTOCOL_SUPPORT_ENUMERATION, convertListToSet(pDesc.getProtocolSupportEnumeration()));
//communication URLs
map.put(ATTR_SOAP_END_POINT, returnEmptySetIfValueIsNull(pDesc.getSoapEndpoint()));
map.put(ATTR_SINGLE_SIGN_ON_SERVICE_URL, returnEmptySetIfValueIsNull(pDesc.getSingleSignOnServiceURL()));
map.put(ATTR_SINGLE_LOGOUT_SERVICE_URL, returnEmptySetIfValueIsNull(pDesc.getSingleLogoutServiceURL()));
map.put(ATTR_SINGLE_LOGOUT_SERVICE_RETURN_URL, returnEmptySetIfValueIsNull(pDesc.getSingleLogoutServiceReturnURL()));
map.put(ATTR_FEDERATION_TERMINATION_SERVICES_URL, returnEmptySetIfValueIsNull(pDesc.getFederationTerminationServiceURL()));
map.put(ATTR_FEDERATION_TERMINATION_SERVICE_RETURN_URL, returnEmptySetIfValueIsNull(pDesc.getFederationTerminationServiceReturnURL()));
map.put(ATTR_REGISTRATION_NAME_IDENTIFIER_SERVICE_URL, returnEmptySetIfValueIsNull(pDesc.getRegisterNameIdentifierServiceURL()));
map.put(ATTR_REGISTRATION_NAME_IDENTIFIER_SERVICE_RETURN_URL, returnEmptySetIfValueIsNull(pDesc.getRegisterNameIdentifierServiceReturnURL()));
// communication profiles
map.put(ATTR_FEDERATION_TERMINATION_NOTIFICATION_PROTOCOL_PROFILE, returnEmptySetIfValueIsNull((String) pDesc.getFederationTerminationNotificationProtocolProfile().get(0)));
map.put(ATTR_SINGLE_LOGOUT_PROTOCOL_PROFILE, returnEmptySetIfValueIsNull((String) pDesc.getSingleLogoutProtocolProfile().get(0)));
map.put(ATTR_REGISTRATION_NAME_IDENTIFIER_PROFILE_PROFILE, returnEmptySetIfValueIsNull((String) pDesc.getRegisterNameIdentifierProtocolProfile().get(0)));
map.put(ATTR_SINGLE_SIGN_ON_PROTOCOL_PROFILE, returnEmptySetIfValueIsNull((String) pDesc.getSingleSignOnProtocolProfile().get(0)));
// get signing key size and algorithm
EncInfo encinfo = KeyUtil.getEncInfo((ProviderDescriptorType) pDesc, entityName, //isIDP
true);
if (encinfo == null) {
map.put(ATTR_ENCRYPTION_KEY_SIZE, Collections.EMPTY_SET);
map.put(ATTR_ENCRYPTION_ALGORITHM, Collections.EMPTY_SET);
} else {
int size = encinfo.getDataEncStrength();
String alg = encinfo.getDataEncAlgorithm();
map.put(ATTR_ENCRYPTION_KEY_SIZE, returnEmptySetIfValueIsNull(Integer.toString(size)));
map.put(ATTR_ENCRYPTION_ALGORITHM, returnEmptySetIfValueIsNull(alg));
}
logEvent("SUCCEED_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
} catch (IDFFMetaException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, entityName, "IDFF", "IDP-Standard Metadata", strError };
logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
throw new AMConsoleException(strError);
}
return map;
}
use of com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType in project OpenAM by OpenRock.
the class IDFFModelImpl method updateEntityIDPDescriptor.
public void updateEntityIDPDescriptor(String realm, String entityName, Map attrValues, Map extendedValues, boolean ishosted) throws AMConsoleException {
String[] params = { realm, entityName, "IDFF", "IDP-Standard Metadata" };
logEvent("ATTEMPT_MODIFY_ENTITY_DESCRIPTOR", params);
try {
//save key and encryption details if present for hosted
if (ishosted == true) {
String keysize = getValueByKey(attrValues, ATTR_ENCRYPTION_KEY_SIZE);
String algorithm = getValueByKey(attrValues, ATTR_ENCRYPTION_ALGORITHM);
String e_certAlias = getValueByKey(extendedValues, ATTR_ENCRYPTION_CERT_ALIAS);
String s_certAlias = getValueByKey(extendedValues, ATTR_SIGNING_CERT_ALIAS);
int keysi = (keysize != null && keysize.length() > 0) ? Integer.parseInt(keysize) : 128;
String alg = (algorithm == null || algorithm.length() == 0) ? "http://www.w3.org/2001/04/xmlenc#aes128-cbc" : algorithm;
IDFFMetaSecurityUtils.updateProviderKeyInfo(realm, entityName, e_certAlias, false, true, alg, keysi);
IDFFMetaSecurityUtils.updateProviderKeyInfo(realm, entityName, s_certAlias, true, true, alg, keysi);
}
IDFFMetaManager idffManager = getIDFFMetaManager();
EntityDescriptorElement entityDescriptor = idffManager.getEntityDescriptor(realm, entityName);
IDPDescriptorType pDesc = idffManager.getIDPDescriptor(realm, entityName);
//Protocol Support Enumeration
pDesc.getProtocolSupportEnumeration().clear();
pDesc.getProtocolSupportEnumeration().addAll((Collection) attrValues.get(ATTR_PROTOCOL_SUPPORT_ENUMERATION));
//communication URLs
pDesc.setSoapEndpoint((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SOAP_END_POINT)));
pDesc.setSingleSignOnServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_SIGN_ON_SERVICE_URL)));
pDesc.setSingleLogoutServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_LOGOUT_SERVICE_URL)));
pDesc.setSingleLogoutServiceReturnURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_LOGOUT_SERVICE_RETURN_URL)));
pDesc.setFederationTerminationServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_FEDERATION_TERMINATION_SERVICES_URL)));
pDesc.setFederationTerminationServiceReturnURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_FEDERATION_TERMINATION_SERVICE_RETURN_URL)));
pDesc.setRegisterNameIdentifierServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_REGISTRATION_NAME_IDENTIFIER_SERVICE_URL)));
pDesc.setRegisterNameIdentifierServiceReturnURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_REGISTRATION_NAME_IDENTIFIER_SERVICE_RETURN_URL)));
// communication profiles
pDesc.getFederationTerminationNotificationProtocolProfile().clear();
pDesc.getFederationTerminationNotificationProtocolProfile().add((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_FEDERATION_TERMINATION_NOTIFICATION_PROTOCOL_PROFILE)));
int size = federationTerminationProfileList.size();
for (int i = 0; i < size; i++) {
if (!federationTerminationProfileList.get(i).equals((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_FEDERATION_TERMINATION_NOTIFICATION_PROTOCOL_PROFILE)))) {
pDesc.getFederationTerminationNotificationProtocolProfile().add(federationTerminationProfileList.get(i));
}
}
pDesc.getSingleLogoutProtocolProfile().clear();
pDesc.getSingleLogoutProtocolProfile().add((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_LOGOUT_PROTOCOL_PROFILE)));
size = singleLogoutProfileList.size();
for (int i = 0; i < size; i++) {
if (!singleLogoutProfileList.get(i).equals((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_LOGOUT_PROTOCOL_PROFILE)))) {
pDesc.getSingleLogoutProtocolProfile().add(singleLogoutProfileList.get(i));
}
}
pDesc.getRegisterNameIdentifierProtocolProfile().clear();
pDesc.getRegisterNameIdentifierProtocolProfile().add((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_REGISTRATION_NAME_IDENTIFIER_PROFILE_PROFILE)));
size = nameRegistrationProfileList.size();
for (int i = 0; i < size; i++) {
if (!nameRegistrationProfileList.get(i).equals((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_REGISTRATION_NAME_IDENTIFIER_PROFILE_PROFILE)))) {
pDesc.getRegisterNameIdentifierProtocolProfile().add(nameRegistrationProfileList.get(i));
}
}
pDesc.getSingleSignOnProtocolProfile().clear();
pDesc.getSingleSignOnProtocolProfile().add((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_SIGN_ON_PROTOCOL_PROFILE)));
size = federationProfileList.size();
for (int i = 0; i < size; i++) {
if (!federationProfileList.get(i).equals((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_SIGN_ON_PROTOCOL_PROFILE)))) {
pDesc.getSingleSignOnProtocolProfile().add(federationProfileList.get(i));
}
}
entityDescriptor.getIDPDescriptor().clear();
entityDescriptor.getIDPDescriptor().add(pDesc);
idffManager.setEntityDescriptor(realm, entityDescriptor);
logEvent("SUCCEED_MODIFY_ENTITY_DESCRIPTOR", params);
} catch (IDFFMetaException e) {
debug.error("IDFFMetaException , updateEntityIDPDescriptor", e);
String strError = getErrorString(e);
String[] paramsEx = { realm, entityName, "IDFF", "SP-Standard Metadata", strError };
logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType in project OpenAM by OpenRock.
the class FSAssertionArtifactHandler method sendProxyResponse.
/**
* Sends the proxy authentication response to the proxying service
* provider which has originally requested for the authentication.
* @param requestID authnRequest id that is sent to the authenticating
* Identity Provider.
*/
protected void sendProxyResponse(String requestID) {
FSUtils.debug.message("FSAssertionArtifactHandler.sendProxyResponse::");
FSSessionManager sessionManager = FSSessionManager.getInstance(hostMetaAlias);
FSAuthnRequest origRequest = sessionManager.getProxySPAuthnRequest(requestID);
if (FSUtils.debug.messageEnabled()) {
try {
FSUtils.debug.message("FSAssertionHandler.sendProxyResponse:" + origRequest.toXMLString());
} catch (Exception ex) {
FSUtils.debug.error("FSAssertionHandler.sendProxyResponse:" + "toString(): Failed.", ex);
}
}
SPDescriptorType proxyDescriptor = sessionManager.getProxySPDescriptor(requestID);
String proxySPEntityId = origRequest.getProviderId();
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSAssertionArtifactHandler.sendProxyResponse" + ":Original requesting service provider id:" + proxySPEntityId);
}
FSSession session = sessionManager.getSession(ssoToken);
if (authnContextStmt != null) {
String authnContext = authnContextStmt.getAuthnContextClassRef();
session.setAuthnContext(authnContext);
}
session.addSessionPartner(new FSSessionPartner(proxySPEntityId, false));
if (FSUtils.debug.messageEnabled()) {
Iterator partners = session.getSessionPartners().iterator();
while (partners.hasNext()) {
FSSessionPartner part = (FSSessionPartner) partners.next();
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("PARTNERS" + part.getPartner());
}
}
}
IDFFMetaManager metaManager = FSUtils.getIDFFMetaManager();
BaseConfigType proxySPConfig = null;
try {
proxySPConfig = metaManager.getSPDescriptorConfig(realm, proxySPEntityId);
} catch (Exception e) {
FSUtils.debug.error("FSAssertionArtifactHandler.sendProxyResponse:" + "Couldn't obtain proxy sp meta:", e);
}
FSProxyHandler handler = new FSProxyHandler(request, response, origRequest, proxyDescriptor, proxySPConfig, proxySPEntityId, origRequest.getRelayState(), ssoToken);
IDPDescriptorType localIDPDesc = null;
BaseConfigType localIDPConfig = null;
String localIDPMetaAlias = null;
try {
localIDPDesc = metaManager.getIDPDescriptor(realm, hostEntityId);
localIDPConfig = metaManager.getIDPDescriptorConfig(realm, hostEntityId);
localIDPMetaAlias = localIDPConfig.getMetaAlias();
} catch (Exception e) {
FSUtils.debug.error("FSAssertionartifactHandler.sendProxyResponse:" + "Exception when obtaining local idp meta:", e);
}
handler.setRealm(realm);
handler.setHostedEntityId(hostEntityId);
handler.setHostedDescriptor(localIDPDesc);
handler.setHostedDescriptorConfig(localIDPConfig);
handler.setMetaAlias(localIDPMetaAlias);
handler.processAuthnRequest(origRequest, true);
}
Aggregations