How to encrypt oracle ucp database connection in tomcat config? - database

I want to encrypt my database connection in tomcat 7 config (server.xml). I'm using the connectionProperties to provide encryption algorithm, but somehow, these properties are not working.
Here is the chunk from my config file:
<Resource
name="jdbc/TestDb" auth="Container"
type="oracle.ucp.jdbc.PoolDataSource"
description="UCP Pool in Tomcat"
factory="oracle.ucp.jdbc.PoolDataSourceImpl"
connectionFactoryClassName="oracle.jdbc.pool.OracleDataSource"
minPoolSize="10"
maxPoolSize="100"
inactiveConnectionTimeout="20"
user="******"
password="*****"
connectionProperties="oracle.net.encryption_client=REQUIRED,
oracle.net.encryption_types_client=AES256,
oracle.net.crypto_checksum_client=REQUIRED,
oracle.net.crypto_checksum_types_client=SHA512"
url="jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=***)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=***)))"
connectionPoolName="UCPPool"
sqlForValidateConnection="select 1 from DUAL"
validateConnectionOnBorrow="true" />
Tried with semicolon in connectionProperties in place of comma. But nothing is working.
Please see, if someone can help.

Try entering values in below format -
{prop1=val1, prop2=val2, ..., propN=valN}
All key value pairs should be separated by ", " (comma and space char)and should be placed within {}.
For example in your case, it should be -
connectionProperties="{oracle.net.encryption_client=REQUIRED, oracle.net.encryption_types_client=AES256, oracle.net.crypto_checksum_client=REQUIRED, oracle.net.crypto_checksum_types_client=SHA512}"

Related

Password containing left angle bracket causing issues in web.config file asp.net

Hi I am trying to build a connectionstring in web.config file in MVC. Everything is fine except that I have to use autogenerated password and latest password has left angle bracket. When I am using this password containing left angle bracket, the connectionstring does not build correctly and I face failed connection.
"Data Source=JungJu.database.windows.net;Initial Catalog=MainDb;User ID=FuntoGo;Password=OV_Xu2v8j2K$#~/<bI,A]d;Authentication=Active Directory Password
Replace it with
<
is is the XML safe replacement for < (less than)

Unable to start Kafka Server using SASL_PLAINTEXT authentication

I'm trying to run Apache Kafka on Windows Server 2016 with the following configurations
server.propertiers:
delete.topic.enable=true
security.inter.broker.protocol=SASL_PLAINTEXT
sasl.mechanism.inter.broker.protocol=PLAIN
sasl.enabled.mechanisms=PLAIN
authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer
allow.everyone.if.no.acl.found=true
security.protocol=SASL_PLAINTEXT
listeners=SASL_PLAINTEXT://127.0.0.1:9092
advertised.listeners=SASL_PLAINTEXT://localhost:9092
listener.security.protocol.map=SASL_PLAINTEXT:SASL_PLAINTEXT
kafka_server_jaas.conf:
KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="username"
password="password"
user_kafkaadmin="password2";
};
Client {};
start-kafka.bat:
#echo off
SET KAFKA_OPTS = "-Djava.security.auth.login.config=C:\Kafka\config\kafka_server_jaas.conf"
C:\Kafka\bin\windows\kafka-server-start.bat C:\Kafka\config\server.properties
However I'm getting the following error
ERROR [KafkaServer id=0] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
java.lang.IllegalArgumentException: Could not find a 'KafkaServer' or 'sasl_plaintext.KafkaServer' entry in the JAAS configuration. System property 'java.security.auth.login.config' is not set
at org.apache.kafka.common.security.JaasContext.defaultContext(JaasContext.java:133)
at org.apache.kafka.common.security.JaasContext.load(JaasContext.java:98)
at org.apache.kafka.common.security.JaasContext.loadServerContext(JaasContext.java:70)
at org.apache.kafka.common.network.ChannelBuilders.create(ChannelBuilders.java:121)
at org.apache.kafka.common.network.ChannelBuilders.serverChannelBuilder(ChannelBuilders.java:85)
at kafka.network.Processor.<init>(SocketServer.scala:747)
at kafka.network.SocketServer.newProcessor(SocketServer.scala:394)
at kafka.network.SocketServer$$anonfun$kafka$network$SocketServer$$addDataPlaneProcessors$1.apply$mcVI$sp(SocketServer.scala:279)
at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:160)
at kafka.network.SocketServer.kafka$network$SocketServer$$addDataPlaneProcessors(SocketServer.scala:278)
at kafka.network.SocketServer$$anonfun$createDataPlaneAcceptorsAndProcessors$1.apply(SocketServer.scala:241)
at kafka.network.SocketServer$$anonfun$createDataPlaneAcceptorsAndProcessors$1.apply(SocketServer.scala:238)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
at kafka.network.SocketServer.createDataPlaneAcceptorsAndProcessors(SocketServer.scala:238)
at kafka.network.SocketServer.startup(SocketServer.scala:121)
at kafka.server.KafkaServer.startup(KafkaServer.scala:263)
at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:44)
at kafka.Kafka$.main(Kafka.scala:84)
at kafka.Kafka.main(Kafka.scala)
Am I missing something in the configuration?
Thank you,
Try to remove spaces before and after the equal sign:
SET KAFKA_OPTS=-Djava.security.auth.login.config=C:\Kafka\config\kafka_server_jaas.conf
Because normally you should not put a space on either side of the equal sign. A space before the equal sign will become part of the name; a space after the equal sign will become part of the value.

How to escape LDAP dn for lookup?

I have a small script (spring/groovy/ldap) that finds, in Active Directory, the 'management tree' under a person,
i.e. from a 'root person' the script finds the root person's direct reports then uses recursion: for each direct report find their direct reports, etc.
the directReports users attribute specifies a list of DN's in the form:
CN=Simpson\, Homer,OU=OU_0731DevOps,OU=OU_0100Monitor Services,OU=OU_0001U*Nuclear Energy Corporation,OU=OU_UNuclearUsers,DC=corp,DC=unucleargrp,DC=com
The script does an "ldap lookup" for each direct report by DN, e.g.:
obj = ldapTemplate.lookup(pDn, new UserAttributesMapper())
Problem
The ldap lookup throws an InvalidNameException
[LDAP: error code 34 - 0000208F: LdapErr: DSID-0C090787
I've tried various combinations of escaping but still get the error.
What am I missing???
More Info
This url https://social.technet.microsoft.com/wiki/contents/articles /5312.active-directory-characters-to-escape.aspx shows which characters to escape:
Active Directory requires that the following ten characters be escaped
with the backslash "\" escape character if they appear in any of the
individual components of a distinguished name:
Comma ,
Backslash character \
Pound sign (hash sign) #
Plus sign +
Less than symbol <
Greater than symbol >
Semicolon ;
Double quote (quotation mark) "
Equal sign =
Leading or trailing spaces
Tools
Groovy
Spring Boot
JVM
thanks!
I found the answer by poking around with LDAPNameBuilder.
TLDR:
ldapTemplate.lookup requires stripping off the "DC.." portion of the DN.*
If you know a cleaner/more-official solution, please post!
LDAP Lookup fails with a DN like this:
This DN has "DC=.." components and fails using spring ldap lookup.
CN=Simpson\, Homer,OU=OU_0731DevOps,OU=OU_0100Monitor Services,OU=OU_0001U*Nuclear Energy Corporation,OU=OU_UNuclearUsers,DC=corp,DC=unucleargrp,DC=com
LDAP succeeds with this (no "DC" components):
This DN has no "DC=" components. Spring LDAP template provides the basedn.
CN=Simpson\, Homer,OU=OU_0731DevOps,OU=OU_0100Monitor Services,OU=OU_0001U*Nuclear Energy Corporation
Context Reminder
This application traverses 'management tree.' It gets a persons managees by the 'directReports' attribute (which lists the full-DN's of each direct report). This application wanted to lookup that user by his/her DN.
Tweak/Example
This tweak got the ldap lookup to work:
User lookupUserByDn(String pDn) {
// needed this to get it to work
String dn=pDn.replace(",${ldapConfig.base}","")
ldapTemplate.lookup(dn, new UserAttributesMapper())
}
for the record, my application.yml ldap portion looked like this:
spring:
ldap:
urls: ldap://dc.corp.unucleargrp.com:389
base: DC=corp,DC=unucleargrp,DC=com
username: username_val
password : password_val
According to this https://docs.spring.io/spring-ldap/docs/2.3.1.RELEASE/reference/#contextsource-configuration
Removing the base attribute, All operations going back and forth will use full DNs.

Matlab Integration - modbus.config error

The steps did successfully :
Install the master driver
Storing the registry file (catalyst371.csv) file
I created modbus.config file in the main volttron root with below information:
{
"driver_config": {"device_address": "127.0.0.2", “port”: “5020”},
"driver_type": "modbus",
"registry_config":"config://registers.csv",
"interval": 5,
"timezone": "UTC"
}
When I store the config using:
vctl config store platform.driver devices/mysite/mybuilding/modbus1 modbus.config
I get the error attached error message
I also attached the Volttron Central installed components Volttron Central please let me know if I am missing any other agent.
The key port and value 5020 are not enclosed within regular double quotes. They are curly quotes (may be from word or another software?). Once I fixed the quotes character around port and 5020 I was able to add the file to config store.

Tomcat context.xml resource password not allow special charcaters

I have been trying for add data source in tomcat conf/context.xml as below.
<Resource name="jdbc/DS1"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://121.111.11.91;databaseName=DB_NAME"
username="testUanme"
password="TT&123$"
maxPoolSize="50"
removeAbandoned="true"
removeAbandonedTimeout="1000"
logAbandoned="true"
/>
After set Data Source entry in config file i m restarting tomcat and it gives error like:
The reference to entity "TT" must end with the ';' delimiter.
Password not allowing special characters which i have used & and $.
Please suggest what should be there which allows me to enter special characters in password..
Thanks in advance.
If you replace & in your password with & you should be fine.

Resources