Skip to content

Instantly share code, notes, and snippets.

@andyczerwonka
Created December 26, 2015 16:42
Show Gist options
  • Save andyczerwonka/13627d2da573cd9155ea to your computer and use it in GitHub Desktop.
Save andyczerwonka/13627d2da573cd9155ea to your computer and use it in GitHub Desktop.
This is the provider implementation that is working under Windows, but not under Linux.
// (c) Copyright 3ES Innovation Inc. 2013. All rights reserved.
package jespa.http;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jespa.security.Account;
import jespa.security.Properties;
import jespa.security.SecurityProvider;
import jespa.security.SecurityProviderException;
/**
* MockSecurityProvider authenicates each request successfully.
* The username is always "mock".
*
* If you want to use this security provider put following property line in your jespa_ntlm.prp file:
*
* provider.classname=jespa.http.MockSecurityProvider
*
*/
public class MockSecurityProvider extends SecurityProvider {
private static final long serialVersionUID = 1L;
private static final Logger _LOGGER = LoggerFactory.getLogger(MockSecurityProvider.class);
public MockSecurityProvider(@SuppressWarnings("rawtypes") Map properties) throws SecurityProviderException {
super(properties);
setFlag("capabilities.accept.ntlmssp", true);
setFlag("flags.capabilities.accept.spnego", true);
this.identity = "Mock";
this.isComplete = true;
}
@Override
public Account getAccount(String acctname, String[] attrs) throws SecurityProviderException {
return new MockAccount();
}
@Override
public void authenticate(Object credential) throws SecurityProviderException {
// do nothing
}
@Override
public byte[] initSecContext(byte[] token, int off, int len) throws SecurityProviderException {
return null;
}
@Override
public byte[] acceptSecContext(byte[] token, int off, int len) throws SecurityProviderException {
return null;
}
public static class MockAccount extends Properties implements Account {
private static final long serialVersionUID = 1L;
@Override
public void changePassword(char[] arg0, char[] arg1) throws SecurityProviderException {
throw new SecurityProviderException(0, "Not implemented");
}
@Override
public void create() throws SecurityProviderException {
throw new SecurityProviderException(0, "Not implemented");
}
@Override
public void create(String[] arg0) throws SecurityProviderException {
throw new SecurityProviderException(0, "Not implemented");
}
@Override
public void delete() throws SecurityProviderException {
throw new SecurityProviderException(0, "Not implemented");
}
@Override
public boolean isMemberOf(String arg0) throws SecurityProviderException {
_LOGGER.debug("Mock isMemberOf " + arg0);
return true;
}
@Override
public void setPassword(char[] arg0) throws SecurityProviderException {
throw new SecurityProviderException(0, "Not implemented");
}
@Override
public void update() throws SecurityProviderException {
throw new SecurityProviderException(0, "Not implemented");
}
@Override
public void update(String[] arg0) throws SecurityProviderException {
throw new SecurityProviderException(0, "Not implemented");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment