Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ public class TokenServiceConfiguration {
@Value("${cosmo.tickets.serverInteger}")
private Integer serverInteger;


@Bean
public TokenService getTokenService() {
KeyBasedPersistenceTokenService keyBasedPersistenceTokenService = new KeyBasedPersistenceTokenService();
keyBasedPersistenceTokenService.setServerSecret(serverSecret);
keyBasedPersistenceTokenService.setServerInteger(serverInteger);
keyBasedPersistenceTokenService.setPseudoRandomNumberBytes(16);
keyBasedPersistenceTokenService.setSecureRandom(new SecureRandom());
return keyBasedPersistenceTokenService;
KeyBasedPersistenceTokenService tokenService = new KeyBasedPersistenceTokenService();
configureTokenService(tokenService);
return tokenService;
}

private void configureTokenService(KeyBasedPersistenceTokenService tokenService) {
tokenService.setServerSecret(serverSecret);
tokenService.setServerInteger(serverInteger);
tokenService.setPseudoRandomNumberBytes(16);
tokenService.setSecureRandom(new SecureRandom());
}

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,124 +1,124 @@
/*
* Copyright 2007 Open Source Applications Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.unitedinternet.cosmo.model;

import java.time.temporal.TemporalAmount;
import java.util.List;

import net.fortuna.ical4j.model.Calendar;
import net.fortuna.ical4j.model.Date;
import net.fortuna.ical4j.model.DateList;
import net.fortuna.ical4j.model.Recur;
import net.fortuna.ical4j.model.component.VEvent;
import net.fortuna.ical4j.model.property.Trigger;

/**
* Represents a stamp that contains event specific information.
*/
public interface BaseEventStamp extends Stamp {

/**
* Get the underlying VEvent
*
* @return VEvent
*/
public VEvent getEvent();

/**
* Get the Calendar that contains the VEvent
*
* @return Calendar containing VEvent
*/
public Calendar getEventCalendar();

/**
* Set the Calendar that contains the VEvent
*
* @param calendar Calendar containing VEvent
*/
public void setEventCalendar(Calendar calendar);

/**
* Returns a copy of the the iCalendar UID property value of the event .
*/
public String getIcalUid();

/**
* Sets the iCalendar UID property of the event.
/*
* Copyright 2007 Open Source Applications Foundation
*
* @param uid uid of VEVENT
*/
public void setIcalUid(String uid);

/**
* Returns a copy of the the iCalendar DTSTART property value of the event (never null).
*/
public Date getStartDate();

/**
* Returns the end date of the event as calculated from the iCalendar DTEND property value or the the iCalendar
* DTSTART + DURATION.
*/
public Date getEndDate();

/**
* Returns the duration of the event as calculated from the iCalendar DURATION property value or the the iCalendar
* DTEND - DTSTART.
*/
public TemporalAmount getDuration();

/**
* Returns a list of copies of the iCalendar RRULE property values of the event (can be empty).
*/
public List<Recur> getRecurrenceRules();

/**
* Returns a list of copies of the iCalendar RDATE property values of the event (can be empty).
*/
public DateList getRecurrenceDates();

/**
* Returns a list of copies of the values of all iCalendar EXDATE properties of the event (can be empty).
*/
public DateList getExceptionDates();

/**
* Return the Trigger of the first display alarm on the event
*
* @return trigger of the first display alarm
*/
public Trigger getDisplayAlarmTrigger();

/**
* Sets a single iCalendar EXDATE property of the event, removing any EXDATEs that were previously set.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* @param dates a <code>DateList</code>
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public void setExceptionDates(DateList dates);
package org.unitedinternet.cosmo.model;

/**
* Returns a copy of the the iCalendar RECURRENCE_ID property value of the event (can be null).
*/
public Date getRecurrenceId();
import java.time.temporal.TemporalAmount;
import java.util.List;

import net.fortuna.ical4j.model.Calendar;
import net.fortuna.ical4j.model.Date;
import net.fortuna.ical4j.model.DateList;
import net.fortuna.ical4j.model.Recur;
import net.fortuna.ical4j.model.component.VEvent;
import net.fortuna.ical4j.model.property.Trigger;

/**
* Determine if an event is recurring
*
* @return true if the underlying event is a recurring event
* Represents a stamp that contains event specific information.
*/
public boolean isRecurring();

}
public interface BaseEventStamp extends Stamp {

/**
* Get the underlying VEvent
*
* @return VEvent
*/
public VEvent getEvent();

/**
* Get the Calendar that contains the VEvent
*
* @return Calendar containing VEvent
*/
public Calendar getEventCalendar();

/**
* Set the Calendar that contains the VEvent
*
* @param calendar Calendar containing VEvent
*/
public void setEventCalendar(Calendar calendar);

/**
* Returns a copy of the the iCalendar UID property value of the event .
*/
public String getIcalUid();

/**
* Sets the iCalendar UID property of the event.
*
* @param uid uid of VEVENT
*/
public void setIcalUid(String uid);

/**
* Returns a copy of the the iCalendar DTSTART property value of the event (never null).
*/
public Date getStartDate();

/**
* Returns the end date of the event as calculated from the iCalendar DTEND property value or the the iCalendar
* DTSTART + DURATION.
*/
public Date getEndDate();

/**
* Returns the duration of the event as calculated from the iCalendar DURATION property value or the the iCalendar
* DTEND - DTSTART.
*/
public TemporalAmount getDuration();

/**
* Returns a list of copies of the iCalendar RRULE property values of the event (can be empty).
*/
public List<Recur> getRecurrenceRules();

/**
* Returns a list of copies of the iCalendar RDATE property values of the event (can be empty).
*/
public DateList getRecurrenceDates();

/**
* Returns a list of copies of the values of all iCalendar EXDATE properties of the event (can be empty).
*/
public DateList getExceptionDates();

/**
* Return the Trigger of the first display alarm on the event
*
* @return trigger of the first display alarm
*/
public Trigger getDisplayAlarmTrigger();

/**
* Sets a single iCalendar EXDATE property of the event, removing any EXDATEs that were previously set.
*
* @param dates a <code>DateList</code>
*/
public void setExceptionDates(DateList dates);

/**
* Returns a copy of the the iCalendar RECURRENCE_ID property value of the event (can be null).
*/
public Date getRecurrenceId();

/**
* Determine if an event is recurring
*
* @return true if the underlying event is a recurring event
*/
public boolean isRecurring();

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
package org.unitedinternet.cosmo.model;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;

/**
* Represents an item change. Includes who, when and what changed.
Expand All @@ -25,10 +28,7 @@ public enum Action { ITEM_ADDED, ITEM_CHANGED, ITEM_REMOVED }

private Action action;
private Date date;
private String modifiedBy;
private String itemUuid;
private String itemDisplayName;


public ItemChangeRecord() {}

public Action getAction() {
Expand All @@ -45,36 +45,22 @@ public void setDate(Date date) {
this.date = (Date)date.clone();
}
}
public String getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(String modifiedBy) {
this.modifiedBy = modifiedBy;
}
public String getItemUuid() {
return itemUuid;
}
public void setItemUuid(String itemUuid) {
this.itemUuid = itemUuid;
}
public String getItemDisplayName() {
return itemDisplayName;
}
public void setItemDisplayName(String itemDisplayName) {
this.itemDisplayName = itemDisplayName;
private static final Map<String, Supplier<Action>> actionMap = new HashMap<>();

static {
actionMap.put("ItemAdded", () -> Action.ITEM_ADDED);
actionMap.put("ItemRemoved", () -> Action.ITEM_REMOVED);
actionMap.put("ItemChanged", () -> Action.ITEM_CHANGED);
actionMap.put("ItemUpdated", () -> Action.ITEM_CHANGED);
}



public static Action toAction(String action) {
if("ItemAdded".equals(action)) {
return Action.ITEM_ADDED;
}
else if("ItemRemoved".equals(action)) {
return Action.ITEM_REMOVED;
}
else if("ItemChanged".equals(action) || "ItemUpdated".equals(action)) {
return Action.ITEM_CHANGED;
Supplier<Action> actionSupplier = actionMap.get(action);
if (actionSupplier != null) {
return actionSupplier.get();
} else {
throw new IllegalStateException("Unknown action " + action);
}

throw new IllegalStateException("Unknown action " + action);
}
}
}
Loading