本文整理汇总了Java中javax.security.sasl.AuthenticationException类的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationException类的具体用法?Java AuthenticationException怎么用?Java AuthenticationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthenticationException类属于javax.security.sasl包,在下文中一共展示了AuthenticationException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logout
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
private synchronized void logout() throws AuthenticationException
{
try
{
synchronized(lock_logged_in){
if(!logged_in)
throw new IllegalStateException("Not logged in.");
rooms.forEach(this::leaveRoom);
//leaveRoom(rooms.toArray(new Long[0]));
String response_text = GET("https://stackoverflow.com/users/logout");
String fkey = search(fkeyHtmlRegex, response_text);
POST(protocol+"://stackoverflow.com/users/logout", urlencode(new String[][]{
{"fkey", fkey},
{"returnUrl", "https%3A%2F%2Fstackoverflow.com%2F"}
}));
logged_in=false;
}
}
catch(Exception e)
{
throw new AuthenticationException("Failed to logout", e);
}
}
示例2: response
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
private byte[] response() throws SaslException
{
if (! AnonymousUtil.isValidTraceInformation(authorizationID))
throw new AuthenticationException(
"Authorisation ID is not a valid email address");
complete = true;
final byte[] result;
try
{
result = authorizationID.getBytes("UTF-8");
}
catch (UnsupportedEncodingException x)
{
throw new AuthenticationException("response()", x);
}
return result;
}
示例3: evaluateResponse
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
public byte[] evaluateResponse(final byte[] response) throws SaslException
{
if (response == null)
return null;
try
{
authorizationID = new String(response, "UTF-8");
}
catch (UnsupportedEncodingException x)
{
throw new AuthenticationException("evaluateResponse()", x);
}
if (AnonymousUtil.isValidTraceInformation(authorizationID))
{
this.complete = true;
return null;
}
authorizationID = null;
throw new AuthenticationException("Invalid email address");
}
示例4: activate
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
public void activate(Map context) throws AuthenticationException
{
try
{
if (context == null)
passwordFile = new PasswordFile();
else
{
passwordFile = (PasswordFile) context.get(SRPRegistry.PASSWORD_DB);
if (passwordFile == null)
{
String pfn = (String) context.get(SRPRegistry.PASSWORD_FILE);
if (pfn == null)
passwordFile = new PasswordFile();
else
passwordFile = new PasswordFile(pfn);
}
}
}
catch (IOException x)
{
throw new AuthenticationException("activate()", x);
}
}
示例5: contains
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
public boolean contains(String userName) throws AuthenticationException
{
if (passwordFile == null)
throw new AuthenticationException("contains()",
new IllegalStateException());
boolean result = false;
try
{
result = passwordFile.contains(userName);
}
catch (IOException x)
{
throw new AuthenticationException("contains()", x);
}
return result;
}
示例6: lookup
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
public Map lookup(Map userID) throws AuthenticationException
{
if (passwordFile == null)
throw new AuthenticationException("lookup()", new IllegalStateException());
Map result = new HashMap();
try
{
String userName = (String) userID.get(Registry.SASL_USERNAME);
if (userName == null)
throw new NoSuchUserException("");
String mdName = (String) userID.get(SRPRegistry.MD_NAME_FIELD);
String[] data = passwordFile.lookup(userName, mdName);
result.put(SRPRegistry.USER_VERIFIER_FIELD, data[0]);
result.put(SRPRegistry.SALT_FIELD, data[1]);
result.put(SRPRegistry.CONFIG_NDX_FIELD, data[2]);
}
catch (Exception x)
{
if (x instanceof AuthenticationException)
throw (AuthenticationException) x;
throw new AuthenticationException("lookup()", x);
}
return result;
}
示例7: update
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
public void update(Map userCredentials) throws AuthenticationException
{
if (passwordFile == null)
throw new AuthenticationException("update()", new IllegalStateException());
try
{
String userName = (String) userCredentials.get(Registry.SASL_USERNAME);
String password = (String) userCredentials.get(Registry.SASL_PASSWORD);
String salt = (String) userCredentials.get(SRPRegistry.SALT_FIELD);
String config = (String) userCredentials.get(SRPRegistry.CONFIG_NDX_FIELD);
if (salt == null || config == null)
passwordFile.changePasswd(userName, password);
else
passwordFile.add(userName, password, Util.fromBase64(salt), config);
}
catch (Exception x)
{
if (x instanceof AuthenticationException)
throw (AuthenticationException) x;
throw new AuthenticationException("update()", x);
}
}
示例8: getConfiguration
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
public Map getConfiguration(String mode) throws AuthenticationException
{
if (passwordFile == null)
throw new AuthenticationException("getConfiguration()",
new IllegalStateException());
Map result = new HashMap();
try
{
String[] data = passwordFile.lookupConfig(mode);
result.put(SRPRegistry.SHARED_MODULUS, data[0]);
result.put(SRPRegistry.FIELD_GENERATOR, data[1]);
}
catch (Exception x)
{
if (x instanceof AuthenticationException)
throw (AuthenticationException) x;
throw new AuthenticationException("getConfiguration()", x);
}
return result;
}
示例9: activate
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
public void activate(Map context) throws AuthenticationException
{
try
{
if (context == null)
passwordFile = new PasswordFile();
else
{
String pfn = (String) context.get(CramMD5Registry.PASSWORD_FILE);
if (pfn == null)
passwordFile = new PasswordFile();
else
passwordFile = new PasswordFile(pfn);
}
}
catch (IOException x)
{
throw new AuthenticationException("activate()", x);
}
}
示例10: lookupPassword
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
private char[] lookupPassword(final String userName) throws SaslException
{
try
{
if (! authenticator.contains(userName))
throw new NoSuchUserException(userName);
final Map userID = new HashMap();
userID.put(Registry.SASL_USERNAME, userName);
final Map credentials = authenticator.lookup(userID);
final String password = (String) credentials.get(Registry.SASL_PASSWORD);
if (password == null)
throw new AuthenticationException("lookupPassword()",
new InternalError());
return password.toCharArray();
}
catch (IOException x)
{
if (x instanceof SaslException)
throw (SaslException) x;
throw new AuthenticationException("lookupPassword()", x);
}
}
示例11: activate
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
public void activate(Map context) throws AuthenticationException
{
try
{
if (context == null)
passwordFile = new PasswordFile();
else
{
String pfn = (String) context.get(PASSWORD_FILE);
if (pfn == null)
passwordFile = new PasswordFile();
else
passwordFile = new PasswordFile(pfn);
}
}
catch (IOException x)
{
throw new AuthenticationException("activate()", x);
}
}
示例12: publish
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
public static void publish(String protocol, String host, String port, String username, String password,
String streamId,String dataFileName, String testCaseFolderName, StreamDefinition streamDefinition,
int events, int delay) throws MalformedStreamDefinitionException,
StreamDefinitionException, DifferentStreamDefinitionAlreadyDefinedException,
MalformedURLException, NoStreamDefinitionExistException, AuthenticationException,
TransportException, SocketException, DataEndpointAgentConfigurationException, DataEndpointException,
DataEndpointAuthenticationException, DataEndpointConfigurationException {
String relativeFilePath = getTestDataFileLocation(testCaseFolderName, dataFileName);
KeyStoreUtil.setTrustStoreParams();
//create data publisher
DataPublisher dataPublisher = new DataPublisher(protocol, "tcp://" + host + ":" + port, null, username,
password);
//Publish event for a valid stream
publishEvents(dataPublisher, streamDefinition, relativeFilePath, events, delay);
dataPublisher.shutdown();
}
示例13: getJEVisClass
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
/**
* Returns the requested JEVisClass
*
* @param httpHeaders
* @param context
* @param name
* @return
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{name}")
public Response getJEVisClass(
@Context HttpHeaders httpHeaders,
@PathParam("name") String name) {
JEVisDataSource ds = null;
try {
Logger.getLogger(ResourceClasses.class.getName()).log(Level.INFO, "GET Class: " + name);
ds = Config.getJEVisDS(httpHeaders);
JEVisClass jclass = ds.getJEVisClass(name);
return Response.ok(JsonFactory.buildJEVisClass(jclass)).build();
} catch (JEVisException jex) {
logger.catching(jex);
return Response.serverError().build();
} catch (AuthenticationException ex) {
return Response.status(Response.Status.UNAUTHORIZED).entity(ex.getMessage()).build();
} finally {
Config.CloseDS(ds);
}
}
示例14: get
import javax.security.sasl.AuthenticationException; //导入依赖的package包/类
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response get(
@Context HttpHeaders httpHeaders) {
JEVisDataSource ds = null;
try {
logger.debug("getCurrent User");
ds = Config.getJEVisDS(httpHeaders);
JEVisUser user = ds.getCurrentUser();
logger.debug("User: {}", user.getAccountName());
JsonObject json = JsonFactory.buildObject(user.getUserObject(), false);
logger.debug("User.json.id: {}", json.getId());
return Response.ok(json).build();
} catch (JEVisException jex) {
logger.catching(jex);
return Response.serverError().build();
} catch (AuthenticationException ex) {
return Response.status(Response.Status.UNAUTHORIZED).entity(ex.getMessage()).build();
} finally {
Config.CloseDS(ds);
}
}