Skip to content

Instantly share code, notes, and snippets.

View jpukg's full-sized avatar
🧭
Full Stack Developer (Java, Angular)

Jayaprakash (JP) jpukg

🧭
Full Stack Developer (Java, Angular)
View GitHub Profile
import java.io.StringWriter;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.util.JAXBSource;
import javax.xml.transform.Source;
@jpukg
jpukg / SpringAdLdapTest.java
Created October 6, 2016 21:09 — forked from mpilone/SpringAdLdapTest.java
A simple example of using Spring LDAP to authenticate a user against Active Directory.
// Setup the LDAP client (normally done via Spring context file).
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldap://adserver.mycompany.com:3268");
contextSource.setBase("DC=AD,DC=MYCOMPANY,DC=COM");
contextSource.setUserDn("[email protected]");
contextSource.setPassword("password1");
contextSource.afterPropertiesSet();
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.afterPropertiesSet();
@jpukg
jpukg / EmailServiceImpl.java
Created October 6, 2016 21:14 — forked from BenDol/EmailServiceImpl.java
The cyclic dependency issue with Spring 4 (worked fine in Spring 3)
@Service("emailService")
public class EmailServiceImpl extends MailServiceImpl implements EmailService, InitializingBean {
private static final long serialVersionUID = -7973057973637014852L;
private static final Logger logger = Logger.getLogger(EmailServiceImpl.class.getName());
@Autowired
private EntityMapperContext mapperContext;
<mule-ss:security-manager>
<mule-ss:delegate-security-provider name="security-provider" delegate-ref="ldap-authentication-manager" />
</mule-ss:security-manager>
<spring:beans>
<ss:authentication-manager id="ldap-authentication-manager" alias="ldapAuthManager">
<ss:authentication-provider ref="ldap-auth-provider" />
</ss:authentication-manager>
@jpukg
jpukg / httpUrlConnection.java
Created October 6, 2016 21:23
httpUrlconnection helper class
package com.example.ikram;
import android.util.Log;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
@jpukg
jpukg / Connect Url Proxy.md
Created October 6, 2016 21:25 — forked from aldoKelvianto/Connect Url Proxy.md
HttpUrlConnection with Proxy (and authentication) for Android

How to enable your app connected to internet using proxy. Note: this only works http, still working on https.

private String fetchUsingProxy() throws IOException {
    URL url = new URL("http://www.google.com");

    Authenticator authenticator = new Authenticator() {
        @Override
        protected PasswordAuthentication getPasswordAuthentication() {
@jpukg
jpukg / Base64Example.java
Created October 6, 2016 21:27 — forked from sunieldalal/Base64Example.java
Base64 username/pasword example
//Reference: http://ostermiller.org/utils/Base64.html
URL url = new URL("http://....");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty(
"Authorization",
"Basic " + Base64.encode(
username + ":" + password
)
);
InputStream in = connection.getInputStream();
package feedback.gusthavo;
import javax.servlet.http.HttpServlet;
import java.io.IOException;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
@jpukg
jpukg / gist:ad13bbb26bb36dc1d59cef0c016e7760
Created October 9, 2016 12:36 — forked from ajokela/gist:1846191
Decrypt passwords stored in Oracle SQL Developer.
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.*;
/**
* Decrypt passwords stored in Oracle SQL Developer.
* This is intended for password recovery.
*
* Passwords are stored in ~/.sqldeveloper/system2.1.1.64.39/o.jdeveloper.db.connection.11.1.1.2.36.55.30/connections.xml
*/
@jpukg
jpukg / UndertowServer.java
Created October 10, 2016 16:56 — forked from vmarcinko/UndertowServer.java
Undertow-Spring MVC integration
package vmarcinko.undertow;
import io.undertow.Handlers;
import io.undertow.Undertow;
import io.undertow.server.HttpHandler;
import io.undertow.server.handlers.PathHandler;
import io.undertow.server.handlers.RedirectHandler;
import io.undertow.server.handlers.resource.FileResourceManager;
import io.undertow.servlet.Servlets;
import io.undertow.servlet.api.DeploymentInfo;