Java 类org.springframework.security.web.util.UrlUtils 实例源码

项目:webpedidos    文件:JsfRedirectStrategy.java   
private String calculateRedirectUrl(String contextPath, String url) {
    if (!UrlUtils.isAbsoluteUrl(url)) {
        if (contextRelative) {
            return url;
        }
        return contextPath + url;
    }

    // Full URL, including http(s)://

    if (!contextRelative) {
        return url;
    }

    // Calculate the relative URL from the fully qualified URL, minus the
    // scheme and base context.
    url = url.substring(url.indexOf("://") + 3); // strip off scheme
    url = url.substring(url.indexOf(contextPath) + contextPath.length());

    if (url.length() > 1 && url.charAt(0) == '/') {
        url = url.substring(1);
    }

    return url;
}
项目:webpedidos    文件:JsfAccessDeniedHandler.java   
private String calculateRedirectUrl(String contextPath, String url) {
    if (!UrlUtils.isAbsoluteUrl(url)) {
        if (contextRelative) {
            return url;
        }
        return contextPath + url;
    }

    // Full URL, including http(s)://

    if (!contextRelative) {
        return url;
    }

    // Calculate the relative URL from the fully qualified URL, minus the
    // scheme and base context.
    url = url.substring(url.indexOf("://") + 3); // strip off scheme
    url = url.substring(url.indexOf(contextPath) + contextPath.length());

    if (url.length() > 1 && url.charAt(0) == '/') {
        url = url.substring(1);
    }

    return url;
}
项目:graviteeio-access-management    文件:XForwardedAwareRedirectStrategy.java   
private String calculateRedirectUrl(String contextPath, String url) {
    if (!UrlUtils.isAbsoluteUrl(url)) {
        if (contextRelative) {
            return url;
        } else {
            return contextPath + url;
        }
    }

    // Full URL, including http(s)://

    if (!contextRelative) {
        return url;
    }

    // Calculate the relative URL from the fully qualified URL, minus the last
    // occurrence of the scheme and base context.
    url = url.substring(url.lastIndexOf("://") + 3); // strip off scheme
    url = url.substring(url.indexOf(contextPath) + contextPath.length());

    if (url.length() > 1 && url.charAt(0) == '/') {
        url = url.substring(1);
    }

    return url;
}
项目:aramcomp    文件:TargetRedirectStrategy.java   
private String calculateRedirectUrl(String contextPath, String url) {
    if (!UrlUtils.isAbsoluteUrl(url)) {
        if (contextRelative) {
            return url;
        } else {
            return contextPath + url;
        }
    }

    // Full URL, including http(s)://

    if (!contextRelative) {
        return url;
    }

    // Calculate the relative URL from the fully qualified URL, minus the last
    // occurrence of the scheme and base context.
    url = url.substring(url.lastIndexOf("://") + 3); // strip off scheme
    url = url.substring(url.indexOf(contextPath) + contextPath.length());

    if (url.length() > 1 && url.charAt(0) == '/') {
        url = url.substring(1);
    }

    return url;
}
项目:PedidoVenda    文件:JsfRedirectStrategy.java   
private String calculateRedirectUrl(String contextPath, String url) {
    if (!UrlUtils.isAbsoluteUrl(url)) {
        if (this.contextRelative) {
            return url;
        } else {
            return contextPath + url;
        }
    }

    // Full URL, including http(s)://

    if (!this.contextRelative) {
        return url;
    }

    // Calculate the relative URL from the fully qualified URL, minus the
    // scheme and base context.
    url = url.substring(url.indexOf("://") + 3); // strip off scheme
    url = url.substring(url.indexOf(contextPath) + contextPath.length());

    if (url.length() > 1 && url.charAt(0) == '/') {
        url = url.substring(1);
    }

    return url;
}
项目:PedidoVenda    文件:JsfAccessDeniedHandler.java   
private String calculateRedirectUrl(String contextPath, String url) {
    if (!UrlUtils.isAbsoluteUrl(url)) {
        if (!contextRelative) {
            return url;
        } else {
            return contextPath + url;
        }
    }

    // Full URL, including http(s)://

    if (!contextRelative) {
        return url;
    }

    // Calculate the relative URL from the fully qualified URL, minus the
    // scheme and base context.
    url = url.substring(url.indexOf("://") + 3); // strip off scheme
    url = url.substring(url.indexOf(contextPath) + contextPath.length());

    if (url.length() > 1 && url.charAt(0) == '/') {
        url = url.substring(1);
    }

    return url;
}
项目:vaadin4spring    文件:DefaultVaadinRedirectStrategy.java   
private String calculateRedirectUrl(String contextPath, String url) {
    if (!UrlUtils.isAbsoluteUrl(url)) {
        if (contextRelative) {
            return url;
        } else {
            return contextPath + url;
        }
    }

    // Full URL, including http(s)://

    if (!contextRelative) {
        return url;
    }

    // Calculate the relative URL from the fully qualified URL, minus the last
    // occurrence of the scheme and base context.
    url = url.substring(url.lastIndexOf("://") + 3); // strip off scheme
    url = url.substring(url.indexOf(contextPath) + contextPath.length());

    if (url.length() > 1 && url.charAt(0) == '/') {
        url = url.substring(1);
    }

    return url;
}
项目:cas-security-spring-boot-starter    文件:DefaultProxyCallbackAndServiceAuthenticationDetails.java   
@Override
public String getProxyCallbackUrl() {
    if (proxyCallbackUri == null) {
        return null;
    }
    if (proxyCallbackUri.isAbsolute()) {
        return proxyCallbackUri.toASCIIString();
    }
    String path = context.getContextPath() + proxyCallbackUri.getPath();
    return UrlUtils.buildFullRequestUrl(context.getScheme(), context.getServerName(),
            context.getServerPort(), path, null);
}
项目:cas-security-spring-boot-starter    文件:DefaultProxyCallbackAndServiceAuthenticationDetails.java   
@Override
public String getServiceUrl() {
    String query = UriComponentsBuilder
            .newInstance()
            .query(context.getQueryString())
            .replaceQueryParam(serviceProperties.getArtifactParameter(), new Object[0])
            .build()
            .toString()
            .replaceFirst("^\\?", "");
    return UrlUtils.buildFullRequestUrl(context.getScheme(), context.getServerName(),
            context.getServerPort(), context.getRequestURI(), StringUtils.hasText(query) ? query : null);
}
项目:cas-security-spring-boot-starter    文件:DefaultProxyCallbackAndServiceAuthenticationDetails.java   
@Override
public String getProxyCallbackUrl() {
    if (proxyCallbackPath == null) {
        return null;
    }
    String path = context.getContextPath() + proxyCallbackPath;
    return UrlUtils.buildFullRequestUrl(context.getScheme(), context.getServerName(),
            context.getServerPort(), path, null);
}
项目:bdf2    文件:BasicLoginAuthenticationFilter.java   
@Override
protected void onSuccessfulAuthentication(HttpServletRequest request,
        HttpServletResponse response, Authentication authResult)
        throws IOException {
    String url=UrlUtils.buildRequestUrl(request);
    try {
        request.getRequestDispatcher(url).forward(request, response);
    } catch (ServletException e) {
        e.printStackTrace();
    }
}
项目:session-cloud    文件:CustomLoginUrlAuthenticationEntryPoint.java   
public void afterPropertiesSet() throws Exception {
    Assert.isTrue(
            StringUtils.hasText(loginFormUrl)
                    && UrlUtils.isValidRedirectUrl(loginFormUrl),
            "loginFormUrl must be specified and must be a valid redirect URL");
    if (useForward && UrlUtils.isAbsoluteUrl(loginFormUrl)) {
        throw new IllegalArgumentException(
                "useForward must be false if using an absolute loginFormURL");
    }
    Assert.notNull(portMapper, "portMapper must be specified");
    Assert.notNull(portResolver, "portResolver must be specified");
}
项目:session-cloud    文件:CustomLoginUrlAuthenticationEntryPoint.java   
protected String buildRedirectUrlToLoginPage(HttpServletRequest request,
                                             HttpServletResponse response, AuthenticationException authException) {

    String loginForm = determineUrlToUseForThisRequest(request, response,
            authException);

    if (UrlUtils.isAbsoluteUrl(loginForm)) {
        return loginForm;
    }

    int serverPort = portResolver.getServerPort(request);
    String scheme = request.getScheme();

    RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder();

    urlBuilder.setScheme(scheme);
    urlBuilder.setServerName(request.getServerName());
    urlBuilder.setPort(serverPort);
    urlBuilder.setContextPath(request.getContextPath());
    urlBuilder.setPathInfo(loginForm);

    if (forceHttps && "http".equals(scheme)) {
        Integer httpsPort = portMapper.lookupHttpsPort(Integer.valueOf(serverPort));

        if (httpsPort != null) {
            // Overwrite scheme and port in the redirect URL
            urlBuilder.setScheme("https");
            urlBuilder.setPort(httpsPort.intValue());
        }
        else {
            log.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port "
                    + serverPort);
        }
    }

    return urlBuilder.getUrl();
}
项目:webpedidos    文件:JsfLoginUrlAuthenticationEntryPoint.java   
@Override
public void afterPropertiesSet() throws Exception {
    Assert.isTrue(StringUtils.hasText(loginFormUrl) && UrlUtils.isValidRedirectUrl(loginFormUrl),
            "loginFormUrl must be specified and must be a valid redirect URL");
    if (useForward && UrlUtils.isAbsoluteUrl(loginFormUrl)) {
        throw new IllegalArgumentException("useForward must be false if using an absolute loginFormURL");
    }
    Assert.notNull(portMapper, "portMapper must be specified");
    Assert.notNull(portResolver, "portResolver must be specified");
}
项目:webpedidos    文件:JsfLoginUrlAuthenticationEntryPoint.java   
protected String buildRedirectUrlToLoginPage(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) {

    String loginForm = determineUrlToUseForThisRequest(request, response, authException);

    if (UrlUtils.isAbsoluteUrl(loginForm)) {
        return loginForm;
    }

    int serverPort = portResolver.getServerPort(request);
    String scheme = request.getScheme();

    RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder();

    urlBuilder.setScheme(scheme);
    urlBuilder.setServerName(request.getServerName());
    urlBuilder.setPort(serverPort);
    urlBuilder.setContextPath(request.getContextPath());
    urlBuilder.setPathInfo(loginForm);

    if (forceHttps && "http".equals(scheme)) {
        Integer httpsPort = portMapper.lookupHttpsPort(Integer.valueOf(serverPort));

        if (httpsPort != null) {
            // Overwrite scheme and port in the redirect URL
            urlBuilder.setScheme("https");
            urlBuilder.setPort(httpsPort.intValue());
        } else {
            logger.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port " + serverPort);
        }
    }

    return urlBuilder.getUrl();
}
项目:dhis2-core    文件:MobileClientController.java   
private static String getUrl( HttpServletRequest request, int id, String path )
{
    String url = UrlUtils.buildFullRequestUrl( request );
    if ( url.endsWith( "/" ) )
    {
        url = url + "orgUnits/" + id + "/" + path;
    }
    else
    {
        url = url + "/orgUnits/" + id + "/" + path;
    }
    return url;
}
项目:citizenship-appointment-server    文件:ExceptionMappingAuthenticationFailureHandler.java   
public void setExceptionMappings(Map<?, ?> failureUrlMap) {
    this.failureUrlMap.clear();
    for (Map.Entry<?, ?> entry : failureUrlMap.entrySet()) {
        Object exception = entry.getKey();
        Object url = entry.getValue();
        Assert.isInstanceOf(String.class, exception,
                "Exception key must be a String (the exception classname).");
        Assert.isInstanceOf(String.class, url, "URL must be a String");
        Assert.isTrue(UrlUtils.isValidRedirectUrl((String) url),
                "Not a valid redirect URL: " + url);
        this.failureUrlMap.put((String) exception, (String) url);
    }
}
项目:kayura-uasp    文件:ExceptionMappingExAuthenticationFailureHandler.java   
/**
 * Sets the map of exception types (by name) to URLs.
 *
 * @param failureUrlMap
 *            the map keyed by the fully-qualified name of the exception
 *            class, with the corresponding failure URL as the value.
 *
 * @throws IllegalArgumentException
 *             if the entries are not Strings or the URL is not valid.
 */
public void setExceptionMappings(Map<?, ?> failureUrlMap) {
    this.failureUrlMap.clear();
    for (Map.Entry<?, ?> entry : failureUrlMap.entrySet()) {
        Object exception = entry.getKey();
        Object url = entry.getValue();
        Assert.isInstanceOf(String.class, exception, "Exception key must be a String (the exception classname).");
        Assert.isInstanceOf(String.class, url, "URL must be a String");
        Assert.isTrue(UrlUtils.isValidRedirectUrl((String) url), "Not a valid redirect URL: " + url);
        this.failureUrlMap.put((String) exception, (String) url);
    }
}
项目:connect    文件:ExceptionMappingAuthenticationFailureHandler.java   
/**
 * Sets the map of exception types (by name) to URLs.
 *
 * @param failureUrlMap the map keyed by the fully-qualified name of the exception class, with the corresponding
 *                      failure URL as the value.
 * @throws IllegalArgumentException if the entries are not Strings or the URL is not valid.
 */
public void setExceptionMappings(Map<?, ?> failureUrlMap) {
    this.failureUrlMap.clear();
    for (Map.Entry<?, ?> entry : failureUrlMap.entrySet()) {
        Object exception = entry.getKey();
        Object url = entry.getValue();
        Assert.isInstanceOf(String.class, exception, "Exception key must be a String (the exception classname).");
        Assert.isInstanceOf(String.class, url, "URL must be a String");
        Assert.isTrue(UrlUtils.isValidRedirectUrl((String) url), "Not a valid redirect URL: " + url);
        this.failureUrlMap.put((String) exception, (String) url);
    }
}
项目:PedidoVenda    文件:JsfLoginUrlAuthenticationEntryPoint.java   
@Override
public void afterPropertiesSet() throws Exception {
       Assert.isTrue(StringUtils.hasText(this.loginFormUrl) && UrlUtils.isValidRedirectUrl(this.loginFormUrl),
               "loginFormUrl must be specified and must be a valid redirect URL");
       if (this.useForward && UrlUtils.isAbsoluteUrl(this.loginFormUrl)) {
           throw new IllegalArgumentException("useForward must be false if using an absolute loginFormURL");
       }
       Assert.notNull(this.portMapper, "portMapper must be specified");
       Assert.notNull(this.portResolver, "portResolver must be specified");
   }
项目:PedidoVenda    文件:JsfLoginUrlAuthenticationEntryPoint.java   
protected String buildRedirectUrlToLoginPage(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) {

    String loginForm = determineUrlToUseForThisRequest(request, response, authException);

    if (UrlUtils.isAbsoluteUrl(loginForm)) {
        return loginForm;
    }

    int serverPort = this.portResolver.getServerPort(request);
    String scheme = request.getScheme();

    RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder();

    urlBuilder.setScheme(scheme);
    urlBuilder.setServerName(request.getServerName());
    urlBuilder.setPort(serverPort);
    urlBuilder.setContextPath(request.getContextPath());
    urlBuilder.setPathInfo(loginForm);

    if (this.forceHttps && "http".equals(scheme)) {
        Integer httpsPort = this.portMapper.lookupHttpsPort(Integer.valueOf(serverPort));

        if (httpsPort != null) {
            // Overwrite scheme and port in the redirect URL
            urlBuilder.setScheme("https");
            urlBuilder.setPort(httpsPort.intValue());
        } else {
            logger.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port " + serverPort);
        }
    }

    return urlBuilder.getUrl();
}
项目:AgileAlligators    文件:MobileClientController.java   
private static String getUrl( HttpServletRequest request, int id, String path )
{
    String url = UrlUtils.buildFullRequestUrl( request );
    if ( url.endsWith( "/" ) )
    {
        url = url + "orgUnits/" + id + "/" + path;
    }
    else
    {
        url = url + "/orgUnits/" + id + "/" + path;
    }
    return url;
}
项目:owf-security    文件:OzoneLogoutSuccessHandler.java   
/***
 * Must have a valid defaultLogoutSuccessUrl
 * 
 * @param defaultLogoutSuccessUrl - Madatory, must be valid.
 * @param casLogoutSuccessUrl - Optional, based on if CAS is provided, and if provided must be valid.
 */
public OzoneLogoutSuccessHandler(String defaultLogoutSuccessUrl,
                              String casLogoutSuccessUrl) {
    if (StringUtils.hasText(casLogoutSuccessUrl)) {
        Assert.isTrue(UrlUtils.isValidRedirectUrl(casLogoutSuccessUrl), casLogoutSuccessUrl + " isn't a valid redirect URL");
    }
    Assert.isTrue(!StringUtils.hasLength(defaultLogoutSuccessUrl) ||
               UrlUtils.isValidRedirectUrl(defaultLogoutSuccessUrl), defaultLogoutSuccessUrl + " isn't a valid redirect URL");

    this.casLogoutHandler = new SimpleUrlLogoutSuccessHandler();
       this.casLogoutHandler.setDefaultTargetUrl(casLogoutSuccessUrl);

    this.defaultLogoutHandler = new SimpleUrlLogoutSuccessHandler();
       this.defaultLogoutHandler.setDefaultTargetUrl(defaultLogoutSuccessUrl);
}
项目:jakduk-api    文件:UrlGenerationUtils.java   
/**
 * URL 생성
 *
 * @param request HttpServletRequest
 * @param uri URI
 * @return 만들어진 URL
 */
public static String buildFullRequestUrl(HttpServletRequest request, String uri) {

    return UrlUtils.buildFullRequestUrl(
            request.getScheme(),
            request.getServerName(),
            request.getServerPort(),
            request.getContextPath() + uri, null);
}
项目:springboot-security-wechat    文件:MySimpleUrlAuthenticationFailureHandler.java   
public void setDefaultFailureUrl(String defaultFailureUrl) {
    Assert.isTrue(UrlUtils.isValidRedirectUrl(defaultFailureUrl), "'" + defaultFailureUrl + "' is not a valid redirect URL");
    this.defaultFailureUrl = defaultFailureUrl;
}
项目:cas-security-spring-boot-starter    文件:DefaultProxyCallbackAndServiceAuthenticationDetails.java   
@Override
public String getServiceUrl() {
    return UrlUtils.buildFullRequestUrl(context.getScheme(), context.getServerName(),
            context.getServerPort(), context.getRequestURI(), null);
}
项目:graviteeio-access-management    文件:ClientAwareAuthenticationFailureHandler.java   
/**
 * The URL which will be used as the failure destination.
 *
 * @param defaultFailureUrl the failure URL, for example "/loginFailed.jsp".
 */
public void setDefaultFailureUrl(String defaultFailureUrl) {
    Assert.isTrue(UrlUtils.isValidRedirectUrl(defaultFailureUrl),
            "'" + defaultFailureUrl + "' is not a valid redirect URL");
    this.defaultFailureUrl = defaultFailureUrl;
}
项目:SpringSecurity    文件:DefaultAuthenticationFailureHandler.java   
/**
 * The URL which will be used as the failure destination.
 *
 * @param defaultFailureUrl the failure URL, for example "/loginFailed.jsp".
 */
public void setDefaultFailureUrl(String defaultFailureUrl) {
    Assert.isTrue(UrlUtils.isValidRedirectUrl(defaultFailureUrl),
            "'" + defaultFailureUrl + "' is not a valid redirect URL");
    this.defaultFailureUrl = defaultFailureUrl;
}
项目:dhis2-core    文件:MobileClientController.java   
private org.hisp.dhis.api.mobile.model.LWUITmodel.MobileOrgUnitLinks getTrackerOrgUnit( OrganisationUnit unit,
    HttpServletRequest request )
{
    org.hisp.dhis.api.mobile.model.LWUITmodel.MobileOrgUnitLinks orgUnit = new org.hisp.dhis.api.mobile.model.LWUITmodel.MobileOrgUnitLinks();

    orgUnit.setId( unit.getId() );
    orgUnit.setName( unit.getShortName() );

    orgUnit.setDownloadAllUrl( getUrl( request, unit.getId(), "all" ) );
    orgUnit.setUpdateActivityPlanUrl( getUrl( request, unit.getId(), "activitiyplan" ) );
    orgUnit.setUploadFacilityReportUrl( getUrl( request, unit.getId(), "dataSets" ) );
    orgUnit.setDownloadFacilityReportUrl( getUrl( request, unit.getId(), "dataSetValue" ) );
    orgUnit.setUploadActivityReportUrl( getUrl( request, unit.getId(), "activities" ) );
    orgUnit.setUpdateDataSetUrl( getUrl( request, unit.getId(), "updateDataSets" ) );
    orgUnit.setChangeUpdateDataSetLangUrl( getUrl( request, unit.getId(), "changeLanguageDataSet" ) );
    orgUnit.setSearchUrl( getUrl( request, unit.getId(), "search" ) );
    orgUnit.setUpdateNewVersionUrl( getUrl( request, unit.getId(), "updateNewVersionUrl" ) );
    orgUnit.setSendFeedbackUrl( getUrl( request, unit.getId(), "sendFeedback" ) );
    orgUnit.setFindUserUrl( getUrl( request, unit.getId(), "findUser" ) );
    orgUnit.setSendMessageUrl( getUrl( request, unit.getId(), "sendMessage" ) );
    orgUnit.setDownloadMessageConversationUrl( getUrl( request, unit.getId(), "downloadMessageConversation" ) );
    orgUnit.setGetMessageUrl( getUrl( request, unit.getId(), "getMessage" ) );
    orgUnit.setReplyMessageUrl( getUrl( request, unit.getId(), "replyMessage" ) );
    orgUnit.setDownloadInterpretationUrl( getUrl( request, unit.getId(), "downloadInterpretation" ) );
    orgUnit.setPostInterpretationUrl( getUrl( request, unit.getId(), "postInterpretation" ) );
    orgUnit.setPostCommentUrl( getUrl( request, unit.getId(), "postComment" ) );
    orgUnit.setUpdateContactUrl( getUrl( request, unit.getId(), "updateContactForMobile" ) );
    orgUnit.setFindPatientUrl( getUrl( request, unit.getId(), "findPatient" ) );
    orgUnit.setRegisterPersonUrl( getUrl( request, unit.getId(), "registerPerson" ) );
    orgUnit.setUploadProgramStageUrl( getUrl( request, unit.getId(), "uploadProgramStage" ) );
    orgUnit.setEnrollProgramUrl( getUrl( request, unit.getId(), "enrollProgram" ) );
    orgUnit.setGetVariesInfoUrl( getUrl( request, unit.getId(), "getVariesInfo" ) );
    orgUnit.setAddRelationshipUrl( getUrl( request, unit.getId(), "addRelationship" ) );
    orgUnit.setDownloadAnonymousProgramUrl( getUrl( request, unit.getId(), "downloadAnonymousProgram" ) );
    orgUnit.setFindProgramUrl( getUrl( request, unit.getId(), "findProgram" ) );
    orgUnit.setFindPatientInAdvancedUrl( getUrl( request, unit.getId(), "findPatientInAdvanced" ) );
    orgUnit.setFindPatientsUrl( getUrl( request, unit.getId(), "findPatients" ) );
    orgUnit.setFindVisitScheduleUrl( getUrl( request, unit.getId(), "findVisitSchedule" ) );
    orgUnit.setFindLostToFollowUpUrl( getUrl( request, unit.getId(), "findLostToFollowUp" ) );
    orgUnit.setHandleLostToFollowUpUrl( getUrl( request, unit.getId(), "handleLostToFollowUp" ) );
    orgUnit.setGenerateRepeatableEventUrl( getUrl( request, unit.getId(), "generateRepeatableEvent" ) );
    orgUnit.setUploadSingleEventWithoutRegistration( getUrl( request, unit.getId(),
        "uploadSingleEventWithoutRegistration" ) );
    orgUnit.setCompleteProgramInstanceUrl( getUrl( request, unit.getId(), "completeProgramInstance" ) );
    orgUnit.setRegisterRelativeUrl( getUrl( request, unit.getId(), "registerRelative" ) );

    // generate URL for download new version
    String full = UrlUtils.buildFullRequestUrl( request );
    String root = full.substring( 0, full.length() - UrlUtils.buildRequestUrl( request ).length() );
    String updateNewVersionUrl = root + "/dhis-web-api-mobile/updateClient.action";
    orgUnit.setUpdateNewVersionUrl( updateNewVersionUrl );

    return orgUnit;
}
项目:dhis2-core    文件:MobileClientController.java   
private MobileOrgUnitLinks getOrgUnit( OrganisationUnit unit, HttpServletRequest request )
{
    MobileOrgUnitLinks orgUnit = new MobileOrgUnitLinks();

    orgUnit.setId( unit.getId() );
    orgUnit.setName( unit.getShortName() );

    orgUnit.setDownloadAllUrl( getUrl( request, unit.getId(), "all" ) );
    orgUnit.setUpdateActivityPlanUrl( getUrl( request, unit.getId(), "activitiyplan" ) );
    orgUnit.setUploadFacilityReportUrl( getUrl( request, unit.getId(), "dataSets" ) );
    orgUnit.setDownloadFacilityReportUrl( getUrl( request, unit.getId(), "dataSetValue" ) );
    orgUnit.setUploadActivityReportUrl( getUrl( request, unit.getId(), "activities" ) );
    orgUnit.setUpdateDataSetUrl( getUrl( request, unit.getId(), "updateDataSets" ) );
    orgUnit.setChangeUpdateDataSetLangUrl( getUrl( request, unit.getId(), "changeLanguageDataSet" ) );
    orgUnit.setSearchUrl( getUrl( request, unit.getId(), "search" ) );
    orgUnit.setUpdateNewVersionUrl( getUrl( request, unit.getId(), "updateNewVersionUrl" ) );
    orgUnit.setSendFeedbackUrl( getUrl( request, unit.getId(), "sendFeedback" ) );
    orgUnit.setFindUserUrl( getUrl( request, unit.getId(), "findUser" ) );
    orgUnit.setSendMessageUrl( getUrl( request, unit.getId(), "sendMessage" ) );
    orgUnit.setDownloadMessageConversationUrl( getUrl( request, unit.getId(), "downloadMessageConversation" ) );
    orgUnit.setGetMessageUrl( getUrl( request, unit.getId(), "getMessage" ) );
    orgUnit.setReplyMessageUrl( getUrl( request, unit.getId(), "replyMessage" ) );
    orgUnit.setDownloadInterpretationUrl( getUrl( request, unit.getId(), "downloadInterpretation" ) );
    orgUnit.setPostInterpretationUrl( getUrl( request, unit.getId(), "postInterpretation" ) );
    orgUnit.setPostCommentUrl( getUrl( request, unit.getId(), "postComment" ) );
    orgUnit.setUpdateContactUrl( getUrl( request, unit.getId(), "updateContactForMobile" ) );
    orgUnit.setFindPatientUrl( getUrl( request, unit.getId(), "findPatient" ) );
    orgUnit.setRegisterPersonUrl( getUrl( request, unit.getId(), "registerPerson" ) );
    orgUnit.setUploadProgramStageUrl( getUrl( request, unit.getId(), "uploadProgramStage" ) );
    orgUnit.setEnrollProgramUrl( getUrl( request, unit.getId(), "enrollProgram" ) );
    orgUnit.setGetVariesInfoUrl( getUrl( request, unit.getId(), "getVariesInfo" ) );
    orgUnit.setAddRelationshipUrl( getUrl( request, unit.getId(), "addRelationship" ) );
    orgUnit.setDownloadAnonymousProgramUrl( getUrl( request, unit.getId(), "downloadAnonymousProgram" ) );
    orgUnit.setFindProgramUrl( getUrl( request, unit.getId(), "findProgram" ) );
    orgUnit.setFindPatientInAdvancedUrl( getUrl( request, unit.getId(), "findPatientInAdvanced" ) );
    orgUnit.setFindPatientsUrl( getUrl( request, unit.getId(), "findPatients" ) );
    orgUnit.setFindVisitScheduleUrl( getUrl( request, unit.getId(), "findVisitSchedule" ) );
    orgUnit.setFindLostToFollowUpUrl( getUrl( request, unit.getId(), "findLostToFollowUp" ) );
    orgUnit.setHandleLostToFollowUpUrl( getUrl( request, unit.getId(), "handleLostToFollowUp" ) );
    orgUnit.setGenerateRepeatableEventUrl( getUrl( request, unit.getId(), "generateRepeatableEvent" ) );
    orgUnit.setUploadSingleEventWithoutRegistration( getUrl( request, unit.getId(),
        "uploadSingleEventWithoutRegistration" ) );
    orgUnit.setCompleteProgramInstanceUrl( getUrl( request, unit.getId(), "completeProgramInstance" ) );
    orgUnit.setRegisterRelativeUrl( getUrl( request, unit.getId(), "registerRelative" ) );

    // generate URL for download new version
    String full = UrlUtils.buildFullRequestUrl( request );
    String root = full.substring( 0, full.length() - UrlUtils.buildRequestUrl( request ).length() );
    String updateNewVersionUrl = root + "/dhis-web-api-mobile/updateClient.action";
    orgUnit.setUpdateNewVersionUrl( updateNewVersionUrl );

    return orgUnit;
}
项目:aggregate    文件:RedirectingLoginUrlAuthenticationEntryPoint.java   
protected String buildRedirectUrlToLoginPage(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) {

    String loginForm = determineUrlToUseForThisRequest(request, response, authException);

    if (UrlUtils.isAbsoluteUrl(loginForm)) {
        return loginForm;
    }

    int serverPort = getPortResolver().getServerPort(request);
    String scheme = request.getScheme();

    RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder();

    urlBuilder.setScheme(scheme);
    urlBuilder.setServerName(request.getServerName());
    urlBuilder.setPort(serverPort);
    urlBuilder.setContextPath(request.getContextPath());
    urlBuilder.setPathInfo(loginForm);
    try {
      String fullRequest = request.getRequestURL().toString();
      if ( request.getQueryString() != null ) {
        fullRequest += "?" + request.getQueryString();
      }
      String redirectParam = "redirect=" + URLEncoder.encode(fullRequest,"UTF-8");
      urlBuilder.setQuery(redirectParam);
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }

    if (isForceHttps() && "http".equals(scheme)) {
        Integer httpsPort = getPortMapper().lookupHttpsPort(Integer.valueOf(serverPort));

        if (httpsPort != null) {
            // Overwrite scheme and port in the redirect URL
            urlBuilder.setScheme("https");
            urlBuilder.setPort(httpsPort.intValue());
        } else {
            logger.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port " + serverPort);
        }
    }

    return urlBuilder.getUrl();
}
项目:AgileAlligators    文件:MobileClientController.java   
private org.hisp.dhis.api.mobile.model.LWUITmodel.MobileOrgUnitLinks getTrackerOrgUnit( OrganisationUnit unit,
    HttpServletRequest request )
{
    org.hisp.dhis.api.mobile.model.LWUITmodel.MobileOrgUnitLinks orgUnit = new org.hisp.dhis.api.mobile.model.LWUITmodel.MobileOrgUnitLinks();

    orgUnit.setId( unit.getId() );
    orgUnit.setName( unit.getShortName() );

    orgUnit.setDownloadAllUrl( getUrl( request, unit.getId(), "all" ) );
    orgUnit.setUpdateActivityPlanUrl( getUrl( request, unit.getId(), "activitiyplan" ) );
    orgUnit.setUploadFacilityReportUrl( getUrl( request, unit.getId(), "dataSets" ) );
    orgUnit.setDownloadFacilityReportUrl( getUrl( request, unit.getId(), "dataSetValue" ) );
    orgUnit.setUploadActivityReportUrl( getUrl( request, unit.getId(), "activities" ) );
    orgUnit.setUpdateDataSetUrl( getUrl( request, unit.getId(), "updateDataSets" ) );
    orgUnit.setChangeUpdateDataSetLangUrl( getUrl( request, unit.getId(), "changeLanguageDataSet" ) );
    orgUnit.setSearchUrl( getUrl( request, unit.getId(), "search" ) );
    orgUnit.setUpdateNewVersionUrl( getUrl( request, unit.getId(), "updateNewVersionUrl" ) );
    orgUnit.setSendFeedbackUrl( getUrl( request, unit.getId(), "sendFeedback" ) );
    orgUnit.setFindUserUrl( getUrl( request, unit.getId(), "findUser" ) );
    orgUnit.setSendMessageUrl( getUrl( request, unit.getId(), "sendMessage" ) );
    orgUnit.setDownloadMessageConversationUrl( getUrl( request, unit.getId(), "downloadMessageConversation" ) );
    orgUnit.setGetMessageUrl( getUrl( request, unit.getId(), "getMessage" ) );
    orgUnit.setReplyMessageUrl( getUrl( request, unit.getId(), "replyMessage" ) );
    orgUnit.setDownloadInterpretationUrl( getUrl( request, unit.getId(), "downloadInterpretation" ) );
    orgUnit.setPostInterpretationUrl( getUrl( request, unit.getId(), "postInterpretation" ) );
    orgUnit.setPostCommentUrl( getUrl( request, unit.getId(), "postComment" ) );
    orgUnit.setUpdateContactUrl( getUrl( request, unit.getId(), "updateContactForMobile" ) );
    orgUnit.setFindPatientUrl( getUrl( request, unit.getId(), "findPatient" ) );
    orgUnit.setRegisterPersonUrl( getUrl( request, unit.getId(), "registerPerson" ) );
    orgUnit.setUploadProgramStageUrl( getUrl( request, unit.getId(), "uploadProgramStage" ) );
    orgUnit.setEnrollProgramUrl( getUrl( request, unit.getId(), "enrollProgram" ) );
    orgUnit.setGetVariesInfoUrl( getUrl( request, unit.getId(), "getVariesInfo" ) );
    orgUnit.setAddRelationshipUrl( getUrl( request, unit.getId(), "addRelationship" ) );
    orgUnit.setDownloadAnonymousProgramUrl( getUrl( request, unit.getId(), "downloadAnonymousProgram" ) );
    orgUnit.setFindProgramUrl( getUrl( request, unit.getId(), "findProgram" ) );
    orgUnit.setFindPatientInAdvancedUrl( getUrl( request, unit.getId(), "findPatientInAdvanced" ) );
    orgUnit.setFindPatientsUrl( getUrl( request, unit.getId(), "findPatients" ) );
    orgUnit.setFindVisitScheduleUrl( getUrl( request, unit.getId(), "findVisitSchedule" ) );
    orgUnit.setFindLostToFollowUpUrl( getUrl( request, unit.getId(), "findLostToFollowUp" ) );
    orgUnit.setHandleLostToFollowUpUrl( getUrl( request, unit.getId(), "handleLostToFollowUp" ) );
    orgUnit.setGenerateRepeatableEventUrl( getUrl( request, unit.getId(), "generateRepeatableEvent" ) );
    orgUnit.setUploadSingleEventWithoutRegistration( getUrl( request, unit.getId(),
        "uploadSingleEventWithoutRegistration" ) );
    orgUnit.setCompleteProgramInstanceUrl( getUrl( request, unit.getId(), "completeProgramInstance" ) );
    orgUnit.setRegisterRelativeUrl( getUrl( request, unit.getId(), "registerRelative" ) );

    // generate URL for download new version
    String full = UrlUtils.buildFullRequestUrl( request );
    String root = full.substring( 0, full.length() - UrlUtils.buildRequestUrl( request ).length() );
    String updateNewVersionUrl = root + "/dhis-web-api-mobile/updateClient.action";
    orgUnit.setUpdateNewVersionUrl( updateNewVersionUrl );

    return orgUnit;
}
项目:AgileAlligators    文件:MobileClientController.java   
private MobileOrgUnitLinks getOrgUnit( OrganisationUnit unit, HttpServletRequest request )
{
    MobileOrgUnitLinks orgUnit = new MobileOrgUnitLinks();

    orgUnit.setId( unit.getId() );
    orgUnit.setName( unit.getShortName() );

    orgUnit.setDownloadAllUrl( getUrl( request, unit.getId(), "all" ) );
    orgUnit.setUpdateActivityPlanUrl( getUrl( request, unit.getId(), "activitiyplan" ) );
    orgUnit.setUploadFacilityReportUrl( getUrl( request, unit.getId(), "dataSets" ) );
    orgUnit.setDownloadFacilityReportUrl( getUrl( request, unit.getId(), "dataSetValue" ) );
    orgUnit.setUploadActivityReportUrl( getUrl( request, unit.getId(), "activities" ) );
    orgUnit.setUpdateDataSetUrl( getUrl( request, unit.getId(), "updateDataSets" ) );
    orgUnit.setChangeUpdateDataSetLangUrl( getUrl( request, unit.getId(), "changeLanguageDataSet" ) );
    orgUnit.setSearchUrl( getUrl( request, unit.getId(), "search" ) );
    orgUnit.setUpdateNewVersionUrl( getUrl( request, unit.getId(), "updateNewVersionUrl" ) );
    orgUnit.setSendFeedbackUrl( getUrl( request, unit.getId(), "sendFeedback" ) );
    orgUnit.setFindUserUrl( getUrl( request, unit.getId(), "findUser" ) );
    orgUnit.setSendMessageUrl( getUrl( request, unit.getId(), "sendMessage" ) );
    orgUnit.setDownloadMessageConversationUrl( getUrl( request, unit.getId(), "downloadMessageConversation" ) );
    orgUnit.setGetMessageUrl( getUrl( request, unit.getId(), "getMessage" ) );
    orgUnit.setReplyMessageUrl( getUrl( request, unit.getId(), "replyMessage" ) );
    orgUnit.setDownloadInterpretationUrl( getUrl( request, unit.getId(), "downloadInterpretation" ) );
    orgUnit.setPostInterpretationUrl( getUrl( request, unit.getId(), "postInterpretation" ) );
    orgUnit.setPostCommentUrl( getUrl( request, unit.getId(), "postComment" ) );
    orgUnit.setUpdateContactUrl( getUrl( request, unit.getId(), "updateContactForMobile" ) );
    orgUnit.setFindPatientUrl( getUrl( request, unit.getId(), "findPatient" ) );
    orgUnit.setRegisterPersonUrl( getUrl( request, unit.getId(), "registerPerson" ) );
    orgUnit.setUploadProgramStageUrl( getUrl( request, unit.getId(), "uploadProgramStage" ) );
    orgUnit.setEnrollProgramUrl( getUrl( request, unit.getId(), "enrollProgram" ) );
    orgUnit.setGetVariesInfoUrl( getUrl( request, unit.getId(), "getVariesInfo" ) );
    orgUnit.setAddRelationshipUrl( getUrl( request, unit.getId(), "addRelationship" ) );
    orgUnit.setDownloadAnonymousProgramUrl( getUrl( request, unit.getId(), "downloadAnonymousProgram" ) );
    orgUnit.setFindProgramUrl( getUrl( request, unit.getId(), "findProgram" ) );
    orgUnit.setFindPatientInAdvancedUrl( getUrl( request, unit.getId(), "findPatientInAdvanced" ) );
    orgUnit.setFindPatientsUrl( getUrl( request, unit.getId(), "findPatients" ) );
    orgUnit.setFindVisitScheduleUrl( getUrl( request, unit.getId(), "findVisitSchedule" ) );
    orgUnit.setFindLostToFollowUpUrl( getUrl( request, unit.getId(), "findLostToFollowUp" ) );
    orgUnit.setHandleLostToFollowUpUrl( getUrl( request, unit.getId(), "handleLostToFollowUp" ) );
    orgUnit.setGenerateRepeatableEventUrl( getUrl( request, unit.getId(), "generateRepeatableEvent" ) );
    orgUnit.setUploadSingleEventWithoutRegistration( getUrl( request, unit.getId(),
        "uploadSingleEventWithoutRegistration" ) );
    orgUnit.setCompleteProgramInstanceUrl( getUrl( request, unit.getId(), "completeProgramInstance" ) );
    orgUnit.setRegisterRelativeUrl( getUrl( request, unit.getId(), "registerRelative" ) );

    // generate URL for download new version
    String full = UrlUtils.buildFullRequestUrl( request );
    String root = full.substring( 0, full.length() - UrlUtils.buildRequestUrl( request ).length() );
    String updateNewVersionUrl = root + "/dhis-web-api-mobile/updateClient.action";
    orgUnit.setUpdateNewVersionUrl( updateNewVersionUrl );

    return orgUnit;
}
项目:identity-sample-apps    文件:Application.java   
private void populateModelAttributes(HttpServletRequest request, Model model) {
    model.addAttribute("ssoServiceUrl", ssoServiceUrl);
    model.addAttribute("thisUrl", UrlUtils.buildFullRequestUrl(request));
    model.addAttribute("clientId", clientId);
}
项目:openclouddb    文件:RainbowFailureHandler.java   
public void setDefaultFailureUrl(String defaultFailureUrl) {
    Assert.isTrue(UrlUtils.isValidRedirectUrl(defaultFailureUrl), "'"
            + defaultFailureUrl + "' is not a valid redirect URL");

    this.defaultFailureUrl = defaultFailureUrl;
}
项目:kaa    文件:KaaAdminAuthFailureHandler.java   
/**
 * The URL which will be used as the failure destination.
 *
 * @param defaultFailureUrl the failure URL, for example "/loginFailed.jsp".
 */
public void setDefaultFailureUrl(String defaultFailureUrl) {
  Assert.isTrue(UrlUtils.isValidRedirectUrl(defaultFailureUrl),
      "'" + defaultFailureUrl + "' is not a valid redirect URL");
  this.defaultFailureUrl = defaultFailureUrl;
}
项目:arsnova-backend    文件:LoginController.java   
@RequestMapping(value = { "/auth/dialog" }, method = RequestMethod.GET)
@ResponseBody
public View dialog(
        @RequestParam("type") final String type,
        @RequestParam(value = "successurl", defaultValue = "/") String successUrl,
        @RequestParam(value = "failureurl", defaultValue = "/") String failureUrl,
        final HttpServletRequest request,
        final HttpServletResponse response
) throws HttpAction, IOException, ServletException {
    View result = null;

    /* Use URLs from a request parameters for redirection as long as the
     * URL is not absolute (to prevent abuse of the redirection). */
    if (UrlUtils.isAbsoluteUrl(successUrl)) {
        successUrl = "/";
    }
    if (UrlUtils.isAbsoluteUrl(failureUrl)) {
        failureUrl = "/";
    }

    /* Handle proxy
     * TODO: It might be better, to support the proposed standard: http://tools.ietf.org/html/rfc7239 */
    String host = null != request.getHeader("X-Forwarded-Host")
            ? request.getHeader("X-Forwarded-Host") : request.getServerName();
    int port = null != request.getHeader("X-Forwarded-Port")
            ? Integer.valueOf(request.getHeader("X-Forwarded-Port")) : request.getServerPort();
    String scheme = null != request.getHeader("X-Forwarded-Proto")
            ? request.getHeader("X-Forwarded-Proto") : request.getScheme();

    String serverUrl = scheme + "://" + host;
    if ("https".equals(scheme)) {
        if (443 != port) {
            serverUrl = serverUrl + ":" + String.valueOf(port);
        }
    } else {
        if (80 != port) {
            serverUrl = serverUrl + ":" + String.valueOf(port);
        }
    }

    request.getSession().setAttribute("ars-login-success-url", serverUrl + successUrl);
    request.getSession().setAttribute("ars-login-failure-url", serverUrl + failureUrl);

    if (casEnabled && "cas".equals(type)) {
        casEntryPoint.commence(request, response, null);
    } else if (twitterEnabled && "twitter".equals(type)) {
        result = new RedirectView(
                twitterClient.getRedirectAction(new J2EContext(request, response)).getLocation());
    } else if (facebookEnabled && "facebook".equals(type)) {
        facebookClient.setFields("id,link");
        facebookClient.setScope("");
        result = new RedirectView(
                facebookClient.getRedirectAction(new J2EContext(request, response)).getLocation());
    } else if (googleEnabled && "google".equals(type)) {
        google2Client.setScope(Google2Client.Google2Scope.EMAIL);
        result = new RedirectView(
                google2Client.getRedirectAction(new J2EContext(request, response)).getLocation());
    } else {
        response.setStatus(HttpStatus.BAD_REQUEST.value());
    }

    return result;
}
项目:openclouddb    文件:RainbowFailureHandler.java   
public void setDefaultFailureUrl(String defaultFailureUrl) {
    Assert.isTrue(UrlUtils.isValidRedirectUrl(defaultFailureUrl), "'"
            + defaultFailureUrl + "' is not a valid redirect URL");

    this.defaultFailureUrl = defaultFailureUrl;
}
项目:nextreports-server    文件:IntegrationAuthenticationFilter.java   
@Override
public void afterPropertiesSet() {
    Assert.hasLength(filterProcessesUrl, "filterProcessesUrl must be specified");
    Assert.notNull(userDetailsService, "userDetailsService must be specified");
    Assert.isTrue(UrlUtils.isValidRedirectUrl(filterProcessesUrl), filterProcessesUrl + " isn't a valid redirect URL");
}
项目:communote-server    文件:CommunoteAuthenticationFailureHandler.java   
/**
 * Borrowed from
 * {@link org.springframework.security.web.authentication.ExceptionMappingAuthenticationFailureHandler}
 * .
 *
 * Sets the map of exception types (by name) to URLs.
 *
 * @param failureUrlMap
 *            the map keyed by the fully-qualified name of the exception class, with the
 *            corresponding failure URL as the value.
 *
 * @throws IllegalArgumentException
 *             if the entries are not Strings or the URL is not valid.
 */
public void setExceptionMappings(Map<?, ?> failureUrlMap) {
    this.failureUrlMap.clear();
    for (Map.Entry<?, ?> entry : failureUrlMap.entrySet()) {
        Object exception = entry.getKey();
        Object url = entry.getValue();
        Assert.isInstanceOf(String.class, exception,
                "Exception key must be a String (the exception classname).");
        Assert.isInstanceOf(String.class, url, "URL must be a String");
        Assert.isTrue(UrlUtils.isValidRedirectUrl((String) url), "Not a valid redirect URL: "
                + url);
        this.failureUrlMap.put((String) exception, (String) url);
    }
}