Package hirondelle.web4j.security

Examples of hirondelle.web4j.security.SafeText


  private void testEqualsFor(Visit aVisit, String aId, String aRestoId, Date aDate, String aComment) {
    Visit testVisit = null;
    Id visitId = (aId != null ? Id.from(aId) : null);
    try {
      testVisit = new Visit(visitId, Id.from(aRestoId), aDate, new SafeText(aComment));
    }
    catch (ModelCtorException ex) {
      throw new RuntimeException(ex);
    }
    // log("aVisit: " + aVisit);
View Full Code Here


  private void testNotEqualsFor(Visit aVisit, String aId, String aRestoId, Date aDate,
  String aComment) {
    Visit testVisit = null;
    Id visitId = (aId != null ? Id.from(aId) : null);
    try {
      testVisit = new Visit(visitId, Id.from(aRestoId), aDate, new SafeText(aComment));
    }
    catch (ModelCtorException ex) {
      throw new RuntimeException(ex);
    }
    // log("A: " + aVisit);
View Full Code Here

  }

  /** Create a {@link User} from user input. */
  protected void validateUserInput() {
    try {
      SafeText userName = getParam(USER_NAME);
      fUser = User.forNewUserOrPasswordReset(userName);
    }
    catch (ModelCtorException ex){
      addError(ex);
    }   
View Full Code Here

    throw new UnsupportedOperationException();
  }
 
  /** Fetch a {@link UserRole}, in preparation for editing it. */
  protected void attemptFetchForChange() throws DAOException {
    SafeText name = getParam(NAME);
    UserRole userRole = fRoleDAO.fetch(name);
    if( userRole == null ){
      addError("Item no longer exists. Likely deleted by another user.");
    }
    else {
View Full Code Here

  @Override public ResponsePage execute() throws AppException {
    ResponsePage result = getResponsePage();
    List<Prediction> predictions = fDAO.list(getIdParam(LIST_ID));
    if( ! predictions.isEmpty() ) {
      addToRequest(ITEMS_FOR_LISTING, predictions);
      SafeText title = getPredictionListTitle();
      addToRequest("title", title);
      addToRequest("averageScore", Prediction.calculateAverageScore(predictions));
      result = getResponse(title.getRawString());
    }
    else {
      //if user puts in an arbitrary list id, it will likely not exist
      addMessage("No list of predictions found.");
    }
View Full Code Here

    return TemplatedPage.get(aTitle, "view.jsp", ViewPublicListAction.class);   
  }

  private SafeText getPredictionListTitle() throws DAOException {
    PredictionList list = fetchPredictionList();
    SafeText ownerScreenName = list.getUserScreenName();
    SafeText title = fetchPredictionList().getTitle();
    return SafeText.from(ownerScreenName.getRawString() + " - " + title.getRawString());
  }
View Full Code Here

  }
 
  public void reactToUserLogin(HttpSession aSession, HttpServletRequest aRequest) throws AppException {
    //SafeText is used here to avoid using String
    //AllowStringAsBuildingBlock is set to NO in web.xml
    SafeText userName = SafeText.from(aRequest.getUserPrincipal().getName());
    fLogger.fine("Adding user preferences to session, for principal name:" + userName);
    PreferencesDAO dao  = new PreferencesDAO();
    try {
      Preferences prefs = dao.fetch(userName);
      fLogger.fine("Adding user id and screen name to session");
View Full Code Here

   */
  public Integer getOutcomeScore() {
    Integer result = null;
    if (fOutcome != null) {
      //Undecidable items will have the short text as null
      SafeText value = fOutcome.getShortText();
      if( value != null ) {
        result = Integer.valueOf(value.getRawString());
      }
    }
    return result;
  }
View Full Code Here

      result = id.getRawString();
    }
    else if ( aObject instanceof SafeText ) {
      //The Populate tag will safely escape all such text data.
      //To avoid double escaping, the raw form is returned.
      SafeText safeText = (SafeText)aObject;
      result = safeText.getRawString();
    }
    else {
      result = aObject.toString();
    }
    return result;
View Full Code Here

      result = null;
    }
    else if (aObject instanceof SafeText){
      //it is odd to extract an identical object like this,
      //but it safely avoids double escaping at the end of this method
      SafeText text = (SafeText) aObject;
      result = text.getRawString();
    }
    else if (aObject instanceof Id){
      Id id = (Id) aObject;
      result = id.getRawString();
    }
    else if (aObject instanceof Code){
      Code code = (Code) aObject;
      result = code.getText().getRawString();
    }
    else if (aObject instanceof String) {
      result = aObject.toString();
    }
    else if ( aObject instanceof DateTime ){
      DateTime dateTime = (DateTime)aObject;
      result = fDateConverter.formatEyeFriendlyDateTime(dateTime, fLocale);
    }
    else if ( aObject instanceof Date ){
      Date date = (Date)aObject;
      result = fDateConverter.formatEyeFriendly(date, fLocale, fTimeZone);
    }
    else if ( aObject instanceof BigDecimal ){
      BigDecimal amount = (BigDecimal)aObject;
      result = getBigDecimalDisplayFormat().format(amount.doubleValue());
    }
    else if ( aObject instanceof Decimal ){
      Decimal money = (Decimal)aObject;
      result = getBigDecimalDisplayFormat().format(money.getAmount().doubleValue());
    }
    else if ( aObject instanceof Boolean ){
      Boolean value = (Boolean)aObject;
      result = getBooleanDisplayText(value);
    }
    else if ( aObject instanceof Integer ) {
      Integer value = (Integer)aObject;
      result = getIntegerReportDisplayFormat().format(value);
    }
    else if ( aObject instanceof Long ) {
      Long value = (Long)aObject;
      result = getIntegerReportDisplayFormat().format(value.longValue());
    }
    else if ( aObject instanceof Locale ) {
      Locale locale = (Locale)aObject;
      result = locale.getDisplayName(fLocale);
    }
    else if ( aObject instanceof TimeZone ) {
      TimeZone timeZone = (TimeZone)aObject;
      result = timeZone.getDisplayName(false, TimeZone.SHORT, fLocale);
    }
    else {
      result = aObject.toString();
    }
    //ensure that all empty results have configured content
    if ( ! Util.textHasContent(result) ) {
      result = fEmptyOrNullText;
    }
    return new SafeText(result);
  }
View Full Code Here

TOP

Related Classes of hirondelle.web4j.security.SafeText

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.