/** * Checks if the specified {@code type} has the {@link RequireHttps} annotation * * @param type * @return {@code true} iff {@code type} has the {@link RequireHttps} annotation */ private boolean hasSecureAnnotation(Class<?> type) { if (type.getAnnotation(RequireHttps.class) != null) { return true; } for (Class<?> iface : type.getInterfaces()) { if (hasSecureAnnotation(iface)) { return true; } } if (type.getSuperclass() != null) { return hasSecureAnnotation(type.getSuperclass()); } return false; }
/** * Checks if the specified {@code type} has the {@link RequireHttps} annotation * * @param type * @return {@code true} iff {@code type} has the {@link RequireHttps} annotation */ private boolean hasSecureAnnotation(Class<?> type) { if (type.getAnnotation(RequireHttps.class) != null) { return true; } for (Class<?> iface : type.getInterfaces()) { if (hasSecureAnnotation(iface)) { return true; } } if (type.getSuperclass() != null) { return hasSecureAnnotation(type.getSuperclass()); } return false; }
/** * Determines which {@link Scheme} should be used to access the page * * @param pageClass * type of page * @return {@link Scheme} */ protected Scheme getDesiredSchemeFor(Class<? extends IRequestablePage> pageClass) { if (pageClass == null) { return Scheme.ANY; } Scheme SCHEME = cache.get(pageClass); if (SCHEME == null) { if (hasSecureAnnotation(pageClass)) { SCHEME = Scheme.HTTPS; } else { SCHEME = Scheme.HTTP; } cache.put(pageClass, SCHEME); } return SCHEME; }
/** * Determines which {@link Scheme} should be used to access the page * * @param pageClass * type of page * @return {@link Scheme} */ protected Scheme getDesiredSchemeFor(Class<? extends IRequestablePage> pageClass) { if (pageClass == null) { return Scheme.ANY; } Scheme SCHEME = cache.get(pageClass); if (SCHEME == null) { if (hasSecureAnnotation(pageClass)) { SCHEME = Scheme.HTTPS; } else { SCHEME = Scheme.HTTP; } cache.put(pageClass, SCHEME); } return SCHEME; }