What is type=Direct in MongoAuthority - mongo-java

Any idea what is Direct type in MongoAuthority ?
Copy-pasting a part of, while my debuging.
Mongo{authority=MongoAuthority{type=Direct, serverAddresses=[127.0.0.1:27017], credentials={credentials={}}}, ... }
Here i see that credentials object is empty!! Is that because of direct type of Authentication?
Also, what are the different types of Authentications in mongo from java?
Thanks in advance!!
Regards,
Nilotpal

Type.Direct specifies the type of connection between server.
There can be 2 possibilities for Type namely:
Type.Direct: In case of single server Address and
Type.Set: In case of a list server addresses.

Related

How can i trim URLs to root domain? i'm using notepad++

I have a list of domain name with parameters
http://www.anandinfra.net/project.php?id=2
http://artlinkinteriors.com/page.php?id=1
http://www.rabinmukherjeecollege.in/notice_details.php?id=1
I need to find other parts with domain and I have to replace those parts.
Finally my result should look as follows. Expected result:
http://www.anandinfra.net/
http://artlinkinteriors.com/
http://www.rabinmukherjeecollege.in/
How can I attain this result?
Hi you can create a CNAME in the DNS setting with the
http://www.anandinfra.net/project.php?id=2 pointing to http://www.anandinfra.net/
and same for the rest
In whatever programming language you use (which you don't disclose), find the relevant library handling URLs and use it to mutate them. DO NOT attempt to do that by string manipulation.

alter email address in DB to render it un-deliverable

I need to alter email addresses of users to render them undeliverable (not ever a real address), however it needs to be reversible so that the original is visible or at least retrievable (without storing it elsewhere).
For example john#example.com -> NONAME_john#exampleNOTHING.com might work as it can be changed back.
However, the problem is that I cannot KNOW that the above-resulting address is not a real email address. Maybe there is a real address out there called NONAME_john#exampleNOTHING.com.
The requirements are that the address needs to be valid (in terms of having '#' and '.com' etc) but won't send.
Maybe my requirements are a contradiction and hence not possible? Does anyone know?
Your requirements are kind of a contradiction. The only way to make an addres unworkable is to render it practically invalid.
Note that "invalid" can mean at least three things;
it doesn't parse as an e-mail address (e.g. replace # by ⓐ)
the user name is invalid at that domain
the domain name is invalid
The point is that for 2 and 3 there is no easy way to know for sure if that is the case.
What you also could do is obfuscate the e-mail addres by applying a reversable transformation, like e.g. base64 encoding it. This falls under category 1 above.
For example in Python 3:
In [1]: import base64
In [2]: base64.b64encode('john#example.com'.encode('utf-8'))
Out[2]: b'am9obkBleGFtcGxlLmNvbQ=='
In [3]: base64.b64decode(b'am9obkBleGFtcGxlLmNvbQ==').decode('utf-8')
Out[3]: 'john#example.com'

Redirecting URL in JBOSS AS 7

Hi everyone currently i am passing query string in my url like
ip:port/contextroot/page.jsf?id=22&tsid=1234
the query string is a user id and tsid. the doesnt specifically need to type in the query string values. my requirement is to hide the query string in the url and still be able to use the query string values in my app. i was thinking if there is a way to strip off the query string using jboss redirection.
To Summarize:
i wanna access my page.jsf like
ip:port/contextroot/page.jsf
and still get id and tsid from the query string.
any help is geartly appreciated.
thanks in advance :)
On your .NET application, encrypt all sensible data using a symmetric cipher (e.g. AES), then POST it to a JBOSS servlet. In that servlet, decrypt the transmitted data and store it in a session scoped bean. This way, you can subsequently access the data from your beans without needing to carry it aound in GET params.
I think you're looking for Pretty Faces ( http://ocpsoft.org/prettyfaces/ )

NS_ERROR_FAILURE with absent property

I trying to capture pageLoad event in progressListener, in onLocationChange i check URI of fresh page, and in case URI = about:blank i got
Error: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIURI.host]
As i understand this URI don't have host at all.
How can i check that host is available without raw parsing and exception catching? Is there any conventional way to check that atribute is present?
Your best bet is to filter certain protocols (filter on scheme). It's best to use a whitelist in this case of the protocols you care about.
In general there's no way to know for sure without doing a try/catch, but currently an nsIStandardURL is the only sort of URI that will have a host.
When I faced this problem my solution was:
To indicate an observer flag aWebProgress.NOTIFY_LOCATION
aWebProgress.addProgressListener(this.listener, aWebProgress.NOTIFY_LOCATION);
Before I had aWebProgress.NOTIFY_LOCATION and there was an exception you desc

is it bad form to have the colon in db and in the URL?

I am designing my namespace such that the id i am storing in the DB is
id -> "e:t:222"
where "e" represents the Event class, "t" represents the type
i am also expecting to use this id in my urls
url -> /events/t:222
Is there anything wrong with doing this?
Is there anything wrong with doing this?
Yes: The colon is a reserved character in URLs that has a special meaning, namely specifying the server port, in a URL.
Using it in other places in the URL is a bad idea.
You would need to URLEncode the colon in order to use it.
There is nothing wrong with doing this, you'll simply need to encode the URL properly. Most libraries with do this automatically for you.
In general though, if you care about your data you shouldn't let the application drive the data or database design. Exceptions to this are application centric databases that have no life outside of a single application nor do you expect to use the data anywhere else. In this case, you may want to stick with schemas and idioms that work best with your application.

Resources