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); } }
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; }
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"); }
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); } }
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; }
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; }
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); } }
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; }
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); } }
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); } }
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); } }
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(); }
/** * 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); } }
@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); } }