I am using apache.commons.net.FTPClient to get some files from customers but I found that there is a ftpserver that doesn't process the command list as it should because it always return the current directory instead of the one that I indicate.
I found out that mlistFile (MLSD) works great on that machine!
My question is:
Is there any way to find out with apache.commons.net if there I should use the MLDS or LIST commnad?
Any flag or something like that?
Thanks
Here is what I found (maybe too late?): you can invoke the function listHelp() on a FTPClient object to get the commands recognized by the remote server. You get an output such as
214-The following commands are recognized.
ABOR ACCT ALLO APPE CDUP CWD DELE EPRT EPSV FEAT HELP LIST MDTM MKD
MODE NLST NOOP OPTS PASS PASV PORT PWD QUIT REIN REST RETR RMD RNFR
RNTO SITE SIZE SMNT STAT STOR STOU STRU SYST TYPE USER XCUP XCWD XMKD
XPWD XRMD
You just have to check if MLSD is in the list.
You can use "FEAT" command.
It shows commands you can use.
Related
I have a Hyperledger Fabric V1.0 network setup using Build Your First Network.
I have made the network up by running the command ./byfn.sh -m up.
Now all the Peers, Orderers and CAs(configured in docker-compose-e2e.yaml) are up and running.
This is my docker ps
And I am trying to connect to this network using fabric-sdk-java.
But when doing user registration using the following code
HFCAClient ca = sampleOrg.getCAClient();
final String orgName = sampleOrg.getName();
final String mspid = sampleOrg.getMSPID();
ca.setCryptoSuite(CryptoSuite.Factory.getCryptoSuite());
SampleUser admin = sampleStore.getMember("ädmin", orgName);
if (!admin.isEnrolled()) { //Preregistered admin only needs to be enrolled with Fabric caClient.
admin.setEnrollment(ca.enroll(admin.getName(), "adminpw"));
admin.setMspId(mspid);
}
sampleOrg.setAdmin(admin); // The admin of this org --
SampleUser user = sampleStore.getMember("user", sampleOrg.getName());
if (!user.isRegistered()) { // users need to be registered AND enrolled
RegistrationRequest rr = new RegistrationRequest(user.getName(), "org1.department1");
user.setEnrollmentSecret(ca.register(rr, admin// here comes the error
}
I am getting the error
2017-08-29 07:44:01,132 main ERROR HFCAClient:237 - com.test.blockchain.client.test.SampleUser#73846619
org.hyperledger.fabric_ca.sdk.exception.RegistrationException: Error while registering the user com.test.blockchain.client.test.SampleUser#73846619 url: https://192.168.99.100:7054 POST request to https://192.168.99.100:7054/api/v1/register failed request body {"id":"user1","type":"user","max_enrollments":0,"affiliation":"org1.department1","attrs":[]} with status code: 500. Response: {"success":false,"result":null,"errors":[{"code":0,"message":"Failed getting affiliation 'org1.department1': sql: no rows in result set"}],"messages":[]}
at org.hyperledger.fabric_ca.sdk.HFCAClient.register(HFCAClient.java:236)
at com.test.blockchain.client.test.Test.setup(Test.java:164)
at com.test.blockchain.client.test.Test.main(Test.java:982)
Caused by: java.lang.Exception: POST request to https://192.168.99.100:7054/api/v1/register failed request body {"id":"user1","type":"user","max_enrollments":0,"affiliation":"org1.department1","attrs":[]} with status code: 500. Response: {"success":false,"result":null,"errors":[{"code":0,"message":"Failed getting affiliation 'org1.department1': sql: no rows in result set"}],"messages":[]}
at org.hyperledger.fabric_ca.sdk.HFCAClient.httpPost(HFCAClient.java:609)
at org.hyperledger.fabric_ca.sdk.HFCAClient.register(HFCAClient.java:227)
... 2 more
I am referring the codes shown in the unit test class End2endIT.java
Someone please share your knowledge to find out where I am doing wrong.
Also I am not sure where it is configuring "affiliation":"org1.department1". Do I need to add anything in my .yaml file?
These are the affiliation which are bootstrapped for the any CA containers
> affiliations:
> org1:
> - department1
> - department2
> org2:
> - department1
But there function though which you can add New affiliation based on your organization
await caClient.newAffiliationService().create({ "name": "AFFILIATION_NAME }, adminObj)
You configure the affiliation when you create the crypto material. In your case when you generate the ./byfn.sh -m up command. You have created your keys (your certificates) when you executed the ./byfn.sh -m up, so you don't need to call the CA to register any user.
Also, your error code is the 500, so the cause of your error should be other. Could you try to invoke the chaincode?
Have you changed something in the crypto-config.yaml file? And in the docker-compose-e2e.yaml file?
I'm not sure about the error you are getting for org1.department1. But even I had faced this similar issue while creating new org3. I was getting error Failed getting affiliation 'org3.department1': : scode: 404, code: 63, msg: Failed to get Affiliation: sql: no rows in result set.
To answer where the setting of the Affiliation happens.
It is bootstrapped, which is defined the file /etc/hyperledger/fabric-ca-server/fabric-ca-client-config.yaml of CA Docker container
affiliations:
org1:
- department1
- department2
org2:
- department1
Link to the file : http://hyperledger-fabric-ca.readthedocs.io/en/latest/serverconfig.html
In line:
SampleUser admin = sampleStore.getMember("ädmin", orgName);
you may have to replace the ä in "ädmin".
I am using Alfresco community edition-5.1.x set up SMTP configuration in my production server whenever user doing activity in alfresco user get notifications mail, We able to get all the information but in the mail notification mail down alfresco url is there with my domain name (i.e http://mydomainxx.com:5038) when click the link not working browser because its wrong url how can i change to (http://mydomainxx.com) only domainname not with port number , I am stuck on that any can help out.
You should change the default alfresco-global.properties:
alfresco.context=alfresco
alfresco.host=127.0.0.1
alfresco.port=8080
alfresco.protocol=http
share.context=share
share.host=127.0.0.1
share.port=8080
share.protocol=http
In your case just changing the port to 80 would be sufficient.
There's a couple of places mentioned here that you could try out (haven't tried them myself). If that proves to not work, IMHO the easiest way is to simply change the notification FTL's with the URL you want (found at "Company Home/Data Dictionary/Email Templates").
However, it is not the cleanest one, so decide for yourself whether you want to take that route.
Hope this helps someone.
#
# URL Parameters(SSL)
# -------------------------
alfresco.context=alfresco
alfresco.host=yourdomain.com
alfresco.port=443
alfresco.protocol=https
share.context=share
share.host=yourdomain.com
share.port=443
share.protocol=https
## Non-ssl
alfresco.context=alfresco
alfresco.host=yourdomain.com
alfresco.port=8080
#<YOUR_PORT_NUMBER>
alfresco.protocol=http
share.context=share
share.host=yourdomain.com
share.port=8080
#<YOUR_PORT_NUMBER>
share.protocol=http
I looked for how to do IP lookup in Java on Stack Overflow but the answers match what I am already doing and do not resolve my problem.
Here is my code:
public void printHostname( String ip ) {
System.out.println( InetAddresses.forString( ip ).getCanonicalHostName( ) );
}
InetAddresses is just a utility class from guava library to get a InetAdress.
The problem: This code works as expected with some IP adresses and not with some others.
A working example
For example, for IP 157.55.39.29, the output is:
msnbot-157-55-39-29.search.msn.com
This result seems correct according to Linux host command:
> host 157.55.39.29
29.39.55.157.in-addr.arpa domain name pointer msnbot-157-55-39-29.search.msn.com.
A not working example
For IP 123.125.71.75, the host command returns:
> host 123.125.71.75
75.71.125.123.in-addr.arpa domain name pointer baiduspider-123-125-71-75.crawl.baidu.com.
But the output of my Java code is:
123.125.71.75
whereas the expected output should be
baiduspider-123-125-71-75.crawl.baidu.com
The javadoc of getCanonicalHostName method says:
Returns:
the fully qualified domain name for this IP address, or if the operation is not allowed by the security check, the textual representation of the IP address.
but I’m pretty sure it's not really a problem with a security check... or I don't understand what is wrong.
Have you any suggestion to explain this behaviour? Do you have a workaround?
EDIT #1
When looking for a solution, I tried to step debug the implementation in JDK:
// first lookup the hostname
host = nameService.getHostByAddr(addr.getAddress());
/* check to see if calling code is allowed to know
* the hostname for this IP address, ie, connect to the host
*/
if (check) {
SecurityManager sec = System.getSecurityManager();
if (sec != null) {
sec.checkConnect(host, -1);
}
}
/* now get all the IP addresses for this hostname,
* and make sure one of them matches the original IP
* address. We do this to try and prevent spoofing.
*/
InetAddress[] arr = InetAddress.getAllByName0(host, check);
In this code, variable host contains the correct value, but the last statement calling getAllByName0 throws an UnknownHostException which is handled by returning just the requested IP. The exception is thrown by internal method getAddressesFromNameServicewith message:
"java.net.UnknownHostException: baiduspider-123-125-71-75.crawl.baidu.com"
I don't know why.
Can I get the host variable value, bypassing the internal exception?
The problem lies in the fact that the java.net.InetAdress has a certain procedure against ip-spoofing.
It first resolves the name into (an) ip address(es). This works fine.
In your case the result are two IP adresses. InetAdress then checks back if (at least one of) these adresses resolve to the original input name.
If they do not, it just returns the original ip adress. The following picture shows the situation after the check for baiduspider-123-125-71-75.crawl.baidu.com
Note: The ip adresses resolved by getAllByName0 are the same as via nslookup, namely:
nslookup baiduspider-123-125-71-75.crawl.baidu.com
Server: 192.168.2.1
Address: 192.168.2.1#53
Non-authoritative answer:
Name: baiduspider-123-125-71-75.crawl.baidu.com
Address: 62.157.140.133
Name: baiduspider-123-125-71-75.crawl.baidu.com
Address: 80.156.86.78
A solution would be to use the dnsjava library. It skips the spoofing check and therefore works fine.
dnsjava example:
String addr = Address.getHostName(InetAddress.getByName("123.125.71.75"));
outputs just as expected baiduspider-123-125-71-75.crawl.baidu.com
Disclaimer: As i am a Java developer and not a security expert, i am not totally aware of the security implications of using a spoofed ip address.
I did not dig a lot into this so I don't know why it is happening, but some online tools (like this one) that checks the health of DNS servers indicates that they have some issues which may or may not be related.
As #jah said, Java tries to double check to see if the hostname has the ip it said it has. The exception is thrown on the native code while trying to do that. In fact, in my case, trying to verify on the command line, the nslookup fails to get the ip from the name, which indicates some configuration preventing this on the DNS Server (maybe on purpose? I'm no expert in DNS either).
When it works:
$ nslookup msnbot-157-55-39-29.search.msn.com
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
Name: msnbot-157-55-39-29.search.msn.com
Address: 157.55.39.29
When it doesnt work:
$ nslookup baiduspider-123-125-71-75.crawl.baidu.com
Server: 192.168.1.1
Address: 192.168.1.1#53
** server can't find baiduspider-123-125-71-75.crawl.baidu.com: NXDOMAIN
When it works:
$ getent hosts msnbot-157-55-39-29.search.msn.com
157.55.39.29 msnbot-157-55-39-29.search.msn.com
When it doesn't:
$ getent hosts baiduspider-123-125-71-75.crawl.baidu.com
$
As an alternative, you can use a DNS Service Provider for JNDI. The documentation has an example, but I'll leave a working snippet for you to test:
String[] octets = "123.125.71.75".split("\\.");
String host = String.join(".", octets[3], octets[2], octets[1], octets[0], "in-addr.arpa");
Properties props = new Properties();
props.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
DirContext dirContext = new InitialDirContext(props);
Attributes attrs = dirContext.getAttributes(host, new String[] {"PTR"});
System.out.println(attrs.get("PTR").get());
How do I SCP a file from a RHEL linux box to another RHEL linux box without the password and without the username using URIs in Java using SCPClient? I know how to do a passwordless ssh, and I can SCP a file without the password, but I'm having trouble getting it to work without the username.
Here's my guess:
Source: file:///home/username/temp.txt
Destination: scp://#192.168.1.1:/home/username/
Have you tried scp://username#192.168.1.1:/home/username/ ?
Based off of the SCPClient page I'm going to say that it's not possible. So, the best method is to do
SCPClient scpc = new SCPClient
scpc.setRemoteHost( "192.168.1.1" );
scpc.getValidator().setHostValidationEnabled( false );
scpc.setAuthentication( "/home/username/.ssh/id_rsa", System.getProperty("user.name"), "" );
scpc.connect();
scpc.put( "file:///home/username/temp.txt", "scp://" + System.getProperty("user.name") + "#192.168.1.1:/home/username/" );
For my purpose its safe to assume the remote username is the same as the local username.
I am in need to somehow display image on Linux console. Why am I need it?
I need to manually enter CAPTCHA code. However my application runs on remote linux system and I am connecting to it via SSH (Bitwise client). I have thought about writing directly to screen, but hey - I see only "clone" of terminal not the remote terminal itself so this is impossible to achieve. Maybe some kind of Img2Asci converter? Please advise.
You want to forward your X session.
on the remote system make sure xauth is installed.
on the client system make sure an X client is installed (Xming for windows)
Connect with ssh -X from a command line or with putty enable X forwarding.
You can then either use display filename or most applications that so that sort of thing will pop up if a display is detected
Assuming you can't forward your X session, perhaps something like jp2a, which converts JPEG to ASCII ?
convert http://www.google.com/intl/en/images/logo.gif jpg:- | jp2a -
....... .':.
.::'....':xd. dX'
.ld. .. . oX. ...
;O' .c;..'cxc ;,...,c;. .:'.,lxc. dX. ,:'.,dx.. .
oO. .ox. ,x0 .cd. .cd..ll l0. xX. :K,..,::.
cxx. .',cl 'x0 lK'.cx ;k, lO; .ll. dX. o0:
,dkc. :kd :kx. :d; ,ol. .lc. .''lk' kX' oOo'...
.;:cc;,,',,. .;;,'.. .,,'... ''',:lxo. .','. .,::;.
.oc. dO
lk;....'c'
.'....