use of com.sun.identity.federation.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class IDFFModelImpl method getIDPAuthenticationContexts.
/**
* Returns the object of Auththentication Contexts in IDP.
*
* @param realm Realm of Entity
* @param entityName Name of Entity Descriptor.
* @return attributes values of provider.
*/
public IDFFAuthContexts getIDPAuthenticationContexts(String realm, String entityName) throws AMConsoleException {
String str = null;
IDFFAuthContexts cxt = new IDFFAuthContexts();
try {
List tmpList = new ArrayList();
IDFFMetaManager manager = getIDFFMetaManager();
Map map = new HashMap();
BaseConfigType idpConfig = manager.getIDPDescriptorConfig(realm, entityName);
if (idpConfig != null) {
map = IDFFMetaUtils.getAttributes(idpConfig);
} else {
throw new AMConsoleException("invalid.entity.name");
}
List list = (List) map.get(ATTR_IDP_AUTHN_CONTEXT_MAPPING);
for (int i = 0; i < list.size(); i++) {
String tmp = (String) list.get(i);
int index = tmp.lastIndexOf("|");
String level = removeKey(tmp.substring(index + 1));
tmp = tmp.substring(0, index);
index = tmp.lastIndexOf("|");
String value = removeKey(tmp.substring(index + 1));
tmp = tmp.substring(0, index);
index = tmp.indexOf("|");
String key = removeKey(tmp.substring(index + 1));
String name = removeKey(tmp.substring(0, index));
cxt.put(name, "true", key, value, level);
}
} catch (IDFFMetaException e) {
throw new AMConsoleException(getErrorString(e));
} catch (AMConsoleException e) {
throw new AMConsoleException(getErrorString(e));
}
return (cxt != null) ? cxt : new IDFFAuthContexts();
}
use of com.sun.identity.federation.jaxb.entityconfig.BaseConfigType 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.jaxb.entityconfig.BaseConfigType 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.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class FSRegistrationReturnServlet method doGetPost.
/**
* Handles the request.
* @param request <code>HttpServletRequest</code> object that contains the
* request the client has made of the servlet.
* @param response <code>HttpServletResponse</code> object that contains
* the response the servlet sends to the client.
* @exception ServletException if an input or output error is detected when
* the servlet handles the request
* @exception IOException if the request could not be handled
*/
private void doGetPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
FSUtils.debug.message("FSRegistrationReturnServlet doGetPost...");
String providerAlias = "";
providerAlias = FSServiceUtils.getMetaAlias(request);
if (providerAlias == null || providerAlias.length() < 1) {
FSUtils.debug.error("Unable to retrieve alias, Hosted" + " Provider. Cannot process request");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("aliasNotFound"));
return;
}
if (metaManager == null) {
FSUtils.debug.error("Cannot retrieve hosted descriptor. " + "Cannot process request");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
return;
}
String realm = IDFFMetaUtils.getRealmByMetaAlias(providerAlias);
ProviderDescriptorType hostedProviderDesc = null;
BaseConfigType hostedConfig = null;
String hostedEntityId = null;
String hostedProviderRole = null;
try {
hostedProviderRole = metaManager.getProviderRoleByMetaAlias(providerAlias);
hostedEntityId = metaManager.getEntityIDByMetaAlias(providerAlias);
if (hostedProviderRole != null && hostedProviderRole.equalsIgnoreCase(IFSConstants.IDP)) {
hostedProviderDesc = metaManager.getIDPDescriptor(realm, hostedEntityId);
hostedConfig = metaManager.getIDPDescriptorConfig(realm, hostedEntityId);
} else if (hostedProviderRole != null && hostedProviderRole.equalsIgnoreCase(IFSConstants.SP)) {
hostedProviderDesc = metaManager.getSPDescriptor(realm, hostedEntityId);
hostedConfig = metaManager.getSPDescriptorConfig(realm, hostedEntityId);
}
if (hostedProviderDesc == null) {
throw new IDFFMetaException((String) null);
}
} catch (IDFFMetaException eam) {
FSUtils.debug.error("Unable to find Hosted Provider. not process request");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
return;
}
this.request = request;
setRegistrationURL(hostedConfig, providerAlias);
// Here we will need to
// 1. verify response signature
// 2. verify response status
// 3. retrieve registration request Id from Map
// 4. if status success then do locally else not do locally and
// 5. show status page or LRURL if found in MAP
// (eg intersiteTransfer)
FSNameRegistrationResponse regisResponse = null;
try {
regisResponse = FSNameRegistrationResponse.parseURLEncodedRequest(request);
} catch (FSMsgException e) {
FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_REQUEST_IMPROPER, IFSConstants.REGISTRATION_FAILED);
return;
} catch (SAMLException e) {
FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_REQUEST_IMPROPER, IFSConstants.REGISTRATION_FAILED);
return;
}
String remoteEntityId = regisResponse.getProviderId();
ProviderDescriptorType remoteDesc = null;
boolean isIDP = false;
try {
if (hostedProviderRole.equalsIgnoreCase(IFSConstants.SP)) {
remoteDesc = metaManager.getIDPDescriptor(realm, remoteEntityId);
isIDP = true;
} else {
remoteDesc = metaManager.getSPDescriptor(realm, remoteEntityId);
}
} catch (IDFFMetaException e) {
FSUtils.debug.error("FSRegistrationReturnServlet:", e);
}
if (remoteDesc == null) {
FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_REQUEST_IMPROPER, IFSConstants.REGISTRATION_FAILED);
return;
}
boolean bVerify = true;
try {
if (FSServiceUtils.isSigningOn()) {
bVerify = verifyResponseSignature(request, remoteDesc, remoteEntityId, isIDP);
}
} catch (SAMLException e) {
bVerify = false;
} catch (FSException e) {
bVerify = false;
}
if (bVerify) {
FSNameRegistrationHandler handlerObj = new FSNameRegistrationHandler();
handlerObj.setHostedDescriptor(hostedProviderDesc);
handlerObj.setHostedDescriptorConfig(hostedConfig);
handlerObj.setHostedEntityId(hostedEntityId);
handlerObj.setHostedProviderRole(hostedProviderRole);
handlerObj.setMetaAlias(providerAlias);
handlerObj.setRemoteEntityId(remoteEntityId);
handlerObj.setRemoteDescriptor(remoteDesc);
handlerObj.setRealm(realm);
handlerObj.processRegistrationResponse(request, response, regisResponse);
return;
} else {
FSUtils.debug.error("FSRegistrationReturnServlet " + "Signature on registration request is invalid" + "Cannot proceed name registration");
String[] data = { FSUtils.bundle.getString(IFSConstants.REGISTRATION_INVALID_SIGNATURE) };
LogUtil.error(Level.INFO, LogUtil.INVALID_SIGNATURE, data);
FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_REQUEST_IMPROPER, IFSConstants.REGISTRATION_FAILED);
return;
}
}
use of com.sun.identity.federation.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.
the class FSTerminationInitiationServlet method doGetPost.
/**
* Invoked when the user clicks on the termination link in the application.
* @param request <code>HttpServletRequest</code> object that contains the
* request the client has made of the servlet.
* @param response <code>HttpServletResponse</code> object that contains
* the response the servlet sends to the client.
* @exception ServletException,IOException if the request could not be
* handled
*/
private void doGetPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Alias processing
String providerAlias = request.getParameter(IFSConstants.META_ALIAS);
if (providerAlias == null || providerAlias.length() < 1) {
FSUtils.debug.error("Unable to retrieve alias, Hosted Provider. " + "Cannot process request");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("aliasNotFound"));
return;
}
if (metaManager == null) {
FSUtils.debug.error("Cannot retrieve hosted descriptor. " + "Cannot process request");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
return;
}
ProviderDescriptorType hostedProviderDesc = null;
BaseConfigType hostedConfig = null;
String hostedRole = null;
String hostedEntityId = null;
String realm = IDFFMetaUtils.getRealmByMetaAlias(providerAlias);
try {
hostedRole = metaManager.getProviderRoleByMetaAlias(providerAlias);
hostedEntityId = metaManager.getEntityIDByMetaAlias(providerAlias);
if (hostedRole != null && hostedRole.equalsIgnoreCase(IFSConstants.SP)) {
hostedProviderDesc = metaManager.getSPDescriptor(realm, hostedEntityId);
hostedConfig = metaManager.getSPDescriptorConfig(realm, hostedEntityId);
} else if (hostedRole != null && hostedRole.equalsIgnoreCase(IFSConstants.IDP)) {
hostedProviderDesc = metaManager.getIDPDescriptor(realm, hostedEntityId);
hostedConfig = metaManager.getIDPDescriptorConfig(realm, hostedEntityId);
}
if (hostedProviderDesc == null) {
throw new IDFFMetaException((String) null);
}
} catch (IDFFMetaException eam) {
FSUtils.debug.error("Unable to find Hosted Provider. not process request", eam);
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
return;
}
boolean isIDP = false;
if (hostedRole != null && hostedRole.equalsIgnoreCase(IFSConstants.IDP)) {
isIDP = true;
}
if (FSUtils.needSetLBCookieAndRedirect(request, response, isIDP)) {
return;
}
this.request = request;
setTerminationURL(hostedConfig, providerAlias);
doTerminationInitiation(request, response, hostedProviderDesc, hostedConfig, realm, hostedEntityId, hostedRole, providerAlias);
return;
}
Aggregations