Example usage for org.apache.http.impl.auth NTLMEngineException NTLMEngineException

List of usage examples for org.apache.http.impl.auth NTLMEngineException NTLMEngineException

Introduction

In this page you can find the example usage for org.apache.http.impl.auth NTLMEngineException NTLMEngineException.

Prototype

public NTLMEngineException(final String message) 

Source Link

Document

Creates a new NTLMEngineException with the specified message.

Usage

From source file:com.anaplan.client.transport.JCIFSEngine.java

/** {@inheritDoc} */
@Override// ww w. j  ava 2 s.com
public String generateType3Msg(String username, String password, String domain, String workstation,
        String challenge) throws NTLMEngineException {
    if (domain == null) {
        throw new NTLMEngineException("Domain must be specified with user name");
    }
    try {
        byte[] byteArray = (byte[]) BASE64.getMethod("decode", String.class).invoke(null, challenge);
        Object type2Message = TYPE_2_MESSAGE.getConstructor(byteArray.getClass()).newInstance(byteArray);
        Integer type2Flags = (Integer) TYPE_2_MESSAGE.getMethod("getFlags").invoke(type2Message);
        int type3Flags = type2Flags & (0xffffffff ^ (NTLMSSP_TARGET_TYPE_DOMAIN | NTLMSSP_TARGET_TYPE_SERVER));
        Object type3Message = TYPE_3_MESSAGE
                .getConstructor(TYPE_2_MESSAGE, String.class, String.class, String.class, String.class,
                        Integer.TYPE)
                .newInstance(type2Message, password, domain, username, workstation, type3Flags);
        byte[] type3ByteArray = (byte[]) TYPE_3_MESSAGE.getMethod("toByteArray").invoke(type3Message);
        return (String) BASE64.getMethod("encode", type3ByteArray.getClass()).invoke(null, type3ByteArray);
    } catch (Exception thrown) {
        throw new NTLMEngineException("Failed to generate NTLM type 3 message", thrown);
    }
}

From source file:be.nabu.libs.http.client.ntlm.NTLMEngineImpl.java

private static int readULong(final byte[] src, final int index) throws NTLMEngineException {
    if (src.length < index + 4) {
        throw new NTLMEngineException("NTLM authentication - buffer too small for DWORD");
    }/*from w  w  w. j  ava2s.  co  m*/
    return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8) | ((src[index + 2] & 0xff) << 16)
            | ((src[index + 3] & 0xff) << 24);
}

From source file:be.nabu.libs.http.client.ntlm.NTLMEngineImpl.java

private static int readUShort(final byte[] src, final int index) throws NTLMEngineException {
    if (src.length < index + 2) {
        throw new NTLMEngineException("NTLM authentication - buffer too small for WORD");
    }//from   ww  w  .ja v  a  2 s .  co  m
    return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8);
}

From source file:be.nabu.libs.http.client.ntlm.NTLMEngineImpl.java

private static byte[] readSecurityBuffer(final byte[] src, final int index) throws NTLMEngineException {
    final int length = readUShort(src, index);
    final int offset = readULong(src, index + 4);
    if (src.length < offset + length) {
        throw new NTLMEngineException("NTLM authentication - buffer too small for data item");
    }//from  w  w  w .  j  av  a2s.  c  om
    final byte[] buffer = new byte[length];
    System.arraycopy(src, offset, buffer, 0, length);
    return buffer;
}

From source file:be.nabu.libs.http.client.ntlm.NTLMEngineImpl.java

/** Calculate a challenge block */
private static byte[] makeRandomChallenge() throws NTLMEngineException {
    if (RND_GEN == null) {
        throw new NTLMEngineException("Random generator not available");
    }//from  ww  w .  j a v a  2  s.  c  o  m
    final byte[] rval = new byte[8];
    synchronized (RND_GEN) {
        RND_GEN.nextBytes(rval);
    }
    return rval;
}

From source file:be.nabu.libs.http.client.ntlm.NTLMEngineImpl.java

/** Calculate a 16-byte secondary key */
private static byte[] makeSecondaryKey() throws NTLMEngineException {
    if (RND_GEN == null) {
        throw new NTLMEngineException("Random generator not available");
    }/*ww w . jav  a2s. c  om*/
    final byte[] rval = new byte[16];
    synchronized (RND_GEN) {
        RND_GEN.nextBytes(rval);
    }
    return rval;
}

From source file:trendmicro.okhttpntlm.NTLMEngineImpl.java

private static int readULong(byte[] src, int index) throws NTLMEngineException {
    if (src.length < index + 4)
        throw new NTLMEngineException("NTLM authentication - buffer too small for DWORD");
    return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8) | ((src[index + 2] & 0xff) << 16)
            | ((src[index + 3] & 0xff) << 24);
}

From source file:trendmicro.okhttpntlm.NTLMEngineImpl.java

private static int readUShort(byte[] src, int index) throws NTLMEngineException {
    if (src.length < index + 2)
        throw new NTLMEngineException("NTLM authentication - buffer too small for WORD");
    return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8);
}

From source file:trendmicro.okhttpntlm.NTLMEngineImpl.java

private static byte[] readSecurityBuffer(byte[] src, int index) throws NTLMEngineException {
    int length = readUShort(src, index);
    int offset = readULong(src, index + 4);
    if (src.length < offset + length)
        throw new NTLMEngineException("NTLM authentication - buffer too small for data item");
    byte[] buffer = new byte[length];
    System.arraycopy(src, offset, buffer, 0, length);
    return buffer;
}

From source file:trendmicro.okhttpntlm.NTLMEngineImpl.java

/** Calculate a challenge block */
private static byte[] makeRandomChallenge() throws NTLMEngineException {
    if (RND_GEN == null) {
        throw new NTLMEngineException("Random generator not available");
    }/*from  w w w  . ja  v  a 2s  . c  om*/
    byte[] rval = new byte[8];
    synchronized (RND_GEN) {
        RND_GEN.nextBytes(rval);
    }
    return rval;
}