Search in sources :

Example 1 with AMPropertySheetModel

use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.

the class TimeConditionHelper method getTime.

private boolean getTime(ConditionOpViewBeanBase viewBean, boolean bStart, Map values) {
    AMPropertySheetModel propModel = viewBean.getPropertySheetModel();
    boolean valid = false;
    String hours = (bStart) ? (String) propModel.getValue(STARTHOUR) : (String) propModel.getValue(ENDHOUR);
    String minutes = (bStart) ? (String) propModel.getValue(STARTMINUTE) : (String) propModel.getValue(ENDMINUTE);
    String session = (bStart) ? (String) propModel.getValue(STARTSESSION) : (String) propModel.getValue(ENDSESSION);
    hours = hours.trim();
    minutes = minutes.trim();
    if ((hours.length() > 0) && (minutes.length() > 0)) {
        try {
            int hr = Integer.parseInt(hours);
            int mm = Integer.parseInt(minutes);
            if (session.equals("pm") && (hr < 12)) {
                hr += 12;
            }
            if ((hr >= 0) && (hr <= 23) && (mm >= 0) && (mm <= 59)) {
                hours = (hr < 10) ? "0" + hr : Integer.toString(hr);
                minutes = (mm < 10) ? "0" + mm : Integer.toString(mm);
                Set set = new HashSet();
                set.add(hours + ":" + minutes);
                values.put((bStart) ? SimpleTimeCondition.START_TIME : SimpleTimeCondition.END_TIME, set);
                valid = true;
            } else {
                viewBean.setErrorMessage((bStart) ? "policy.condition.time.invalid.starttime" : "policy.condition.time.invalid.endtime");
            }
        } catch (NumberFormatException e) {
            viewBean.setErrorMessage((bStart) ? "policy.condition.time.invalid.starttime" : "policy.condition.time.invalid.endtime");
        }
    } else {
        valid = true;
    }
    return valid;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) HashSet(java.util.HashSet)

Example 2 with AMPropertySheetModel

use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.

the class TimeConditionHelper method getDay.

private void getDay(ConditionOpViewBeanBase viewBean, boolean bStart, Map values) {
    AMPropertySheetModel propModel = viewBean.getPropertySheetModel();
    String day = (bStart) ? (String) propModel.getValue(STARTDAY) : (String) propModel.getValue(ENDDAY);
    if (day.length() > 0) {
        Set set = new HashSet();
        set.add(day);
        values.put((bStart) ? SimpleTimeCondition.START_DAY : SimpleTimeCondition.END_DAY, set);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) HashSet(java.util.HashSet)

Example 3 with AMPropertySheetModel

use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.

the class TimeConditionHelper method setDate.

public void setDate(ConditionOpViewBeanBase viewBean, boolean bStart, String strDate, AMModel model) {
    TimeConditionHelper.DATE_FORMAT = model.getLocalizedString("policy.condition.time.dateformat");
    if (TimeConditionHelper.DATE_FORMAT == null || TimeConditionHelper.DATE_FORMAT.length() == 0)
        TimeConditionHelper.DATE_FORMAT = "MM/dd/yyyy";
    AMPropertySheetModel propModel = viewBean.getPropertySheetModel();
    propModel.setValue((bStart) ? STARTDATE : ENDDATE, formatDate(strDate));
}
Also used : AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel)

Example 4 with AMPropertySheetModel

use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.

the class TimeConditionHelper method getTimeZoneValue.

private boolean getTimeZoneValue(ConditionOpViewBeanBase viewBean, Map values) {
    boolean valid = false;
    AMPropertySheetModel propModel = viewBean.getPropertySheetModel();
    String radio = (String) propModel.getValue(RADIOTIMEZONE);
    if ((radio != null) && (radio.length() > 0)) {
        String tz = null;
        if (radio.equals("standard")) {
            tz = (String) propModel.getValue(STANDARDTIMEZONE);
            valid = true;
        } else {
            tz = (String) propModel.getValue(CUSTOMTIMEZONE);
            if (RFC_822_PATTERN.matcher(tz).matches()) {
                tz = getNormalizedTimeZone("GMT" + tz);
                valid = true;
            } else {
                valid = isValidTimeZone(tz);
            }
            if (!valid) {
                viewBean.setErrorMessage("policy.condition.time.invalid.timezone");
            }
        }
        if (valid) {
            Set set = new HashSet();
            set.add(tz);
            values.put(SimpleTimeCondition.ENFORCEMENT_TIME_ZONE, set);
        }
    } else {
        valid = true;
    }
    return valid;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) HashSet(java.util.HashSet)

Example 5 with AMPropertySheetModel

use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.

the class TimeConditionHelper method setDay.

public void setDay(ConditionOpViewBeanBase viewBean, boolean bStart, String strDay) {
    if ((strDay != null) && (strDay.length() > 0)) {
        AMPropertySheetModel propModel = viewBean.getPropertySheetModel();
        propModel.setValue((bStart) ? STARTDAY : ENDDAY, strDay);
    }
}
Also used : AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel)

Aggregations

AMPropertySheetModel (com.sun.identity.console.base.model.AMPropertySheetModel)146 DelegationConfig (com.sun.identity.console.delegation.model.DelegationConfig)32 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)16 CCAddRemoveModel (com.sun.web.ui.model.CCAddRemoveModel)9 InputStream (java.io.InputStream)8 HashSet (java.util.HashSet)7 Set (java.util.Set)7 Iterator (java.util.Iterator)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 CCEditableListModel (com.sun.web.ui.model.CCEditableListModel)3 List (java.util.List)3 ViewBean (com.iplanet.jato.view.ViewBean)2 AgentsModel (com.sun.identity.console.agentconfig.model.AgentsModel)2 AbstractAuditModel (com.sun.identity.console.audit.model.AbstractAuditModel)2 EntitiesModel (com.sun.identity.console.idm.model.EntitiesModel)2 RMRealmModel (com.sun.identity.console.realm.model.RMRealmModel)2 SubConfigModel (com.sun.identity.console.service.model.SubConfigModel)2 CCOrderedListModel (com.sun.identity.console.ui.model.CCOrderedListModel)2