use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.
the class FSPreLogin method setMetaInfo.
/**
* Retrieves hosted provider and local configuration attributes.
*
* @param metaAlias the provider alias.
* @param httpRequest the HttpServletRequest object.
* @exception FSPreLoginException on error.
*/
private void setMetaInfo(String metaAlias, HttpServletRequest httpRequest) throws FSPreLoginException {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSPreLogin::setMetaInfo called with metaAlias =" + metaAlias);
}
String authType = null;
try {
String hostedEntityID = null;
String hostedProviderRole = IFSConstants.SP;
if (metaManager != null) {
hostedProviderRole = metaManager.getProviderRoleByMetaAlias(metaAlias);
hostedEntityID = metaManager.getEntityIDByMetaAlias(metaAlias);
} else {
FSUtils.debug.error("FSPreLogin::setMetaInfo " + "meta manager is null. " + "Cannot proceed so throwing error page");
throw new FSPreLoginException("FSPreLogin:: could not get meta manager handle.");
}
realm = IDFFMetaUtils.getRealmByMetaAlias(metaAlias);
BaseConfigType hostedConfig = null;
if (hostedProviderRole != null) {
if (hostedProviderRole.equals(IFSConstants.SP)) {
hostedConfig = metaManager.getSPDescriptorConfig(realm, hostedEntityID);
} else if (hostedProviderRole.equals(IFSConstants.IDP)) {
hostedConfig = metaManager.getIDPDescriptorConfig(realm, hostedEntityID);
}
}
if (hostedConfig != null) {
Map attributes = IDFFMetaUtils.getAttributes(hostedConfig);
homePage = IDFFMetaUtils.getFirstAttributeValue(attributes, IFSConstants.PROVIDER_HOME_PAGE_URL);
authType = IDFFMetaUtils.getFirstAttributeValue(attributes, IFSConstants.AUTH_TYPE);
commonLoginPage = FSServiceUtils.getCommonLoginPageURL(httpRequest, hostedConfig);
errorPage = FSServiceUtils.getErrorPageURL(httpRequest, hostedConfig, metaAlias);
} else {
FSUtils.debug.error("FSPreLogin::setMetaInfo " + "getDescriptorConfig retured null. " + "Cannot proceed so throwing error page");
throw new FSPreLoginException("FSPreLogin:: could not get sp config.");
}
if (authType != null && authType.equalsIgnoreCase(IFSConstants.AUTH_LOCAL)) {
doLocalAuth = true;
} else {
FSUtils.debug.message("FSPreLogin::setMetaInfo " + "authType=" + authType + "Setting authType to default false.");
}
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSPreLogin::setMetaInfo.realm = " + realm + " doLocalAuth = " + doLocalAuth);
}
} catch (IDFFMetaException allianExp) {
FSUtils.debug.error("FSPreLogin::setMetaInfo." + " IDFFMetaException caught. ", allianExp);
throw new FSPreLoginException("FSPreLogin::IDFFMetaException. ");
} catch (Exception exp) {
FSUtils.debug.error("FSPreLogin::setMetaInfo." + " General Exception caught. ", exp);
throw new FSPreLoginException("Prelogin exception");
}
}
use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.
the class FSPostLogin method setMetaInfo.
/**
* Retrieves the entityID of the provider.
*
* @param metaAlias the provider alias.
* @param request the <code>HttpServletRequest</code> object.
* @exception FSPostLoginException on error.
*/
private void setMetaInfo(String metaAlias, HttpServletRequest request) throws FSPostLoginException {
if (metaManager != null) {
BaseConfigType hostedConfig = null;
try {
providerRole = metaManager.getProviderRoleByMetaAlias(metaAlias);
entityID = metaManager.getEntityIDByMetaAlias(metaAlias);
realm = IDFFMetaUtils.getRealmByMetaAlias(metaAlias);
if (providerRole != null && providerRole.equals(IFSConstants.IDP)) {
isIDP = true;
hostedConfig = metaManager.getIDPDescriptorConfig(realm, entityID);
} else if (providerRole != null && providerRole.equalsIgnoreCase(IFSConstants.SP)) {
hostedConfig = metaManager.getSPDescriptorConfig(realm, entityID);
}
} catch (IDFFMetaException ie) {
FSUtils.debug.error("FSPostLogin::setMetaInfo: exception:", ie);
}
consentPage = FSServiceUtils.getConsentPageURL(request, hostedConfig);
federationPage = FSServiceUtils.getDoFederatePageURL(request, hostedConfig);
errorPage = FSServiceUtils.getErrorPageURL(request, hostedConfig, metaAlias);
} else {
FSUtils.debug.error("FSPostLogin::setMetaInfo " + "could not get alliane manager handle " + "Cannot proceed so throwing error page");
throw new FSPostLoginException("FSPostLogin:: could not get meta manager handle.");
}
}
use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.
the class FSSOAPReceiver method getRemoteProviderDescriptor.
private ProviderDescriptorType getRemoteProviderDescriptor(String hostedProviderRole, String remoteEntityId, String realm) {
try {
IDFFMetaManager metaManager = FSUtils.getIDFFMetaManager();
if (metaManager == null) {
FSUtils.debug.message("Unable to get meta manager");
return null;
}
ProviderDescriptorType remoteDesc = null;
if (hostedProviderRole.equalsIgnoreCase(IFSConstants.SP)) {
remoteDesc = metaManager.getIDPDescriptor(realm, remoteEntityId);
} else {
remoteDesc = metaManager.getSPDescriptor(realm, remoteEntityId);
}
return remoteDesc;
} catch (IDFFMetaException eam) {
FSUtils.debug.error("Unable to find Hosted Provider.Cannot process request:", eam);
return null;
}
}
use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.
the class FSDefaultRealmAttributePlugin method getAttributeStatements.
/**
* Returns list of <code>AttributeStatement</code>s by using attribute
* map defined in the configuration.
* @param realm The realm under which the entity resides.
* @param hostEntityId Hosted identity provider entity id.
* @param remoteEntityID Remote provider's entity id
* @param subject Subject subject of the authenticated principal.
* @param token user's session.
* @return list of SAML <code>AttributeStatement<code>s.
*/
public List getAttributeStatements(String realm, String hostEntityId, String remoteEntityID, FSSubject subject, Object token) {
FSUtils.debug.message("FSDefaultAttributePlugin.getAttributeStatements");
Map attributeMap = null;
try {
IDFFMetaManager metaManager = FSUtils.getIDFFMetaManager();
if (metaManager != null) {
IDPDescriptorConfigElement idpConfig = metaManager.getIDPDescriptorConfig(realm, hostEntityId);
if (idpConfig != null) {
Map attributes = IDFFMetaUtils.getAttributes(idpConfig);
attributeMap = FSServiceUtils.parseAttributeConfig((List) attributes.get(IFSConstants.IDP_ATTRIBUTE_MAP));
}
}
} catch (IDFFMetaException me) {
FSUtils.debug.error("FSDefaultAttributePlugin.getAttribute" + "Statements: meta exception.", me);
return null;
}
if (attributeMap == null || attributeMap.isEmpty()) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSDefaultAttributePlugin.getAttribute" + "Statements: Attribute map configuration is empty.");
}
return null;
} else {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSDefaultAttributePlugin.getAttribute" + "Statements: Attribute map configuration: " + attributeMap);
}
}
List statements = new ArrayList();
List attributes = new ArrayList();
try {
Iterator iter = attributeMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String attributeName = (String) entry.getKey();
String attributeValue = getAttributeValue(token, (String) entry.getValue());
if (attributeValue != null) {
Attribute attr = new Attribute(attributeName, SAMLConstants.assertionSAMLNameSpaceURI, attributeValue);
attributes.add(attr);
}
}
AttributeStatement statement = new AttributeStatement(subject, attributes);
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSDefaultAttributePlugin.getAttribute" + "Statements: attribute statement: " + statement.toString());
}
statements.add(statement);
return statements;
} catch (SAMLException ex) {
FSUtils.debug.error("FSDefaultAttributePlugin.getAttribute" + "Statements: SAML Exception", ex);
}
return new ArrayList();
}
use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.
the class FSLoginHelper method setMetaInfo.
private void setMetaInfo(String metaAlias, String authLevel) throws FSLoginHelperException {
try {
realm = IDFFMetaUtils.getRealmByMetaAlias(metaAlias);
if (metaManager != null) {
hostEntityID = metaManager.getEntityIDByMetaAlias(metaAlias);
hostDescriptor = metaManager.getSPDescriptor(realm, hostEntityID);
hostConfig = metaManager.getSPDescriptorConfig(realm, hostEntityID);
} else {
FSUtils.debug.error("FSLoginHelper::setMetaInfo " + "could not get meta manager handle " + "Cannot proceed so throwing error page");
throw new FSLoginHelperException("FSLoginHelper:: could not get meta manager handle.");
}
if (hostDescriptor == null) {
FSUtils.debug.error("FSLoginHelper::setMetaInfo " + "getHostedProviderByMetaAlias retured null. " + "Cannot proceed so throwing error page");
throw new FSLoginHelperException("FSLoginHelper:: could not get" + " host provider Descriptor handle.");
}
if (hostConfig != null) {
nameIDPolicy = IDFFMetaUtils.getFirstAttributeValueFromConfig(hostConfig, IFSConstants.NAMEID_POLICY);
cotList = IDFFMetaUtils.getAttributeValueFromConfig(hostConfig, IFSConstants.COT_LIST);
respondWithString = IFSConstants.RESPOND_WITH;
forceAuthn = IDFFMetaUtils.getBooleanAttributeValueFromConfig(hostConfig, IFSConstants.FORCE_AUTHN);
isPassive = IDFFMetaUtils.getBooleanAttributeValueFromConfig(hostConfig, IFSConstants.IS_PASSIVE);
protocolProfile = IDFFMetaUtils.getFirstAttributeValueFromConfig(hostConfig, IFSConstants.SUPPORTED_SSO_PROFILE);
authContextString = IDFFMetaUtils.getFirstAttributeValueFromConfig(hostConfig, IFSConstants.DEFAULT_AUTHNCONTEXT);
errorPage = FSServiceUtils.getErrorPageURL(request, hostConfig, metaAlias);
if (authLevel != null) {
FSUtils.debug.message("FSLoginHelper()::authLevel not null");
Map spAuthInfoMap = FSServiceUtils.getSPAuthContextInfo(hostConfig);
Set mapSet = spAuthInfoMap.entrySet();
Iterator iter = mapSet.iterator();
FSSPAuthenticationContextInfo tmpObj = null;
while (iter.hasNext()) {
Map.Entry mapEntry = (Map.Entry) iter.next();
tmpObj = (FSSPAuthenticationContextInfo) mapEntry.getValue();
int authLevelInt = Integer.parseInt(authLevel);
if (tmpObj.getAuthenticationLevel() == authLevelInt) {
authContextString = tmpObj.getAuthenticationContext();
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSLoginHelper()::Found auth context " + authContextString + "for auth level " + authLevel);
}
break;
}
}
}
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSLoginHelper()::respondWithString: " + respondWithString);
FSUtils.debug.message("FSLoginHelper()::providerID: " + hostEntityID);
FSUtils.debug.message("FSLoginHelper()::forceAuthn: " + forceAuthn);
FSUtils.debug.message("FSLoginHelper()::isPassive: " + isPassive);
}
} else {
FSUtils.debug.error("FSLoginHelper:setMetaInfo failed" + "host extended meta is null");
throw new FSLoginHelperException("FSLoginHelper::could not get host meta config.");
}
} catch (IDFFMetaException metaExp) {
FSUtils.debug.error("FSLoginHelper::setMetaInfo " + "meta management Failed.", metaExp);
throw new FSLoginHelperException("FSLoginHelper::IDFFMetaException:" + metaExp.getMessage());
} catch (Exception exp) {
FSUtils.debug.error("FSLoginHelper::setMetaInfo " + "General Exception caugth.", exp);
throw new FSLoginHelperException("FSLoginHelper::Exception:" + exp.getMessage());
}
}
Aggregations