Menu

Check and replace the attribute value using JS

 We can use JQuery to find the element and then we can replace the attribute value of an HTML element. Below is a JS code snippet to find and replace an attribute value.


$this.next().attr('aria-expanded', function(index, attr){

    return attr == 'false' ? 'true' : 'false';

});

Login into WinSCP using ssh key

Please follow the below steps to configure your WinSCP session using ssh(Secure Shell) key.

Create a new session in WinSCP. Select File Protocol and put Host name(IP address) and your ssh User name. Don't put anything in the Password field. Below is a screenshot for reference.


Click on Advanced, then go to SSH >> Authentication



In the Private key file area, click on the browse option and select your .ppk (private key) file. WinSCP accepts only ssh keys generated via Putty but if you generated your key using OpenSSH don't worry WinScp will automatically convert your file in the required format after showing you a warning message. 


For more, you could refer following documents

1. https://winscp.net/eng/docs/guide_public_key#winscp

2. https://docs.oracle.com/cd/E19509-01/820-3503/ggbgc/index.html

Bundle is NOT whitelisted in AEM

While using the loginAdministrative() method of SlingRepository class you might see an error "Bundle is not whitelisted". To get this method work we have to whitelist the bundle in OSGi configuration "Apache Sling Login Admin Whitelist" this helps us to defines which bundles can use SlingRepository.loginAdministrative().

Below is the code snippet of creating session using loginAdministartive method.

@Reference
private SlingRepository repository

Session session = repository.loginAdministrative(null);