use of org.wso2.carbon.mediation.commons.rest.api.swagger.SwaggerConstants.PARAMETERS in project carbon-identity-framework by wso2.
the class FileBasedConfigurationBuilder method processIdPConfigElement.
private ExternalIdPConfig processIdPConfigElement(OMElement idpConfigElem) {
OMAttribute nameAttr = idpConfigElem.getAttribute(new QName("name"));
// if the name is not given, do not register this config
if (nameAttr == null) {
log.warn("Each IDP configuration should have a unique name attribute");
return null;
}
// read the config parameters
Map<String, String> parameterMap = new HashMap<>();
for (Iterator paramIterator = idpConfigElem.getChildrenWithLocalName("Parameter"); paramIterator.hasNext(); ) {
OMElement paramElem = (OMElement) paramIterator.next();
OMAttribute paramNameAttr = paramElem.getAttribute(new QName("name"));
if (paramNameAttr == null) {
log.warn("A Parameter should have a name attribute. Skipping the parameter.");
continue;
}
parameterMap.put(paramNameAttr.getAttributeValue(), paramElem.getText());
}
IdentityProvider fedIdp = new IdentityProvider();
fedIdp.setIdentityProviderName(nameAttr.getAttributeValue());
ExternalIdPConfig externalIdPConfig = new ExternalIdPConfig(fedIdp);
externalIdPConfig.setParameterMap(parameterMap);
return externalIdPConfig;
}
use of org.wso2.carbon.mediation.commons.rest.api.swagger.SwaggerConstants.PARAMETERS in project carbon-identity-framework by wso2.
the class FileBasedConfigurationBuilder method processAuthenticatorConfigElement.
/**
* Create AuthenticatorBean elements for each authenticator entry
*
* @param authenticatorConfigElem OMElement for Authenticator
* @return AuthenticatorBean object
*/
private AuthenticatorConfig processAuthenticatorConfigElement(OMElement authenticatorConfigElem) {
// read the name of the authenticator. this is a mandatory attribute.
OMAttribute nameAttr = authenticatorConfigElem.getAttribute(new QName(FrameworkConstants.Config.ATTR_AUTHENTICATOR_CONFIG_NAME));
// if the name is not given, do not register this authenticator
if (nameAttr == null) {
log.warn("Each Authenticator Configuration should have a unique name attribute. +" + "This Authenticator will not be registered.");
return null;
}
String authenticatorName = nameAttr.getAttributeValue();
// Check whether the enabled attribute is set. By default it will be true if not configured.
boolean enabled = true;
OMAttribute enabledAttr = authenticatorConfigElem.getAttribute(new QName(FrameworkConstants.Config.ATTR_AUTHENTICATOR_ENABLED));
if (enabledAttr != null) {
enabled = Boolean.parseBoolean(enabledAttr.getAttributeValue());
}
// read the config parameters
Map<String, String> parameterMap = new HashMap<>();
for (Iterator paramIterator = authenticatorConfigElem.getChildrenWithLocalName(FrameworkConstants.Config.ELEM_PARAMETER); paramIterator.hasNext(); ) {
OMElement paramElem = (OMElement) paramIterator.next();
OMAttribute paramNameAttr = paramElem.getAttribute(new QName(FrameworkConstants.Config.ATTR_PARAMETER_NAME));
if (paramNameAttr == null) {
log.warn("An Authenticator Parameter should have a name attribute. Skipping the parameter.");
continue;
}
parameterMap.put(paramNameAttr.getAttributeValue(), paramElem.getText());
}
AuthenticatorConfig authenticatorConfig = new AuthenticatorConfig(authenticatorName, enabled, parameterMap);
authenticatorConfig.setApplicationAuthenticator(FrameworkUtils.getAppAuthenticatorByName(authenticatorName));
return authenticatorConfig;
}
use of org.wso2.carbon.mediation.commons.rest.api.swagger.SwaggerConstants.PARAMETERS in project carbon-identity-framework by wso2.
the class FrameworkUtils method getCommonAuthReqWithParams.
/**
* Builds the wrapper, wrapping incoming request and information take from cache entry.
*
* @param request Original request coming to authentication framework
* @param cacheEntry Cache entry from the cache, which is added from calling servlets
* @return
*/
public static HttpServletRequest getCommonAuthReqWithParams(HttpServletRequest request, AuthenticationRequestCacheEntry cacheEntry) {
// add this functionality as a constructor
Map<String, String[]> modifiableParameters = new TreeMap<String, String[]>();
if (cacheEntry != null) {
AuthenticationRequest authenticationRequest = cacheEntry.getAuthenticationRequest();
if (!authenticationRequest.getRequestQueryParams().isEmpty()) {
modifiableParameters.putAll(authenticationRequest.getRequestQueryParams());
}
// Adding field variables to wrapper
if (authenticationRequest.getType() != null) {
modifiableParameters.put(FrameworkConstants.RequestParams.TYPE, new String[] { authenticationRequest.getType() });
}
if (authenticationRequest.getCommonAuthCallerPath() != null) {
modifiableParameters.put(FrameworkConstants.RequestParams.CALLER_PATH, new String[] { authenticationRequest.getCommonAuthCallerPath() });
}
if (authenticationRequest.getRelyingParty() != null) {
modifiableParameters.put(FrameworkConstants.RequestParams.ISSUER, new String[] { authenticationRequest.getRelyingParty() });
}
if (authenticationRequest.getTenantDomain() != null && !IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) {
modifiableParameters.put(FrameworkConstants.RequestParams.TENANT_DOMAIN, new String[] { authenticationRequest.getTenantDomain() });
}
modifiableParameters.put(FrameworkConstants.RequestParams.FORCE_AUTHENTICATE, new String[] { String.valueOf(authenticationRequest.getForceAuth()) });
modifiableParameters.put(FrameworkConstants.RequestParams.PASSIVE_AUTHENTICATION, new String[] { String.valueOf(authenticationRequest.getPassiveAuth()) });
if (log.isDebugEnabled()) {
StringBuilder queryStringBuilder = new StringBuilder("");
for (Map.Entry<String, String[]> entry : modifiableParameters.entrySet()) {
StringBuilder paramValueBuilder = new StringBuilder("");
String[] paramValueArr = entry.getValue();
if (paramValueArr != null) {
for (String paramValue : paramValueArr) {
paramValueBuilder.append("{").append(paramValue).append("}");
}
}
queryStringBuilder.append("\n").append(entry.getKey() + "=" + paramValueBuilder.toString());
}
log.debug("\nInbound Request parameters: " + queryStringBuilder.toString());
}
return new AuthenticationFrameworkWrapper(request, modifiableParameters, authenticationRequest.getRequestHeaders());
}
return request;
}
use of org.wso2.carbon.mediation.commons.rest.api.swagger.SwaggerConstants.PARAMETERS in project carbon-identity-framework by wso2.
the class PrimitiveConditionValidator method validate.
/**
* Validate parameters in a {@link PrimitiveCondition} with the given Search bean
*
* @param primitiveCondition
* @return A db qualified {@link PrimitiveCondition}.
* @throws PrimitiveConditionValidationException
*/
public PrimitiveCondition validate(PrimitiveCondition primitiveCondition) throws PrimitiveConditionValidationException {
if (searchBean == null) {
throw new NullPointerException("Invalid search bean: null in the PrimitiveCondition validate.");
}
String property = primitiveCondition.getProperty();
ConditionType.PrimitiveOperator operator = primitiveCondition.getOperator();
Object value = primitiveCondition.getValue();
if (property == null || operator == null || value == null) {
throw new PrimitiveConditionValidationException("Invalid primitive condition parameters found in: property = " + property + (operator == null ? ", condition = null" : "") + (value == null ? ", value = null" : "") + ".");
}
try {
Field field = this.searchBean.getClass().getDeclaredField(property);
if (!field.getType().getName().equals(value.getClass().getName())) {
throw new PrimitiveConditionValidationException("Value for the property: " + property + " is expected to be: " + field.getType().getName() + " but found: " + value.getClass().getName());
}
} catch (NoSuchFieldException e) {
throw new PrimitiveConditionValidationException("Property: " + property + " is not found in the allowed search properties present in the bean " + "class: " + ResourceSearchBean.class.getName());
}
// If parameter validation are a success then build a database qualified primitive condition.
PrimitiveCondition dbQualifiedPrimitiveCondition;
dbQualifiedPrimitiveCondition = this.searchBean.mapPrimitiveCondition(primitiveCondition);
dbQualifiedPrimitiveCondition.setProperty(this.searchBean.getDBQualifiedFieldName(dbQualifiedPrimitiveCondition.getProperty()));
return dbQualifiedPrimitiveCondition;
}
use of org.wso2.carbon.mediation.commons.rest.api.swagger.SwaggerConstants.PARAMETERS in project carbon-identity-framework by wso2.
the class EntitlementServiceComponent method startThriftEntitlementService.
private void startThriftEntitlementService() throws Exception {
try {
// read identity.xml
IdentityUtil.populateProperties();
// if thrift based EntitlementService is enabled.
String thriftEnabled = IdentityUtil.getProperty(ThriftConfigConstants.PARAM_ENABLE_THRIFT_SERVICE);
if (thriftEnabled != null && Boolean.parseBoolean(thriftEnabled)) {
TSSLTransportFactory.TSSLTransportParameters transportParam = new TSSLTransportFactory.TSSLTransportParameters();
// read the keystore and password used for ssl communication from config
String keystorePath = IdentityUtil.getProperty(ThriftConfigConstants.PARAM_KEYSTORE_LOCATION);
String keystorePassword = IdentityUtil.getProperty(ThriftConfigConstants.PARAM_KEYSTORE_PASSWORD);
// set it in parameters
transportParam.setKeyStore(keystorePath, keystorePassword);
// int receivePort = 10395;
int receivePort = readThriftReceivePort();
// int clientTimeOut = 10000;
int clientTimeOut = Integer.parseInt(IdentityUtil.getProperty(ThriftConfigConstants.PARAM_CLIENT_TIMEOUT));
// String ifAddress = "localhost";
TServerSocket serverTransport = TSSLTransportFactory.getServerSocket(receivePort, clientTimeOut, getHostAddress(readThriftHostName()), transportParam);
EntitlementService.Processor processor = new EntitlementService.Processor(new ThriftEntitlementServiceImpl());
// TODO: have to decide on the protocol.
TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
// TServer server = new TThreadPoolServer(new TThreadPoolServer.Args())
/*
TServer server = new TThreadPoolServer(processor, serverTransport,
new TCompactProtocol.Factory());*/
Runnable serverThread = new ServerRunnable(server);
executor.submit(serverThread);
if (log.isDebugEnabled()) {
log.debug("Started thrift entitlement service at port:" + receivePort);
}
}
} catch (TTransportException e) {
String transportErrorMsg = "Error in initializing thrift transport";
log.error(transportErrorMsg, e);
throw new Exception(transportErrorMsg);
} catch (UnknownHostException e) {
String hostErrorMsg = "Error in obtaining host name";
log.error(hostErrorMsg, e);
throw new Exception(hostErrorMsg);
}
}
Aggregations