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());
}
}
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));
}
}
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;
}
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;
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaException in project OpenAM by OpenRock.
the class FSAuthDomainsModelImpl method getAllProviderNames.
/**
* Returns a <code>Set</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;
}
Aggregations