├── .project ├── .settings └── org.eclipse.m2e.core.prefs ├── AuthServer ├── .classpath ├── .project ├── .settings │ ├── .jsdtscope │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.wst.common.component │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.wst.jsdt.ui.superType.container │ └── org.eclipse.wst.jsdt.ui.superType.name ├── .springBeans ├── pom.xml ├── src │ └── main │ │ ├── java │ │ └── org │ │ │ └── spring │ │ │ ├── aspect │ │ │ └── LoggerAspect.java │ │ │ └── web │ │ │ └── controller │ │ │ ├── AccessConfirmationController.java │ │ │ ├── AdminController.java │ │ │ └── LoginController.java │ │ ├── resources │ │ ├── db.properties │ │ ├── logback.xml │ │ ├── messages_ar.properties │ │ ├── messages_en.properties │ │ ├── schema.sql │ │ ├── schema_MySql.sql │ │ ├── spring │ │ │ ├── root-context.xml │ │ │ └── security-context.xml │ │ ├── test-data.sql │ │ ├── theme-black.properties │ │ ├── theme-blue.properties │ │ ├── theme-default.properties │ │ ├── theme-green.properties │ │ ├── theme-red.properties │ │ └── theme-yellow.properties │ │ └── webapp │ │ ├── WEB-INF │ │ ├── jsp │ │ │ ├── access_confirmation.jsp │ │ │ ├── index.jsp │ │ │ ├── login.jsp │ │ │ ├── oauth_error.jsp │ │ │ ├── register │ │ │ │ └── client.jsp │ │ │ ├── request_token_authorized.jsp │ │ │ └── tokenManagment.jsp │ │ ├── spring-servlet.xml │ │ └── web.xml │ │ ├── resources │ │ ├── css │ │ │ ├── images │ │ │ │ ├── bg.gif │ │ │ │ └── header.jpg │ │ │ ├── style.css │ │ │ └── ui-darkness │ │ │ │ ├── images │ │ │ │ ├── ui-bg_flat_30_cccccc_40x100.png │ │ │ │ ├── ui-bg_flat_50_5c5c5c_40x100.png │ │ │ │ ├── ui-bg_glass_20_555555_1x400.png │ │ │ │ ├── ui-bg_glass_40_0078a3_1x400.png │ │ │ │ ├── ui-bg_glass_40_ffc73d_1x400.png │ │ │ │ ├── ui-bg_gloss-wave_25_333333_500x100.png │ │ │ │ ├── ui-bg_highlight-soft_80_eeeeee_1x100.png │ │ │ │ ├── ui-bg_inset-soft_25_000000_1x100.png │ │ │ │ ├── ui-bg_inset-soft_30_f58400_1x100.png │ │ │ │ ├── ui-icons_222222_256x240.png │ │ │ │ ├── ui-icons_4b8e0b_256x240.png │ │ │ │ ├── ui-icons_a83300_256x240.png │ │ │ │ ├── ui-icons_cccccc_256x240.png │ │ │ │ └── ui-icons_ffffff_256x240.png │ │ │ │ ├── jquery-ui-1.9.2.custom.css │ │ │ │ └── jquery-ui-1.9.2.custom.min.css │ │ └── js │ │ │ ├── jquery-1.8.3.js │ │ │ └── jquery-ui-1.9.2.custom.js │ │ └── themes │ │ ├── black.css │ │ ├── blue.css │ │ ├── default.css │ │ ├── green.css │ │ ├── images │ │ ├── bg.gif │ │ ├── header.jpg │ │ ├── header_black.jpg │ │ ├── header_blue.jpg │ │ ├── header_green.jpg │ │ ├── header_red.jpg │ │ └── header_yellow.jpg │ │ ├── red.css │ │ └── yellow.css └── target │ ├── .gitignore │ └── m2e-wtp │ └── web-resources │ └── .gitignore ├── README.md ├── RESTClient ├── .classpath ├── .project ├── .settings │ ├── .jsdtscope │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.wst.common.component │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.wst.jsdt.ui.superType.container │ └── org.eclipse.wst.jsdt.ui.superType.name ├── .springBeans ├── pom.xml ├── src │ └── main │ │ ├── resources │ │ └── spring │ │ │ └── root-context.xml │ │ └── webapp │ │ ├── WEB-INF │ │ ├── spring-servlet.xml │ │ └── web.xml │ │ ├── css │ │ └── ui-darkness │ │ │ ├── images │ │ │ ├── ui-bg_flat_30_cccccc_40x100.png │ │ │ ├── ui-bg_flat_50_5c5c5c_40x100.png │ │ │ ├── ui-bg_glass_20_555555_1x400.png │ │ │ ├── ui-bg_glass_40_0078a3_1x400.png │ │ │ ├── ui-bg_glass_40_ffc73d_1x400.png │ │ │ ├── ui-bg_gloss-wave_25_333333_500x100.png │ │ │ ├── ui-bg_highlight-soft_80_eeeeee_1x100.png │ │ │ ├── ui-bg_inset-soft_25_000000_1x100.png │ │ │ ├── ui-bg_inset-soft_30_f58400_1x100.png │ │ │ ├── ui-icons_222222_256x240.png │ │ │ ├── ui-icons_4b8e0b_256x240.png │ │ │ ├── ui-icons_a83300_256x240.png │ │ │ ├── ui-icons_cccccc_256x240.png │ │ │ └── ui-icons_ffffff_256x240.png │ │ │ ├── jquery-ui-1.9.2.custom.css │ │ │ └── jquery-ui-1.9.2.custom.min.css │ │ ├── index.jsp │ │ └── js │ │ ├── jquery-1.8.3.js │ │ ├── jquery-ui-1.9.2.custom.js │ │ ├── jso.js │ │ └── json2.js └── target │ ├── .gitignore │ └── m2e-wtp │ └── web-resources │ └── .gitignore ├── RESTServer ├── .classpath ├── .project ├── .settings │ ├── .jsdtscope │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.wst.common.component │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.wst.jsdt.ui.superType.container │ └── org.eclipse.wst.jsdt.ui.superType.name ├── .springBeans ├── pom.xml ├── src │ └── main │ │ ├── java │ │ └── org │ │ │ └── spring │ │ │ ├── aspect │ │ │ └── LoggerAspect.java │ │ │ └── web │ │ │ └── rest │ │ │ ├── controller │ │ │ └── PersonController.java │ │ │ ├── model │ │ │ └── Person.java │ │ │ ├── repository │ │ │ ├── GenericRepository.java │ │ │ ├── PersonRepository.java │ │ │ └── impl │ │ │ │ └── jdbc │ │ │ │ ├── JDBCPersonRepository.java │ │ │ │ └── JDBCRepository.java │ │ │ └── service │ │ │ ├── PersonService.java │ │ │ └── impl │ │ │ └── PersonServiceImpl.java │ │ ├── resources │ │ ├── db.properties │ │ ├── logback.xml │ │ └── spring │ │ │ ├── root-context.xml │ │ │ └── security-context.xml │ │ └── webapp │ │ └── WEB-INF │ │ ├── rest-servlet.xml │ │ └── web.xml └── target │ ├── .gitignore │ └── m2e-wtp │ └── web-resources │ └── .gitignore └── pom.xml /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | OAuth 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /AuthServer/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /AuthServer/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | AuthServer 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.springframework.ide.eclipse.core.springbuilder 25 | 26 | 27 | 28 | 29 | org.eclipse.wst.validation.validationbuilder 30 | 31 | 32 | 33 | 34 | org.eclipse.m2e.core.maven2Builder 35 | 36 | 37 | 38 | 39 | 40 | org.eclipse.jem.workbench.JavaEMFNature 41 | org.eclipse.wst.common.modulecore.ModuleCoreNature 42 | org.springframework.ide.eclipse.core.springnature 43 | org.eclipse.jdt.core.javanature 44 | org.eclipse.m2e.core.maven2Nature 45 | org.eclipse.wst.common.project.facet.core.nature 46 | org.eclipse.wst.jsdt.core.jsNature 47 | 48 | 49 | -------------------------------------------------------------------------------- /AuthServer/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /AuthServer/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 4 | org.eclipse.jdt.core.compiler.compliance=1.5 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 8 | org.eclipse.jdt.core.compiler.source=1.5 9 | -------------------------------------------------------------------------------- /AuthServer/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /AuthServer/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /AuthServer/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AuthServer/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /AuthServer/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /AuthServer/.springBeans: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1 4 | 5 | 6 | 7 | 8 | 9 | 10 | src/main/webapp/WEB-INF/spring-servlet.xml 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /AuthServer/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.spring.test 6 | Spring_REST_OAuth 7 | 0.0.1-SNAPSHOT 8 | 9 | AuthServer 10 | war 11 | -------------------------------------------------------------------------------- /AuthServer/src/main/java/org/spring/aspect/LoggerAspect.java: -------------------------------------------------------------------------------- 1 | package org.spring.aspect; 2 | 3 | import java.util.Date; 4 | 5 | import org.apache.commons.beanutils.BeanUtils; 6 | import org.aspectj.lang.ProceedingJoinPoint; 7 | import org.aspectj.lang.annotation.Around; 8 | import org.aspectj.lang.annotation.Aspect; 9 | import org.aspectj.lang.annotation.Pointcut; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | @Aspect 14 | public class LoggerAspect { 15 | private static final Logger logger = LoggerFactory 16 | .getLogger(LoggerAspect.class); 17 | 18 | @Pointcut("@annotation(org.springframework.stereotype.Controller)") 19 | public void controllerBean() { 20 | } 21 | 22 | @Pointcut("@annotation(org.springframework.stereotype.Service)") 23 | public void serviceBean() { 24 | } 25 | 26 | @Pointcut("@annotation(org.springframework.stereotype.Repository)") 27 | public void repositoryBean() { 28 | } 29 | 30 | @Pointcut("within(org.spring..*)") 31 | public void methodPointcut() { 32 | } 33 | 34 | @Around("controllerBean() && methodPointcut()") 35 | public Object aroundControllerMethod(ProceedingJoinPoint joinPoint) 36 | throws Throwable { 37 | logger.debug(">>>>>>>> invoking {}", joinPoint.getSignature()); 38 | Date start = new Date(); 39 | Object result = joinPoint.proceed(); 40 | Date end = new Date(); 41 | logger.debug(">>>>>>>> return of {} with {}", joinPoint.getSignature(), 42 | BeanUtils.describe(result)); 43 | logger.debug(">>>>>>>> end of {} take {} millisec", 44 | joinPoint.getSignature(), end.getTime() - start.getTime()); 45 | return result; 46 | } 47 | 48 | @Around("serviceBean() && methodPointcut()") 49 | public Object aroundServiceMethod(ProceedingJoinPoint joinPoint) 50 | throws Throwable { 51 | logger.debug(">>>>>>>> invoking {}", joinPoint.getSignature()); 52 | Date start = new Date(); 53 | Object result = joinPoint.proceed(); 54 | Date end = new Date(); 55 | logger.debug(">>>>>>>> return of {} with {}", joinPoint.getSignature(), 56 | BeanUtils.describe(result)); 57 | logger.debug(">>>>>>>> end of {} take {} millisec", 58 | joinPoint.getSignature(), end.getTime() - start.getTime()); 59 | return result; 60 | } 61 | 62 | @Around("repositoryBean() && methodPointcut()") 63 | public Object aroundRepositoryMethod(ProceedingJoinPoint joinPoint) 64 | throws Throwable { 65 | logger.debug(">>>>>>>> invoking {}", joinPoint.getSignature()); 66 | Date start = new Date(); 67 | Object result = joinPoint.proceed(); 68 | Date end = new Date(); 69 | logger.debug(">>>>>>>> return of {} with {}", joinPoint.getSignature(), 70 | BeanUtils.describe(result)); 71 | logger.debug(">>>>>>>> end of {} take {} millisec", 72 | joinPoint.getSignature(), end.getTime() - start.getTime()); 73 | return result; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /AuthServer/src/main/java/org/spring/web/controller/AccessConfirmationController.java: -------------------------------------------------------------------------------- 1 | package org.spring.web.controller; 2 | 3 | import java.util.Map; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.security.oauth2.provider.AuthorizationRequest; 7 | import org.springframework.security.oauth2.provider.ClientDetails; 8 | import org.springframework.security.oauth2.provider.ClientDetailsService; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.SessionAttributes; 12 | import org.springframework.web.servlet.ModelAndView; 13 | 14 | /** 15 | * Controller for retrieving the model for and displaying the confirmation page for access to a protected resource. 16 | * 17 | * @author Ryan Heaton 18 | */ 19 | @Controller 20 | @SessionAttributes("authorizationRequest") 21 | public class AccessConfirmationController { 22 | 23 | private ClientDetailsService clientDetailsService; 24 | 25 | @RequestMapping("/oauth/confirm_access") 26 | public ModelAndView getAccessConfirmation(Map model) throws Exception { 27 | AuthorizationRequest clientAuth = (AuthorizationRequest) model.remove("authorizationRequest"); 28 | ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId()); 29 | model.put("auth_request", clientAuth); 30 | model.put("client", client); 31 | return new ModelAndView("access_confirmation", model); 32 | } 33 | 34 | @RequestMapping("/oauth/error") 35 | public String handleError(Map model) throws Exception { 36 | // We can add more stuff to the model here for JSP rendering. If the client was a machine then 37 | // the JSON will already have been rendered. 38 | model.put("message", "There was a problem with the OAuth2 protocol"); 39 | return "oauth_error"; 40 | } 41 | 42 | @Autowired 43 | public void setClientDetailsService(ClientDetailsService clientDetailsService) { 44 | this.clientDetailsService = clientDetailsService; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /AuthServer/src/main/java/org/spring/web/controller/AdminController.java: -------------------------------------------------------------------------------- 1 | package org.spring.web.controller; 2 | 3 | import java.security.Principal; 4 | import java.util.ArrayList; 5 | import java.util.Collection; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.security.access.AccessDeniedException; 13 | import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; 14 | import org.springframework.security.oauth2.common.OAuth2AccessToken; 15 | import org.springframework.security.oauth2.provider.OAuth2Authentication; 16 | import org.springframework.security.oauth2.provider.token.ConsumerTokenServices; 17 | import org.springframework.stereotype.Controller; 18 | import org.springframework.web.bind.annotation.PathVariable; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RequestMethod; 21 | import org.springframework.web.bind.annotation.ResponseBody; 22 | 23 | /** 24 | * Controller for resetting the token store for testing purposes. 25 | * 26 | * @author Dave Syer 27 | */ 28 | @Controller 29 | public class AdminController { 30 | 31 | @Autowired 32 | private ConsumerTokenServices tokenServices; 33 | 34 | @RequestMapping("/oauth/tokenManagment") 35 | public String tokenManagment() { 36 | return "tokenManagment"; 37 | } 38 | 39 | @RequestMapping("/oauth/users/{user}/tokens") 40 | @ResponseBody 41 | public Collection listTokensForUser( 42 | @PathVariable String user, Principal principal) throws Exception { 43 | checkResourceOwner(user, principal); 44 | return enhance(tokenServices.findTokensByUserName(user)); 45 | } 46 | 47 | @RequestMapping(value = "/oauth/users/{user}/tokens/{token}", method = RequestMethod.DELETE) 48 | public ResponseEntity revokeToken(@PathVariable String user, 49 | @PathVariable String token, Principal principal) throws Exception { 50 | checkResourceOwner(user, principal); 51 | if (tokenServices.revokeToken(token)) { 52 | return new ResponseEntity(HttpStatus.NO_CONTENT); 53 | } else { 54 | return new ResponseEntity(HttpStatus.NOT_FOUND); 55 | } 56 | } 57 | 58 | @RequestMapping("/oauth/clients/{client}/tokens") 59 | @ResponseBody 60 | public Collection listTokensForClient( 61 | @PathVariable String client) throws Exception { 62 | return enhance(tokenServices.findTokensByClientId(client)); 63 | } 64 | 65 | private Collection enhance( 66 | Collection tokens) { 67 | Collection result = new ArrayList(); 68 | for (OAuth2AccessToken prototype : tokens) { 69 | DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken( 70 | prototype); 71 | String clientId = tokenServices.getClientId(token.getValue()); 72 | if (clientId != null) { 73 | Map map = new HashMap( 74 | token.getAdditionalInformation()); 75 | map.put("client_id", clientId); 76 | token.setAdditionalInformation(map); 77 | result.add(token); 78 | } 79 | } 80 | return result; 81 | } 82 | 83 | private void checkResourceOwner(String user, Principal principal) { 84 | if (principal instanceof OAuth2Authentication) { 85 | OAuth2Authentication authentication = (OAuth2Authentication) principal; 86 | if (!authentication.isClientOnly() 87 | && !user.equals(principal.getName())) { 88 | throw new AccessDeniedException(String.format( 89 | "User '%s' cannot obtain tokens for user '%s'", 90 | principal.getName(), user)); 91 | } 92 | } 93 | } 94 | 95 | /** 96 | * @param tokenServices 97 | * the consumerTokenServices to set 98 | */ 99 | public void setTokenServices(ConsumerTokenServices tokenServices) { 100 | this.tokenServices = tokenServices; 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /AuthServer/src/main/java/org/spring/web/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package org.spring.web.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | @Controller 7 | public class LoginController { 8 | 9 | @RequestMapping("login") 10 | public String login() { 11 | return "login"; 12 | } 13 | 14 | @RequestMapping("logout") 15 | public String logout() { 16 | return "logout"; 17 | } 18 | 19 | @RequestMapping("index") 20 | public String index() { 21 | return "index"; 22 | } 23 | 24 | @RequestMapping("request_token_authorized") 25 | public String request_token_authorized() { 26 | return "request_token_authorized"; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /AuthServer/src/main/resources/db.properties: -------------------------------------------------------------------------------- 1 | db.driver=com.mysql.jdbc.Driver 2 | db.jdbcurl=jdbc:mysql://localhost:3306/test 3 | db.username=root 4 | db.password=123456 -------------------------------------------------------------------------------- /AuthServer/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /AuthServer/src/main/resources/messages_ar.properties: -------------------------------------------------------------------------------- 1 | lable.title=\u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u062A\u0637\u0628\u064A\u0642 -------------------------------------------------------------------------------- /AuthServer/src/main/resources/messages_en.properties: -------------------------------------------------------------------------------- 1 | lable.title=Title Web App -------------------------------------------------------------------------------- /AuthServer/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | --CREATE SEQUENCE seq_person; 2 | --CREATE SEQUENCE seq_app_user; 3 | 4 | create table PERSON(ID INTEGER NOT NULL,FIRST_NAME VARCHAR(100),LAST_NAME VARCHAR(100),NUMBER INTEGER,BRITH_DATE DATE); 5 | 6 | create table users( 7 | username varchar_ignorecase(50) not null primary key, 8 | password varchar_ignorecase(50) not null, 9 | enabled boolean not null); 10 | 11 | create table authorities ( 12 | username varchar_ignorecase(50) not null, 13 | authority varchar_ignorecase(50) not null, 14 | constraint fk_authorities_users foreign key(username) references users(username)); 15 | create unique index ix_auth_username on authorities (username,authority); 16 | 17 | create table groups ( 18 | id bigint generated by default as identity(start with 0) primary key, 19 | group_name varchar_ignorecase(50) not null); 20 | 21 | create table group_authorities ( 22 | group_id bigint not null, 23 | authority varchar(50) not null, 24 | constraint fk_group_authorities_group foreign key(group_id) references groups(id)); 25 | 26 | create table group_members ( 27 | id bigint generated by default as identity(start with 0) primary key, 28 | username varchar(50) not null, 29 | group_id bigint not null, 30 | constraint fk_group_members_group foreign key(group_id) references groups(id)); 31 | -- Persistent Login (Remember-Me) Schema 32 | create table persistent_logins ( 33 | username varchar(64) not null, 34 | series varchar(64) primary key, 35 | token varchar(64) not null, 36 | last_used timestamp not null); 37 | 38 | 39 | create table oauth_client_details ( 40 | client_id VARCHAR(256) PRIMARY KEY, 41 | resource_ids VARCHAR(256), 42 | client_secret VARCHAR(256), 43 | scope VARCHAR(256), 44 | authorized_grant_types VARCHAR(256), 45 | web_server_redirect_uri VARCHAR(256), 46 | authorities VARCHAR(256), 47 | access_token_validity INTEGER, 48 | refresh_token_validity INTEGER, 49 | additional_information VARCHAR(4096) 50 | ); 51 | 52 | create table oauth_client_token ( 53 | token_id VARCHAR(256), 54 | token LONGVARBINARY, 55 | authentication_id VARCHAR(256), 56 | user_name VARCHAR(256), 57 | client_id VARCHAR(256) 58 | ); 59 | 60 | create table oauth_access_token ( 61 | token_id VARCHAR(256), 62 | token LONGVARBINARY, 63 | authentication_id VARCHAR(256), 64 | user_name VARCHAR(256), 65 | client_id VARCHAR(256), 66 | authentication LONGVARBINARY, 67 | refresh_token VARCHAR(256) 68 | ); 69 | 70 | create table oauth_refresh_token ( 71 | token_id VARCHAR(256), 72 | token LONGVARBINARY, 73 | authentication LONGVARBINARY 74 | ); 75 | 76 | create table oauth_code ( 77 | code VARCHAR(256), authentication LONGVARBINARY 78 | ); 79 | 80 | -- customized oauth_client_details table 81 | create table ClientDetails ( 82 | appId VARCHAR(256) PRIMARY KEY, 83 | resourceIds VARCHAR(256), 84 | appSecret VARCHAR(256), 85 | scope VARCHAR(256), 86 | grantTypes VARCHAR(256), 87 | redirectUrl VARCHAR(256), 88 | authorities VARCHAR(256), 89 | access_token_validity INTEGER, 90 | refresh_token_validity INTEGER, 91 | additionalInformation VARCHAR(4096) 92 | ); 93 | ALTER TABLE PERSON ADD PRIMARY KEY (ID); 94 | -------------------------------------------------------------------------------- /AuthServer/src/main/resources/schema_MySql.sql: -------------------------------------------------------------------------------- 1 | drop table if exists person; 2 | drop table if exists authorities; 3 | drop table if exists group_members; 4 | drop table if exists group_authorities; 5 | drop table if exists groups; 6 | drop table if exists oauth_refresh_token; 7 | drop table if exists oauth_access_token; 8 | drop table if exists oauth_client_token; 9 | drop table if exists oauth_client_details; 10 | drop table if exists oauth_code; 11 | drop table if exists ClientDetails; 12 | drop table if exists users; 13 | 14 | create table if not exists person(ID INTEGER NOT NULL primary key,FIRST_NAME VARCHAR(100),LAST_NAME VARCHAR(100),NUMBER INTEGER,BRITH_DATE DATE); 15 | 16 | create table if not exists users( 17 | username varchar(50) not null primary key, 18 | password varchar(50) not null, 19 | enabled boolean not null); 20 | 21 | create table if not exists authorities ( 22 | username varchar(50) not null, 23 | authority varchar(50) not null, 24 | constraint fk_authorities_users foreign key(username) references users(username), 25 | unique index ix_auth_username (username,authority) 26 | ); 27 | 28 | #create unique index ix_auth_username on authorities (username,authority); 29 | 30 | 31 | create table if not exists groups ( 32 | id BIGINT AUTO_INCREMENT primary key, 33 | group_name varchar(50) not null); 34 | 35 | create table if not exists group_authorities ( 36 | group_id bigint not null, 37 | authority varchar(50) not null, 38 | constraint fk_group_authorities_group foreign key(group_id) references groups(id)); 39 | 40 | create table if not exists group_members ( 41 | id BIGINT AUTO_INCREMENT primary key, 42 | username varchar(50) not null, 43 | group_id bigint not null, 44 | constraint fk_group_members_group foreign key(group_id) references groups(id)); 45 | 46 | create table if not exists persistent_logins ( 47 | username varchar(64) not null, 48 | series varchar(64) primary key, 49 | token varchar(64) not null, 50 | last_used timestamp not null); 51 | 52 | 53 | create table if not exists oauth_client_details ( 54 | client_id VARCHAR(128) PRIMARY KEY, 55 | resource_ids VARCHAR(128), 56 | client_secret VARCHAR(128), 57 | scope VARCHAR(128), 58 | authorized_grant_types VARCHAR(128), 59 | web_server_redirect_uri VARCHAR(128), 60 | authorities VARCHAR(128), 61 | access_token_validity INTEGER, 62 | refresh_token_validity INTEGER, 63 | additional_information VARCHAR(128) 64 | ); 65 | 66 | create table if not exists oauth_client_token ( 67 | token_id VARCHAR(256), 68 | token longblob, 69 | authentication_id VARCHAR(256), 70 | user_name VARCHAR(256), 71 | client_id VARCHAR(256) 72 | ); 73 | 74 | create table if not exists oauth_access_token ( 75 | token_id VARCHAR(256), 76 | token longblob, 77 | authentication_id VARCHAR(256), 78 | user_name VARCHAR(256), 79 | client_id VARCHAR(256), 80 | authentication longblob, 81 | refresh_token VARCHAR(256) 82 | ); 83 | 84 | create table if not exists oauth_refresh_token ( 85 | token_id VARCHAR(256), 86 | token longblob, 87 | authentication longblob 88 | ); 89 | 90 | create table if not exists oauth_code ( 91 | code VARCHAR(256), authentication longblob 92 | ); 93 | 94 | create table if not exists ClientDetails ( 95 | appId VARCHAR(128) PRIMARY KEY, 96 | resourceIds VARCHAR(128), 97 | appSecret VARCHAR(128), 98 | scope VARCHAR(128), 99 | grantTypes VARCHAR(128), 100 | redirectUrl VARCHAR(128), 101 | authorities VARCHAR(128), 102 | access_token_validity INTEGER, 103 | refresh_token_validity INTEGER, 104 | additionalInformation VARCHAR(256) 105 | ); -------------------------------------------------------------------------------- /AuthServer/src/main/resources/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 37 | 38 | 40 | 41 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /AuthServer/src/main/resources/spring/security-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 19 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | 29 | 31 | 33 | 35 | 36 | 37 | 38 | 40 | 42 | 44 | 45 | 47 | 48 | 50 | 51 | 53 | 54 | 55 | 56 | 57 | 58 | 60 | 61 | 62 | 64 | 65 | 66 | 67 | 69 | 70 | 71 | 72 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 83 | 84 | 85 | 86 | 88 | 90 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 106 | 107 | 108 | 109 | 111 | 112 | 113 | 114 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /AuthServer/src/main/resources/test-data.sql: -------------------------------------------------------------------------------- 1 | insert into person values (1,'firstName','lastName',3,'2008-08-22') ; 2 | insert into person values (2,'firstName','lastName',3,'2008-08-22') ; 3 | insert into person values (3,'firstName','lastName',3,'2008-08-22') ; 4 | insert into person values (4,'firstName','lastName',3,'2008-08-22') ; 5 | insert into person values (5,'firstName','lastName',3,'2008-08-22') ; 6 | insert into person values (6,'firstName','lastName',3,'2008-08-22') ; 7 | insert into person values (7,'firstName','lastName',3,'2008-08-22') ; 8 | insert into person values (8,'firstName','lastName',3,'2008-08-22') ; 9 | insert into person values (9,'firstName','lastName',3,'2008-08-22') ; 10 | insert into person values (10,'firstName','lastName',3,'2008-08-22') ; 11 | insert into person values (11,'firstName','lastName',3,'2008-08-22') ; 12 | insert into person values (12,'firstName','lastName',3,'2008-08-22') ; 13 | 14 | insert into users values ('user_01','5f4dcc3b5aa765d61d8327deb882cf99',1) ; 15 | insert into users values ('user_02','5f4dcc3b5aa765d61d8327deb882cf99',1) ; 16 | 17 | insert into authorities values ('user_01','ROLE_USER') ; 18 | insert into authorities values ('user_01','ROLE_CLIENT') ; 19 | insert into authorities values ('user_02','ROLE_USER') ; 20 | insert into authorities values ('user_02','ROLE_CLIENT') ; 21 | insert into authorities values ('user_02','ROLE_ADMIN') ; 22 | insert into authorities values ('user_02','ROLE_TRUSTED_CLIENT') ; 23 | 24 | insert into oauth_client_details values ('client1',null,null,'read,write,delete','password,authorization_code,refresh_token,implicit',null,'ROLE_CLIENT, ROLE_TRUSTED_CLIENT',null,null,null) ; 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /AuthServer/src/main/resources/theme-black.properties: -------------------------------------------------------------------------------- 1 | css=themes/black.css 2 | key=key -------------------------------------------------------------------------------- /AuthServer/src/main/resources/theme-blue.properties: -------------------------------------------------------------------------------- 1 | css=themes/blue.css 2 | key=key -------------------------------------------------------------------------------- /AuthServer/src/main/resources/theme-default.properties: -------------------------------------------------------------------------------- 1 | css=themes/default.css -------------------------------------------------------------------------------- /AuthServer/src/main/resources/theme-green.properties: -------------------------------------------------------------------------------- 1 | css=themes/green.css -------------------------------------------------------------------------------- /AuthServer/src/main/resources/theme-red.properties: -------------------------------------------------------------------------------- 1 | css=themes/red.css -------------------------------------------------------------------------------- /AuthServer/src/main/resources/theme-yellow.properties: -------------------------------------------------------------------------------- 1 | css=themes/yellow.css -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/WEB-INF/jsp/access_confirmation.jsp: -------------------------------------------------------------------------------- 1 | <%@ page 2 | import="org.springframework.security.core.AuthenticationException"%> 3 | <%@ page 4 | import="org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter"%> 5 | <%@ page 6 | import="org.springframework.security.oauth2.common.exceptions.UnapprovedClientAuthenticationException"%> 7 | <%@ taglib prefix="authz" 8 | uri="http://www.springframework.org/security/tags"%> 9 | <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> 10 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 11 | 12 | 13 | 14 | 15 | REST 16 | 18 | 19 | 20 | 21 | 22 |

REST

23 | 24 |
25 | 26 | <% 27 | if (session 28 | .getAttribute(AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY) != null 29 | && !(session 30 | .getAttribute(AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY) instanceof UnapprovedClientAuthenticationException)) { 31 | %> 32 |
33 |

Woops!

34 | 35 |

36 | Access could not be granted. (<%=((AuthenticationException) session 37 | .getAttribute(AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)) 38 | .getMessage()%>) 39 |

40 |
41 | <% 42 | } 43 | %> 44 | 45 | 46 | 47 |

Please Confirm

48 | 49 |

50 | You hereby authorize " 51 | 52 | " to access your protected resources with scopes : 53 |

54 |
    55 | 56 |
  • ${scope}
  • 57 |
    58 |
59 | 60 | 61 | 62 |
64 | 66 |
67 |
69 | 71 |
72 |
73 |
74 | 75 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/WEB-INF/jsp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html;charset=UTF-8" language="java"%> 2 | <%@page isELIgnored="false"%> 3 | <%@ taglib prefix="authz" 4 | uri="http://www.springframework.org/security/tags"%> 5 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 6 | <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> 7 | 8 | 9 | 10 | 11 | REST 12 | " type="text/css" /> 13 | 14 | 15 | 16 |

REST

17 | 18 |
19 |

Home

20 | 21 |

Login

22 |
" method="post"> 24 |

25 | 27 |

28 |

29 | 31 |

32 | 33 |

34 | 35 |

36 |
37 |
38 | 39 |
40 |
"> 41 | 42 |
43 |
44 |
45 |
46 | 47 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/WEB-INF/jsp/login.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 2 | <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> 3 | 4 | 5 | 6 | 7 | REST 8 | 9 | 10 | 11 | 12 | 13 | 14 |

REST

15 | 16 |
17 | 18 |

Woops!

19 | 20 |

Your login attempt was not successful.

21 |
22 | 23 |

Woops!

24 | 25 |

You are not permitted to access that resource.

26 |
27 | 28 |

Login

29 | 30 |
" method="post"> 32 |

33 | 35 |

36 |

37 | 39 |

40 | 41 |

42 | 43 |

44 |
45 |
46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/WEB-INF/jsp/oauth_error.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 2 | 3 | 4 | 5 | 6 | REST 7 | "/> 8 | 9 | 10 | 11 | 12 |

REST OAuth2 Error

13 | 14 |
15 |

()

16 |

Please go back to your client application and try again, or contact the owner and ask for support

17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/WEB-INF/jsp/register/client.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html;charset=UTF-8" language="java"%> 2 | <%@page isELIgnored="false"%> 3 | <%@ taglib prefix="authz" 4 | uri="http://www.springframework.org/security/tags"%> 5 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 6 | <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Register Client 16 | " type="text/css" /> 17 | 18 | 19 |

Register Client

20 | 21 |
23 |

24 | 26 |

27 |

28 | 30 |

31 | 32 |

33 | 34 |

35 |
36 |
37 | 38 | -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/WEB-INF/jsp/request_token_authorized.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 3 | 4 | 5 | 6 | 7 | REST 8 | "/> 9 | 10 | 11 | 12 | 13 |

REST

14 | 15 |
16 |

Home

17 | 18 |

You have successfully authorized the request for a protected resource.

19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/WEB-INF/jsp/tokenManagment.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=utf-8" 2 | pageEncoding="utf-8"%> 3 | <%@ taglib prefix="security" 4 | uri="http://www.springframework.org/security/tags"%> 5 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 6 | 7 | 8 | 9 | 10 | 11 | Token Managment of - <security:authentication 12 | property="principal.username" /> 13 | 14 | " 16 | rel="stylesheet"> 17 | 18 | 19 | 20 | <% 21 | String url = request.getScheme() + "://" + request.getServerName() 22 | + ":" + request.getServerPort() + request.getContextPath(); 23 | %> 24 | 25 | 79 | 80 | 81 |

82 | Token Managment of - 83 | 84 |

85 |
86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
TokenTypeclient_idAccess TokenRefresh TokenScopeDelete
100 |
101 | 102 | -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/WEB-INF/spring-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | /index 8 | 9 | 10 | contextConfigLocation 11 | 12 | classpath:spring/root-context.xml 13 | 14 | 15 | 16 | org.springframework.web.context.request.RequestContextListener 17 | 18 | 19 | org.springframework.web.context.ContextLoaderListener 20 | 21 | 22 | springSecurityFilterChain 23 | org.springframework.web.filter.DelegatingFilterProxy 24 | 25 | 26 | springSecurityFilterChain 27 | /* 28 | 29 | 30 | spring 31 | org.springframework.web.servlet.DispatcherServlet 32 | 1 33 | 34 | 35 | spring 36 | / 37 | 38 | 39 | -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/images/bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/images/bg.gif -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/images/header.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/images/header.jpg -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/style.css: -------------------------------------------------------------------------------- 1 | /* CSS Document */ 2 | 3 | body { 4 | color: white; 5 | font-family: 'Trebuchet MS', Helvetica, sans-serif; 6 | font-size: 12px; 7 | margin: 0 auto; 8 | width: 736px; 9 | background: url( 'images/bg.gif' ); 10 | } 11 | 12 | #content { 13 | background: #3d3d3d; 14 | width: 676px; 15 | margin-top: 20px; 16 | padding: 0 30px 25px 30px; 17 | } 18 | 19 | a { 20 | color: lightblue; 21 | text-decoration: none; 22 | } 23 | 24 | a:hover { 25 | color: red; 26 | text-decoration: none; 27 | } 28 | 29 | h1 { 30 | background: url( 'images/header.jpg' ); 31 | height: 36px; 32 | width: 721px; 33 | margin: 0 0 1em 0; 34 | padding-top: 80px; 35 | padding-left: 15px; 36 | font-size: 1.8em; 37 | font-variant: small-caps; 38 | } 39 | 40 | h2 { 41 | font-size: 1.2em; 42 | margin-left: -10px; 43 | padding-top: 20px; 44 | font-weight: bold; 45 | letter-spacing: .3px; 46 | } 47 | 48 | .error h2 { 49 | color: red; 50 | font-size: 1.2em; 51 | padding-top: 20px; 52 | font-weight: bold; 53 | letter-spacing: .3px; 54 | } 55 | 56 | .error p { 57 | color: red; 58 | } 59 | 60 | p { 61 | letter-spacing: .2px; 62 | } 63 | 64 | label { 65 | text-indent: 20px; 66 | letter-spacing: .2px; 67 | padding: 5px 5px 5px 5px; 68 | } 69 | 70 | #footer { 71 | font-size: .8em; 72 | margin-top: 1em; 73 | } 74 | 75 | #footer a { 76 | color: #333333; 77 | font-weight: bold; 78 | font-size: 1em 79 | } 80 | 81 | #footer a:hover { 82 | color: red; 83 | font-weight: bold; 84 | font-size: 1em 85 | } -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-icons_a83300_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-icons_a83300_256x240.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-icons_cccccc_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-icons_cccccc_256x240.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/resources/css/ui-darkness/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/black.css: -------------------------------------------------------------------------------- 1 | /* CSS Document */ 2 | 3 | body { 4 | color: white; 5 | font-family: 'Trebuchet MS', Helvetica, sans-serif; 6 | font-size: 12px; 7 | margin: 0 auto; 8 | width: 736px; 9 | background: url( 'images/bg.gif' ); 10 | } 11 | 12 | #content { 13 | background: black; 14 | width: 676px; 15 | margin-top: 20px; 16 | padding: 0 30px 25px 30px; 17 | } 18 | 19 | a { 20 | color: lightblue; 21 | text-decoration: none; 22 | } 23 | 24 | a:hover { 25 | color: red; 26 | text-decoration: none; 27 | } 28 | 29 | h1 { 30 | background: url( 'images/header_black.jpg' ); 31 | height: 36px; 32 | width: 721px; 33 | margin: 0 0 1em 0; 34 | padding-top: 80px; 35 | padding-left: 15px; 36 | font-size: 1.8em; 37 | font-variant: small-caps; 38 | } 39 | 40 | h2 { 41 | font-size: 1.2em; 42 | margin-left: -10px; 43 | padding-top: 20px; 44 | font-weight: bold; 45 | letter-spacing: .3px; 46 | } 47 | 48 | .error h2 { 49 | color: red; 50 | font-size: 1.2em; 51 | padding-top: 20px; 52 | font-weight: bold; 53 | letter-spacing: .3px; 54 | } 55 | 56 | .error p { 57 | color: red; 58 | } 59 | 60 | p { 61 | letter-spacing: .2px; 62 | } 63 | 64 | label { 65 | text-indent: 20px; 66 | letter-spacing: .2px; 67 | padding: 5px 5px 5px 5px; 68 | } 69 | 70 | #footer { 71 | font-size: .8em; 72 | margin-top: 1em; 73 | } 74 | 75 | #footer a { 76 | color: #333333; 77 | font-weight: bold; 78 | font-size: 1em 79 | } 80 | 81 | #footer a:hover { 82 | color: red; 83 | font-weight: bold; 84 | font-size: 1em 85 | } -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/blue.css: -------------------------------------------------------------------------------- 1 | /* CSS Document */ 2 | 3 | body { 4 | color: white; 5 | font-family: 'Trebuchet MS', Helvetica, sans-serif; 6 | font-size: 12px; 7 | margin: 0 auto; 8 | width: 736px; 9 | background: url( 'images/bg.gif' ); 10 | } 11 | 12 | #content { 13 | background: blue; 14 | width: 676px; 15 | margin-top: 20px; 16 | padding: 0 30px 25px 30px; 17 | } 18 | 19 | a { 20 | color: lightblue; 21 | text-decoration: none; 22 | } 23 | 24 | a:hover { 25 | color: red; 26 | text-decoration: none; 27 | } 28 | 29 | h1 { 30 | background: url( 'images/header_blue.jpg' ); 31 | height: 36px; 32 | width: 721px; 33 | margin: 0 0 1em 0; 34 | padding-top: 80px; 35 | padding-left: 15px; 36 | font-size: 1.8em; 37 | font-variant: small-caps; 38 | } 39 | 40 | h2 { 41 | font-size: 1.2em; 42 | margin-left: -10px; 43 | padding-top: 20px; 44 | font-weight: bold; 45 | letter-spacing: .3px; 46 | } 47 | 48 | .error h2 { 49 | color: red; 50 | font-size: 1.2em; 51 | padding-top: 20px; 52 | font-weight: bold; 53 | letter-spacing: .3px; 54 | } 55 | 56 | .error p { 57 | color: red; 58 | } 59 | 60 | p { 61 | letter-spacing: .2px; 62 | } 63 | 64 | label { 65 | text-indent: 20px; 66 | letter-spacing: .2px; 67 | padding: 5px 5px 5px 5px; 68 | } 69 | 70 | #footer { 71 | font-size: .8em; 72 | margin-top: 1em; 73 | } 74 | 75 | #footer a { 76 | color: #333333; 77 | font-weight: bold; 78 | font-size: 1em 79 | } 80 | 81 | #footer a:hover { 82 | color: red; 83 | font-weight: bold; 84 | font-size: 1em 85 | } -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/default.css: -------------------------------------------------------------------------------- 1 | /* CSS Document */ 2 | 3 | body { 4 | color: white; 5 | font-family: 'Trebuchet MS', Helvetica, sans-serif; 6 | font-size: 12px; 7 | margin: 0 auto; 8 | width: 736px; 9 | background: url( 'images/bg.gif' ); 10 | } 11 | 12 | #content { 13 | background: red; 14 | width: 676px; 15 | margin-top: 20px; 16 | padding: 0 30px 25px 30px; 17 | } 18 | 19 | a { 20 | color: lightblue; 21 | text-decoration: none; 22 | } 23 | 24 | a:hover { 25 | color: red; 26 | text-decoration: none; 27 | } 28 | 29 | h1 { 30 | background: url( 'images/header_red.jpg' ); 31 | height: 36px; 32 | width: 721px; 33 | margin: 0 0 1em 0; 34 | padding-top: 80px; 35 | padding-left: 15px; 36 | font-size: 1.8em; 37 | font-variant: small-caps; 38 | } 39 | 40 | h2 { 41 | font-size: 1.2em; 42 | margin-left: -10px; 43 | padding-top: 20px; 44 | font-weight: bold; 45 | letter-spacing: .3px; 46 | } 47 | 48 | .error h2 { 49 | color: red; 50 | font-size: 1.2em; 51 | padding-top: 20px; 52 | font-weight: bold; 53 | letter-spacing: .3px; 54 | } 55 | 56 | .error p { 57 | color: red; 58 | } 59 | 60 | p { 61 | letter-spacing: .2px; 62 | } 63 | 64 | label { 65 | text-indent: 20px; 66 | letter-spacing: .2px; 67 | padding: 5px 5px 5px 5px; 68 | } 69 | 70 | #footer { 71 | font-size: .8em; 72 | margin-top: 1em; 73 | } 74 | 75 | #footer a { 76 | color: #333333; 77 | font-weight: bold; 78 | font-size: 1em 79 | } 80 | 81 | #footer a:hover { 82 | color: red; 83 | font-weight: bold; 84 | font-size: 1em 85 | } -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/green.css: -------------------------------------------------------------------------------- 1 | /* CSS Document */ 2 | 3 | body { 4 | color: white; 5 | font-family: 'Trebuchet MS', Helvetica, sans-serif; 6 | font-size: 12px; 7 | margin: 0 auto; 8 | width: 736px; 9 | background: url( 'images/bg.gif' ); 10 | } 11 | 12 | #content { 13 | background: green; 14 | width: 676px; 15 | margin-top: 20px; 16 | padding: 0 30px 25px 30px; 17 | } 18 | 19 | a { 20 | color: lightblue; 21 | text-decoration: none; 22 | } 23 | 24 | a:hover { 25 | color: red; 26 | text-decoration: none; 27 | } 28 | 29 | h1 { 30 | background: url( 'images/header_green.jpg' ); 31 | height: 36px; 32 | width: 721px; 33 | margin: 0 0 1em 0; 34 | padding-top: 80px; 35 | padding-left: 15px; 36 | font-size: 1.8em; 37 | font-variant: small-caps; 38 | } 39 | 40 | h2 { 41 | font-size: 1.2em; 42 | margin-left: -10px; 43 | padding-top: 20px; 44 | font-weight: bold; 45 | letter-spacing: .3px; 46 | } 47 | 48 | .error h2 { 49 | color: red; 50 | font-size: 1.2em; 51 | padding-top: 20px; 52 | font-weight: bold; 53 | letter-spacing: .3px; 54 | } 55 | 56 | .error p { 57 | color: red; 58 | } 59 | 60 | p { 61 | letter-spacing: .2px; 62 | } 63 | 64 | label { 65 | text-indent: 20px; 66 | letter-spacing: .2px; 67 | padding: 5px 5px 5px 5px; 68 | } 69 | 70 | #footer { 71 | font-size: .8em; 72 | margin-top: 1em; 73 | } 74 | 75 | #footer a { 76 | color: #333333; 77 | font-weight: bold; 78 | font-size: 1em 79 | } 80 | 81 | #footer a:hover { 82 | color: red; 83 | font-weight: bold; 84 | font-size: 1em 85 | } -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/images/bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/themes/images/bg.gif -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/images/header.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/themes/images/header.jpg -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/images/header_black.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/themes/images/header_black.jpg -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/images/header_blue.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/themes/images/header_blue.jpg -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/images/header_green.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/themes/images/header_green.jpg -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/images/header_red.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/themes/images/header_red.jpg -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/images/header_yellow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/AuthServer/src/main/webapp/themes/images/header_yellow.jpg -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/red.css: -------------------------------------------------------------------------------- 1 | /* CSS Document */ 2 | 3 | body { 4 | color: white; 5 | font-family: 'Trebuchet MS', Helvetica, sans-serif; 6 | font-size: 12px; 7 | margin: 0 auto; 8 | width: 736px; 9 | background: url( 'images/bg.gif' ); 10 | } 11 | 12 | #content { 13 | background: red; 14 | width: 676px; 15 | margin-top: 20px; 16 | padding: 0 30px 25px 30px; 17 | } 18 | 19 | a { 20 | color: lightblue; 21 | text-decoration: none; 22 | } 23 | 24 | a:hover { 25 | color: red; 26 | text-decoration: none; 27 | } 28 | 29 | h1 { 30 | background: url( 'images/header_red.jpg' ); 31 | height: 36px; 32 | width: 721px; 33 | margin: 0 0 1em 0; 34 | padding-top: 80px; 35 | padding-left: 15px; 36 | font-size: 1.8em; 37 | font-variant: small-caps; 38 | } 39 | 40 | h2 { 41 | font-size: 1.2em; 42 | margin-left: -10px; 43 | padding-top: 20px; 44 | font-weight: bold; 45 | letter-spacing: .3px; 46 | } 47 | 48 | .error h2 { 49 | color: red; 50 | font-size: 1.2em; 51 | padding-top: 20px; 52 | font-weight: bold; 53 | letter-spacing: .3px; 54 | } 55 | 56 | .error p { 57 | color: red; 58 | } 59 | 60 | p { 61 | letter-spacing: .2px; 62 | } 63 | 64 | label { 65 | text-indent: 20px; 66 | letter-spacing: .2px; 67 | padding: 5px 5px 5px 5px; 68 | } 69 | 70 | #footer { 71 | font-size: .8em; 72 | margin-top: 1em; 73 | } 74 | 75 | #footer a { 76 | color: #333333; 77 | font-weight: bold; 78 | font-size: 1em 79 | } 80 | 81 | #footer a:hover { 82 | color: red; 83 | font-weight: bold; 84 | font-size: 1em 85 | } -------------------------------------------------------------------------------- /AuthServer/src/main/webapp/themes/yellow.css: -------------------------------------------------------------------------------- 1 | /* CSS Document */ 2 | 3 | body { 4 | color: black; 5 | font-family: 'Trebuchet MS', Helvetica, sans-serif; 6 | font-size: 12px; 7 | margin: 0 auto; 8 | width: 736px; 9 | background: url( 'images/bg.gif' ); 10 | } 11 | 12 | #content { 13 | background: yellow; 14 | width: 676px; 15 | margin-top: 20px; 16 | padding: 0 30px 25px 30px; 17 | } 18 | 19 | a { 20 | color: lightblue; 21 | text-decoration: none; 22 | } 23 | 24 | a:hover { 25 | color: red; 26 | text-decoration: none; 27 | } 28 | 29 | h1 { 30 | background: url( 'images/header_yellow.jpg' ); 31 | height: 36px; 32 | width: 721px; 33 | margin: 0 0 1em 0; 34 | padding-top: 80px; 35 | padding-left: 15px; 36 | font-size: 1.8em; 37 | font-variant: small-caps; 38 | } 39 | 40 | h2 { 41 | font-size: 1.2em; 42 | margin-left: -10px; 43 | padding-top: 20px; 44 | font-weight: bold; 45 | letter-spacing: .3px; 46 | } 47 | 48 | .error h2 { 49 | color: red; 50 | font-size: 1.2em; 51 | padding-top: 20px; 52 | font-weight: bold; 53 | letter-spacing: .3px; 54 | } 55 | 56 | .error p { 57 | color: red; 58 | } 59 | 60 | p { 61 | letter-spacing: .2px; 62 | } 63 | 64 | label { 65 | text-indent: 20px; 66 | letter-spacing: .2px; 67 | padding: 5px 5px 5px 5px; 68 | } 69 | 70 | #footer { 71 | font-size: .8em; 72 | margin-top: 1em; 73 | } 74 | 75 | #footer a { 76 | color: #333333; 77 | font-weight: bold; 78 | font-size: 1em 79 | } 80 | 81 | #footer a:hover { 82 | color: red; 83 | font-weight: bold; 84 | font-size: 1em 85 | } -------------------------------------------------------------------------------- /AuthServer/target/.gitignore: -------------------------------------------------------------------------------- 1 | /classes 2 | /test-classes 3 | -------------------------------------------------------------------------------- /AuthServer/target/m2e-wtp/web-resources/.gitignore: -------------------------------------------------------------------------------- 1 | /META-INF 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Spring REST OAuth Demo 2 | ====================== 3 | This is a demo of using OAuth 2.0 with Spring REST application, this demo is part of presentation 4 | https://docs.google.com/presentation/d/1wiOJTMnGWL51P6NyFTCbpJz7-TsrYYrTd6_Siv_9Sfo/edit?usp=sharing 5 | 6 | the home project is a parent one, contains 3 chilcren application: 7 | 8 | * Auth Server 9 | ----------- 10 | The application will be responsible of handling the OAuth 2.0 tokens and clients details. 11 | 12 | * REST Server 13 | ------------ 14 | The Resource provider application which is checking the token provided and if it is authorized, 15 | it is provide the resources required by resource consumer. 16 | 17 | * REST Client 18 | -------------- 19 | Application using java script to access the resources required after getting a valid token from Auth Server 20 | 21 | Note: 22 | ----- 23 | in this application I'm using HTTP for all requests as it is demo in real line all request contains tokne have to be HTTPS 24 | -------------------------------------------------------------------------------- /RESTClient/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /RESTClient/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | RESTClient 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.springframework.ide.eclipse.core.springbuilder 25 | 26 | 27 | 28 | 29 | org.eclipse.wst.validation.validationbuilder 30 | 31 | 32 | 33 | 34 | org.eclipse.m2e.core.maven2Builder 35 | 36 | 37 | 38 | 39 | 40 | org.eclipse.jem.workbench.JavaEMFNature 41 | org.eclipse.wst.common.modulecore.ModuleCoreNature 42 | org.springframework.ide.eclipse.core.springnature 43 | org.eclipse.jdt.core.javanature 44 | org.eclipse.m2e.core.maven2Nature 45 | org.eclipse.wst.common.project.facet.core.nature 46 | org.eclipse.wst.jsdt.core.jsNature 47 | 48 | 49 | -------------------------------------------------------------------------------- /RESTClient/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /RESTClient/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 4 | org.eclipse.jdt.core.compiler.compliance=1.5 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 8 | org.eclipse.jdt.core.compiler.source=1.5 9 | -------------------------------------------------------------------------------- /RESTClient/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /RESTClient/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /RESTClient/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RESTClient/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /RESTClient/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /RESTClient/.springBeans: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1 4 | 5 | 6 | 7 | 8 | 9 | 10 | src/main/webapp/WEB-INF/spring-servlet.xml 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /RESTClient/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.spring.test 6 | Spring_REST_OAuth 7 | 0.0.1-SNAPSHOT 8 | 9 | RESTClient 10 | war 11 | -------------------------------------------------------------------------------- /RESTClient/src/main/resources/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/WEB-INF/spring-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | index.jsp 8 | 31 | 32 | -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-icons_a83300_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-icons_a83300_256x240.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-icons_cccccc_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-icons_cccccc_256x240.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassemZohdy/Spring_REST_OAuth_Demo/d4d481cbbc71786c914ebbec2772b495e489cdee/RESTClient/src/main/webapp/css/ui-darkness/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/css/ui-darkness/jquery-ui-1.9.2.custom.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.2 - 2012-11-27 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css 4 | * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Segoe%20UI%2CArial%2Csans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=6px&bgColorHeader=333333&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=25&borderColorHeader=333333&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=000000&bgTextureContent=05_inset_soft.png&bgImgOpacityContent=25&borderColorContent=666666&fcContent=ffffff&iconColorContent=cccccc&bgColorDefault=555555&bgTextureDefault=02_glass.png&bgImgOpacityDefault=20&borderColorDefault=666666&fcDefault=eeeeee&iconColorDefault=cccccc&bgColorHover=0078a3&bgTextureHover=02_glass.png&bgImgOpacityHover=40&borderColorHover=59b4d4&fcHover=ffffff&iconColorHover=ffffff&bgColorActive=f58400&bgTextureActive=05_inset_soft.png&bgImgOpacityActive=30&borderColorActive=ffaf0f&fcActive=ffffff&iconColorActive=222222&bgColorHighlight=eeeeee&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=80&borderColorHighlight=cccccc&fcHighlight=2e7db2&iconColorHighlight=4b8e0b&bgColorError=ffc73d&bgTextureError=02_glass.png&bgImgOpacityError=40&borderColorError=ffb73d&fcError=111111&iconColorError=a83300&bgColorOverlay=5c5c5c&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=50&opacityOverlay=80&bgColorShadow=cccccc&bgTextureShadow=01_flat.png&bgImgOpacityShadow=30&opacityShadow=60&thicknessShadow=7px&offsetTopShadow=-7px&offsetLeftShadow=-7px&cornerRadiusShadow=8px 5 | * Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{zoom:1}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:0.1px;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.ui-accordion .ui-accordion-header{display:block;cursor:pointer;position:relative;margin-top:2px;padding:.5em .5em .5em .7em;zoom:1}.ui-accordion .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-noicons{padding-left:.7em}.ui-accordion .ui-accordion-icons .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-accordion-header-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;overflow:auto;zoom:1}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}* html .ui-autocomplete{width:1px}.ui-button{display:inline-block;position:relative;padding:0;margin-right:.1em;cursor:pointer;text-align:center;zoom:1;overflow:visible}.ui-button,.ui-button:link,.ui-button:visited,.ui-button:hover,.ui-button:active{text-decoration:none}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:1.4}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}.ui-datepicker .ui-datepicker-prev{left:2px}.ui-datepicker .ui-datepicker-next{right:2px}.ui-datepicker .ui-datepicker-prev-hover{left:1px}.ui-datepicker .ui-datepicker-next-hover{right:1px}.ui-datepicker .ui-datepicker-prev span,.ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}.ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.ui-datepicker select.ui-datepicker-month-year{width:100%}.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:49%}.ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:bold;border:0}.ui-datepicker td{border:0;padding:1px}.ui-datepicker td span,.ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}.ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em .6em;width:auto;overflow:visible}.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.ui-datepicker.ui-datepicker-multi{width:auto}.ui-datepicker-multi .ui-datepicker-group{float:left}.ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.ui-datepicker-row-break{clear:both;width:100%;font-size:0em}.ui-datepicker-rtl{direction:rtl}.ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}.ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}.ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current{float:right}.ui-datepicker-rtl .ui-datepicker-group{float:right}.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-cover{position:absolute;z-index:-1;filter:mask();top:-4px;left:-4px;width:200px;height:200px}.ui-dialog{position:absolute;top:0;left:0;padding:.2em;width:300px;overflow:hidden}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 16px .1em 0}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:19px;margin:-10px 0 0 0;padding:1px;height:18px}.ui-dialog .ui-dialog-titlebar-close span{display:block;margin:1px}.ui-dialog .ui-dialog-titlebar-close:hover,.ui-dialog .ui-dialog-titlebar-close:focus{padding:0}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:none;overflow:auto;zoom:1}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin:.5em 0 0 0;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:14px;height:14px;right:3px;bottom:3px}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-menu{list-style:none;padding:2px;margin:0;display:block;outline:none}.ui-menu .ui-menu{margin-top:-3px;position:absolute}.ui-menu .ui-menu-item{margin:0;padding:0;zoom:1;width:100%}.ui-menu .ui-menu-divider{margin:5px -2px 5px -2px;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-menu-item a{text-decoration:none;display:block;padding:2px .4em;line-height:1.5;zoom:1;font-weight:normal}.ui-menu .ui-menu-item a.ui-state-focus,.ui-menu .ui-menu-item a.ui-state-active{font-weight:normal;margin:-1px}.ui-menu .ui-state-disabled{font-weight:normal;margin:.4em 0 .2em;line-height:1.5}.ui-menu .ui-state-disabled a{cursor:default}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item a{position:relative;padding-left:2em}.ui-menu .ui-icon{position:absolute;top:.2em;left:.2em}.ui-menu .ui-menu-icon{position:static;float:right}.ui-progressbar{height:2em;text-align:left;overflow:hidden}.ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.ui-slider{position:relative;text-align:left}.ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default}.ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.ui-slider-horizontal{height:.8em}.ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.ui-slider-horizontal .ui-slider-range-min{left:0}.ui-slider-horizontal .ui-slider-range-max{right:0}.ui-slider-vertical{width:.8em;height:100px}.ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.ui-slider-vertical .ui-slider-range{left:0;width:100%}.ui-slider-vertical .ui-slider-range-min{bottom:0}.ui-slider-vertical .ui-slider-range-max{top:0}.ui-spinner{position:relative;display:inline-block;overflow:hidden;padding:0;vertical-align:middle}.ui-spinner-input{border:none;background:none;padding:0;margin:.2em 0;vertical-align:middle;margin-left:.4em;margin-right:22px}.ui-spinner-button{width:16px;height:50%;font-size:.5em;padding:0;margin:0;text-align:center;position:absolute;cursor:default;display:block;overflow:hidden;right:0}.ui-spinner a.ui-spinner-button{border-top:none;border-bottom:none;border-right:none}.ui-spinner .ui-icon{position:absolute;margin-top:-8px;top:50%;left:0}.ui-spinner-up{top:0}.ui-spinner-down{bottom:0}.ui-spinner .ui-icon-triangle-1-s{background-position:-65px -16px}.ui-tabs{position:relative;padding:.2em;zoom:1}.ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:0;margin:1px .2em 0 0;border-bottom:0;padding:0;white-space:nowrap}.ui-tabs .ui-tabs-nav li a{float:left;padding:.5em 1em;text-decoration:none}.ui-tabs .ui-tabs-nav li.ui-tabs-active{margin-bottom:-1px;padding-bottom:1px}.ui-tabs .ui-tabs-nav li.ui-tabs-active a,.ui-tabs .ui-tabs-nav li.ui-state-disabled a,.ui-tabs .ui-tabs-nav li.ui-tabs-loading a{cursor:text}.ui-tabs .ui-tabs-nav li a,.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a{cursor:pointer}.ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:none}.ui-tooltip{padding:8px;position:absolute;z-index:9999;max-width:300px;-webkit-box-shadow:0 0 5px #aaa;box-shadow:0 0 5px #aaa}* html .ui-tooltip{background-image:none}body .ui-tooltip{border-width:2px}.ui-widget{font-family:Segoe UI,Arial,sans-serif;font-size:1.1em}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Segoe UI,Arial,sans-serif;font-size:1em}.ui-widget-content{border:1px solid #666;background:#000 url(images/ui-bg_inset-soft_25_000000_1x100.png) 50% bottom repeat-x;color:#fff}.ui-widget-content a{color:#fff}.ui-widget-header{border:1px solid #333;background:#333 url(images/ui-bg_gloss-wave_25_333333_500x100.png) 50% 50% repeat-x;color:#fff;font-weight:bold}.ui-widget-header a{color:#fff}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:1px solid #666;background:#555 url(images/ui-bg_glass_20_555555_1x400.png) 50% 50% repeat-x;font-weight:bold;color:#eee}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#eee;text-decoration:none}.ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus{border:1px solid #59b4d4;background:#0078a3 url(images/ui-bg_glass_40_0078a3_1x400.png) 50% 50% repeat-x;font-weight:bold;color:#fff}.ui-state-hover a,.ui-state-hover a:hover,.ui-state-hover a:link,.ui-state-hover a:visited{color:#fff;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #ffaf0f;background:#f58400 url(images/ui-bg_inset-soft_30_f58400_1x100.png) 50% 50% repeat-x;font-weight:bold;color:#fff}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#fff;text-decoration:none}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #ccc;background:#eee url(images/ui-bg_highlight-soft_80_eeeeee_1x100.png) 50% top repeat-x;color:#2e7db2}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#2e7db2}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #ffb73d;background:#ffc73d url(images/ui-bg_glass_40_ffc73d_1x400.png) 50% 50% repeat-x;color:#111}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#111}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#111}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-state-disabled .ui-icon{filter:Alpha(Opacity=35)}.ui-icon{width:16px;height:16px;background-image:url(images/ui-icons_cccccc_256x240.png)}.ui-widget-content .ui-icon{background-image:url(images/ui-icons_cccccc_256x240.png)}.ui-widget-header .ui-icon{background-image:url(images/ui-icons_ffffff_256x240.png)}.ui-state-default .ui-icon{background-image:url(images/ui-icons_cccccc_256x240.png)}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url(images/ui-icons_ffffff_256x240.png)}.ui-state-active .ui-icon{background-image:url(images/ui-icons_222222_256x240.png)}.ui-state-highlight .ui-icon{background-image:url(images/ui-icons_4b8e0b_256x240.png)}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url(images/ui-icons_a83300_256x240.png)}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-on{background-position:-96px -144px}.ui-icon-radio-off{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{-moz-border-radius-topleft:6px;-webkit-border-top-left-radius:6px;-khtml-border-top-left-radius:6px;border-top-left-radius:6px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{-moz-border-radius-topright:6px;-webkit-border-top-right-radius:6px;-khtml-border-top-right-radius:6px;border-top-right-radius:6px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{-moz-border-radius-bottomleft:6px;-webkit-border-bottom-left-radius:6px;-khtml-border-bottom-left-radius:6px;border-bottom-left-radius:6px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{-moz-border-radius-bottomright:6px;-webkit-border-bottom-right-radius:6px;-khtml-border-bottom-right-radius:6px;border-bottom-right-radius:6px}.ui-widget-overlay{background:#5c5c5c url(images/ui-bg_flat_50_5c5c5c_40x100.png) 50% 50% repeat-x;opacity:.8;filter:Alpha(Opacity=80)}.ui-widget-shadow{margin:-7px 0 0 -7px;padding:7px;background:#ccc url(images/ui-bg_flat_30_cccccc_40x100.png) 50% 50% repeat-x;opacity:.6;filter:Alpha(Opacity=60);-moz-border-radius:8px;-khtml-border-radius:8px;-webkit-border-radius:8px;border-radius:8px} -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | 5 | 6 | 7 | REST Client 8 | 9 | <% 10 | //String url = request.getScheme() + "://" + request.getServerName()+ ":" + request.getServerPort(); 11 | //String url = "https" + "://" + request.getServerName()+ ":" + "8443"; 12 | String url = "http" + "://" + request.getServerName() + ":" + "8080"; 13 | //String clientURL="http://restclient-oauth.cloudfoundry.com"; 14 | //String serverURL = "https://restserver-oauth.cloudfoundry.com"; 15 | String clientURL = url + "/RESTClient"; 16 | String serverURL = url + "/RESTServer"; 17 | String authURL = url + "/AuthServer"; 18 | %> 19 | 20 | 21 | 22 | 206 | 207 | 208 | 209 | Id: 210 | 211 | 212 | 213 |
json 214 |
215 |
216 |
217 |
218 | Person 219 |
220 |


224 | 225 |

227 | 228 | 229 |
230 |
231 |
232 | 233 | -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/js/jso.js: -------------------------------------------------------------------------------- 1 | (function(exp, $) { 2 | 3 | var 4 | config = {}, 5 | default_lifetime = 3600, 6 | options = { 7 | "debug": false 8 | }, 9 | 10 | api_redirect, 11 | Api_default_storage, 12 | api_storage, 13 | 14 | internalStates = []; 15 | 16 | /* 17 | * ------ SECTION: Utilities 18 | */ 19 | 20 | /* 21 | * Returns a random string used for state 22 | */ 23 | var uuid = function() { 24 | return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { 25 | var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); 26 | return v.toString(16); 27 | }); 28 | } 29 | 30 | /** 31 | * A log wrapper, that only logs if logging is turned on in the config 32 | * @param {string} msg Log message 33 | */ 34 | var log = function(msg) { 35 | if (!options.debug) return; 36 | if (!console) return; 37 | if (!console.log) return; 38 | 39 | // console.log("LOG(), Arguments", arguments, msg) 40 | if (arguments.length > 1) { 41 | console.log(arguments); 42 | } else { 43 | console.log(msg); 44 | } 45 | 46 | } 47 | 48 | /** 49 | * Set the global options. 50 | */ 51 | var setOptions = function(opts) { 52 | if (!opts) return; 53 | for(var k in opts) { 54 | if (opts.hasOwnProperty(k)) { 55 | options[k] = opts[k]; 56 | } 57 | } 58 | log("Options is set to ", options); 59 | } 60 | 61 | 62 | /* 63 | * Takes an URL as input and a params object. 64 | * Each property in the params is added to the url as query string parameters 65 | */ 66 | var encodeURL = function(url, params) { 67 | var res = url; 68 | var k, i = 0; 69 | var firstSeparator = (url.indexOf("?") === -1) ? '?' : '&'; 70 | for(k in params) { 71 | res += (i++ === 0 ? firstSeparator : '&') + encodeURIComponent(k) + '=' + encodeURIComponent(params[k]); 72 | } 73 | return res; 74 | } 75 | 76 | 77 | 78 | /* 79 | * Redirects the user to a specific URL 80 | */ 81 | api_redirect = function(url) { 82 | window.location = url; 83 | }; 84 | 85 | Api_default_storage = function() { 86 | log("Constructor"); 87 | }; 88 | 89 | /** 90 | saveState stores an object with an Identifier. 91 | TODO: Ensure that both localstorage and JSON encoding has fallbacks for ancient browsers. 92 | In the state object, we put the request object, plus these parameters: 93 | * restoreHash 94 | * providerID 95 | * scopes 96 | 97 | */ 98 | Api_default_storage.prototype.saveState = function (state, obj) { 99 | localStorage.setItem("state-" + state, JSON.stringify(obj)); 100 | } 101 | 102 | 103 | /** 104 | * getStage() returns the state object, but also removes it. 105 | * @type {Object} 106 | */ 107 | Api_default_storage.prototype.getState = function(state) { 108 | // log("getState (" + state+ ")"); 109 | var obj = JSON.parse(localStorage.getItem("state-" + state)); 110 | localStorage.removeItem("state-" + state) 111 | return obj; 112 | }; 113 | 114 | 115 | /* 116 | * Checks if a token, has includes a specific scope. 117 | * If token has no scope at all, false is returned. 118 | */ 119 | Api_default_storage.prototype.hasScope = function(token, scope) { 120 | var i; 121 | if (!token.scopes) return false; 122 | for(i = 0; i < token.scopes.length; i++) { 123 | if (token.scopes[i] === scope) return true; 124 | } 125 | return false; 126 | }; 127 | 128 | /* 129 | * Takes an array of tokens, and removes the ones that 130 | * are expired, and the ones that do not meet a scopes requirement. 131 | */ 132 | Api_default_storage.prototype.filterTokens = function(tokens, scopes) { 133 | var i, j, 134 | result = [], 135 | now = epoch(), 136 | usethis; 137 | 138 | if (!scopes) scopes = []; 139 | 140 | for(i = 0; i < tokens.length; i++) { 141 | usethis = true; 142 | 143 | // Filter out expired tokens. Tokens that is expired in 1 second from now. 144 | if (tokens[i].expires && tokens[i].expires < (now+1)) usethis = false; 145 | 146 | // Filter out this token if not all scope requirements are met 147 | for(j = 0; j < scopes.length; j++) { 148 | if (!api_storage.hasScope(tokens[i], scopes[j])) usethis = false; 149 | } 150 | 151 | if (usethis) result.push(tokens[i]); 152 | } 153 | return result; 154 | }; 155 | 156 | 157 | /* 158 | * saveTokens() stores a list of tokens for a provider. 159 | 160 | Usually the tokens stored are a plain Access token plus: 161 | * expires : time that the token expires 162 | * providerID: the provider of the access token? 163 | * scopes: an array with the scopes (not string) 164 | */ 165 | Api_default_storage.prototype.saveTokens = function(provider, tokens) { 166 | // log("Save Tokens (" + provider+ ")"); 167 | localStorage.setItem("tokens-" + provider, JSON.stringify(tokens)); 168 | }; 169 | 170 | Api_default_storage.prototype.getTokens = function(provider) { 171 | // log("Get Tokens (" + provider+ ")"); 172 | var tokens = JSON.parse(localStorage.getItem("tokens-" + provider)); 173 | if (!tokens) tokens = []; 174 | 175 | log("Token received", tokens) 176 | return tokens; 177 | }; 178 | Api_default_storage.prototype.wipeTokens = function(provider) { 179 | localStorage.removeItem("tokens-" + provider); 180 | }; 181 | /* 182 | * Save a single token for a provider. 183 | * This also cleans up expired tokens for the same provider. 184 | */ 185 | Api_default_storage.prototype.saveToken = function(provider, token) { 186 | var tokens = this.getTokens(provider); 187 | tokens = api_storage.filterTokens(tokens); 188 | tokens.push(token); 189 | this.saveTokens(provider, tokens); 190 | }; 191 | 192 | /* 193 | * Get a token if exists for a provider with a set of scopes. 194 | * The scopes parameter is OPTIONAL. 195 | */ 196 | Api_default_storage.prototype.getToken = function(provider, scopes) { 197 | var tokens = this.getTokens(provider); 198 | tokens = api_storage.filterTokens(tokens, scopes); 199 | if (tokens.length < 1) return null; 200 | return tokens[0]; 201 | }; 202 | 203 | api_storage = new Api_default_storage(); 204 | 205 | 206 | 207 | /* 208 | * ------ SECTION: Utilities 209 | */ 210 | 211 | /* 212 | * Returns a random string used for state 213 | */ 214 | var uuid = function() { 215 | return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { 216 | var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); 217 | return v.toString(16); 218 | }); 219 | } 220 | 221 | /* 222 | * Takes an URL as input and a params object. 223 | * Each property in the params is added to the url as query string parameters 224 | */ 225 | var encodeURL = function(url, params) { 226 | var res = url; 227 | var k, i = 0; 228 | for(k in params) { 229 | res += (i++ === 0 ? '?' : '&') + encodeURIComponent(k) + '=' + encodeURIComponent(params[k]); 230 | } 231 | return res; 232 | } 233 | 234 | /* 235 | * Returns epoch, seconds since 1970. 236 | * Used for calculation of expire times. 237 | */ 238 | var epoch = function() { 239 | return Math.round(new Date().getTime()/1000.0); 240 | } 241 | 242 | 243 | 244 | var parseQueryString = function (qs) { 245 | var e, 246 | a = /\+/g, // Regex for replacing addition symbol with a space 247 | r = /([^&;=]+)=?([^&;]*)/g, 248 | d = function (s) { return decodeURIComponent(s.replace(a, " ")); }, 249 | q = qs, 250 | urlParams = {}; 251 | 252 | while (e = r.exec(q)) 253 | urlParams[d(e[1])] = d(e[2]); 254 | 255 | return urlParams; 256 | } 257 | /* 258 | * ------ / SECTION: Utilities 259 | */ 260 | 261 | 262 | 263 | 264 | 265 | 266 | /** 267 | * Check if the hash contains an access token. 268 | * And if it do, extract the state, compare with 269 | * config, and store the access token for later use. 270 | * 271 | * The url parameter is optional. Used with phonegap and 272 | * childbrowser when the jso context is not receiving the response, 273 | * instead the response is received on a child browser. 274 | */ 275 | exp.jso_checkfortoken = function(providerID, url, callback) { 276 | var 277 | atoken, 278 | h = window.location.hash, 279 | now = epoch(), 280 | state, 281 | co; 282 | 283 | log("jso_checkfortoken(" + providerID + ")"); 284 | 285 | // If a url is provided 286 | if (url) { 287 | // log('Hah, I got the url and it ' + url); 288 | if(url.indexOf('#') === -1) return; 289 | h = url.substring(url.indexOf('#')); 290 | // log('Hah, I got the hash and it is ' + h); 291 | } 292 | 293 | /* 294 | * Start with checking if there is a token in the hash 295 | */ 296 | if (h.length < 2) return; 297 | if (h.indexOf("access_token") === -1) return; 298 | h = h.substring(1); 299 | atoken = parseQueryString(h); 300 | 301 | if (atoken.state) { 302 | state = api_storage.getState(atoken.state); 303 | } else { 304 | if (!providerID) {throw "Could not get [state] and no default providerid is provided.";} 305 | state = {providerID: providerID}; 306 | } 307 | 308 | 309 | if (!state) throw "Could not retrieve state"; 310 | if (!state.providerID) throw "Could not get providerid from state"; 311 | if (!config[state.providerID]) throw "Could not retrieve config for this provider."; 312 | co = config[state.providerID]; 313 | 314 | /** 315 | * If state was not provided, and default provider contains a scope parameter 316 | * we assume this is the one requested... 317 | */ 318 | if (!atoken.state && co.scope) { 319 | state.scopes = co.scope; 320 | log("Setting state: ", state); 321 | } 322 | log("Checking atoken ", atoken, " and co ", co); 323 | 324 | /* 325 | * Decide when this token should expire. 326 | * Priority fallback: 327 | * 1. Access token expires_in 328 | * 2. Life time in config (may be false = permanent...) 329 | * 3. Specific permanent scope. 330 | * 4. Default library lifetime: 331 | */ 332 | if (atoken["expires_in"]) { 333 | atoken["expires"] = now + parseInt(atoken["expires_in"], 10); 334 | } else if (co["default_lifetime"] === false) { 335 | // Token is permanent. 336 | } else if (co["default_lifetime"]) { 337 | atoken["expires"] = now + co["default_lifetime"]; 338 | } else if (co["permanent_scope"]) { 339 | if (!api_storage.hasScope(atoken, co["permanent_scope"])) { 340 | atoken["expires"] = now + default_lifetime; 341 | } 342 | } else { 343 | atoken["expires"] = now + default_lifetime; 344 | } 345 | 346 | /* 347 | * Handle scopes for this token 348 | */ 349 | if (atoken["scope"]) { 350 | atoken["scopes"] = atoken["scope"].split(" "); 351 | } else if (state["scopes"]) { 352 | atoken["scopes"] = state["scopes"]; 353 | } 354 | 355 | 356 | 357 | api_storage.saveToken(state.providerID, atoken); 358 | 359 | if (state.restoreHash) { 360 | window.location.hash = state.restoreHash; 361 | } else { 362 | window.location.hash = ''; 363 | } 364 | 365 | 366 | log(atoken); 367 | 368 | if (internalStates[atoken.state] && typeof internalStates[atoken.state] === 'function') { 369 | // log("InternalState is set, calling it now!"); 370 | internalStates[atoken.state](); 371 | delete internalStates[atoken.state]; 372 | } 373 | 374 | 375 | if (typeof callback === 'function') { 376 | callback(); 377 | } 378 | 379 | // log(atoken); 380 | 381 | } 382 | 383 | /* 384 | * A config object contains: 385 | */ 386 | var jso_authrequest = function(providerid, scopes, callback) { 387 | 388 | var 389 | state, 390 | request, 391 | authurl, 392 | co; 393 | 394 | if (!config[providerid]) throw "Could not find configuration for provider " + providerid; 395 | co = config[providerid]; 396 | 397 | log("About to send an authorization request to [" + providerid + "]. Config:") 398 | log(co); 399 | 400 | state = uuid(); 401 | request = { 402 | "response_type": "token" 403 | }; 404 | request.state = state; 405 | 406 | if (callback && typeof callback === 'function') { 407 | internalStates[state] = callback; 408 | } 409 | 410 | 411 | if (co["redirect_uri"]) { 412 | request["redirect_uri"] = co["redirect_uri"]; 413 | } 414 | if (co["client_id"]) { 415 | request["client_id"] = co["client_id"]; 416 | } 417 | if (scopes) { 418 | request["scope"] = scopes.join(" "); 419 | } 420 | 421 | authurl = encodeURL(co.authorization, request); 422 | 423 | // We'd like to cache the hash for not loosing Application state. 424 | // With the implciit grant flow, the hash will be replaced with the access 425 | // token when we return after authorization. 426 | if (window.location.hash) { 427 | request["restoreHash"] = window.location.hash; 428 | } 429 | request["providerID"] = providerid; 430 | if (scopes) { 431 | request["scopes"] = scopes; 432 | } 433 | 434 | 435 | log("Saving state [" + state+ "]"); 436 | log(JSON.parse(JSON.stringify(request))); 437 | 438 | api_storage.saveState(state, request); 439 | api_redirect(authurl); 440 | 441 | }; 442 | 443 | exp.jso_ensureTokens = function (ensure) { 444 | var providerid, scopes, token; 445 | for(providerid in ensure) { 446 | scopes = undefined; 447 | if (ensure[providerid]) scopes = ensure[providerid]; 448 | token = api_storage.getToken(providerid, scopes); 449 | 450 | log("Ensure token for provider [" + providerid + "] "); 451 | log(token); 452 | 453 | if (token === null) { 454 | jso_authrequest(providerid, scopes); 455 | } 456 | } 457 | 458 | 459 | return true; 460 | } 461 | 462 | exp.jso_findDefaultEntry = function(c) { 463 | var 464 | k, 465 | i = 0; 466 | 467 | if (!c) return; 468 | log("c", c); 469 | for(k in c) { 470 | i++; 471 | if (c[k].isDefault && c[k].isDefault === true) { 472 | return k; 473 | } 474 | } 475 | if (i === 1) return k; 476 | }; 477 | 478 | exp.jso_configure = function(c, opts) { 479 | config = c; 480 | setOptions(opts); 481 | try { 482 | 483 | var def = jso_findDefaultEntry(c); 484 | log("jso_configure() about to check for token for this entry", def); 485 | exp.jso_checkfortoken(def); 486 | 487 | } catch(e) { 488 | log("Error when retrieving token from hash: " + e); 489 | window.location.hash = ""; 490 | } 491 | 492 | } 493 | 494 | exp.jso_dump = function() { 495 | var key; 496 | for(key in config) { 497 | 498 | log("=====> Processing provider [" + key + "]"); 499 | log("=] Config"); 500 | log(config[key]); 501 | log("=] Tokens") 502 | log(api_storage.getTokens(key)); 503 | 504 | } 505 | } 506 | 507 | exp.jso_wipe = function() { 508 | var key; 509 | log("jso_wipe()"); 510 | for(key in config) { 511 | log("Wipping tokens for " + key); 512 | api_storage.wipeTokens(key); 513 | } 514 | } 515 | 516 | exp.jso_getToken = function(providerid, scopes) { 517 | var token = api_storage.getToken(providerid, scopes); 518 | if (!token) return null; 519 | if (!token["access_token"]) return null; 520 | return token["access_token"]; 521 | } 522 | 523 | 524 | 525 | exp.jso_registerRedirectHandler = function(callback) { 526 | api_redirect = callback; 527 | }; 528 | 529 | exp.jso_registerStorageHandler = function(object) { 530 | api_storage = object; 531 | }; 532 | 533 | 534 | /* 535 | * From now on, we only perform tasks that require jQuery. 536 | * Like adding the $.oajax function. 537 | */ 538 | if (typeof $ === 'undefined') return; 539 | 540 | $.oajax = function(settings) { 541 | var 542 | allowia, 543 | scopes, 544 | token, 545 | providerid, 546 | co; 547 | 548 | providerid = settings.jso_provider; 549 | allowia = settings.jso_allowia || false; 550 | scopes = settings.jso_scopes; 551 | token = api_storage.getToken(providerid, scopes); 552 | co = config[providerid]; 553 | 554 | // var successOverridden = settings.success; 555 | // settings.success = function(response) { 556 | // } 557 | 558 | var errorOverridden = settings.error || null; 559 | 560 | var performAjax = function() { 561 | // log("Perform ajax!"); 562 | 563 | if (!token) throw "Could not perform AJAX call because no valid tokens was found."; 564 | 565 | if (co["presenttoken"] && co["presenttoken"] === "qs") { 566 | // settings.url += ((h.indexOf("?") === -1) ? '?' : '&') + "access_token=" + encodeURIComponent(token["access_token"]); 567 | if (!settings.data) settings.data = {}; 568 | settings.data["access_token"] = token["access_token"]; 569 | } else { 570 | if (!settings.headers) settings.headers = {}; 571 | settings.headers["Authorization"] = "Bearer " + token["access_token"]; 572 | } 573 | $.ajax(settings); 574 | }; 575 | 576 | settings.error = function(jqXHR, textStatus, errorThrown) { 577 | log('error(jqXHR, textStatus, errorThrown)'); 578 | log(jqXHR); 579 | log(textStatus); 580 | log(errorThrown); 581 | 582 | if (jqXHR.status === 401) { 583 | 584 | log("Token expired. About to delete this token"); 585 | log(token); 586 | api_storage.wipeTokens(providerid); 587 | 588 | } 589 | if (errorOverridden && typeof errorOverridden === 'function') { 590 | errorOverridden(jqXHR, textStatus, errorThrown); 591 | } 592 | } 593 | 594 | 595 | if (!token) { 596 | if (allowia) { 597 | log("Perform authrequest"); 598 | jso_authrequest(providerid, scopes, function() { 599 | token = api_storage.getToken(providerid, scopes); 600 | performAjax(); 601 | }); 602 | return; 603 | } else { 604 | throw "Could not perform AJAX call because no valid tokens was found."; 605 | } 606 | } 607 | 608 | 609 | performAjax(); 610 | }; 611 | 612 | 613 | })(window, window.jQuery); 614 | -------------------------------------------------------------------------------- /RESTClient/src/main/webapp/js/json2.js: -------------------------------------------------------------------------------- 1 | /* 2 | http://www.JSON.org/json2.js 3 | 2011-10-19 4 | 5 | Public Domain. 6 | 7 | NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. 8 | 9 | See http://www.JSON.org/js.html 10 | 11 | 12 | This code should be minified before deployment. 13 | See http://javascript.crockford.com/jsmin.html 14 | 15 | USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO 16 | NOT CONTROL. 17 | 18 | 19 | This file creates a global JSON object containing two methods: stringify 20 | and parse. 21 | 22 | JSON.stringify(value, replacer, space) 23 | value any JavaScript value, usually an object or array. 24 | 25 | replacer an optional parameter that determines how object 26 | values are stringified for objects. It can be a 27 | function or an array of strings. 28 | 29 | space an optional parameter that specifies the indentation 30 | of nested structures. If it is omitted, the text will 31 | be packed without extra whitespace. If it is a number, 32 | it will specify the number of spaces to indent at each 33 | level. If it is a string (such as '\t' or ' '), 34 | it contains the characters used to indent at each level. 35 | 36 | This method produces a JSON text from a JavaScript value. 37 | 38 | When an object value is found, if the object contains a toJSON 39 | method, its toJSON method will be called and the result will be 40 | stringified. A toJSON method does not serialize: it returns the 41 | value represented by the name/value pair that should be serialized, 42 | or undefined if nothing should be serialized. The toJSON method 43 | will be passed the key associated with the value, and this will be 44 | bound to the value 45 | 46 | For example, this would serialize Dates as ISO strings. 47 | 48 | Date.prototype.toJSON = function (key) { 49 | function f(n) { 50 | // Format integers to have at least two digits. 51 | return n < 10 ? '0' + n : n; 52 | } 53 | 54 | return this.getUTCFullYear() + '-' + 55 | f(this.getUTCMonth() + 1) + '-' + 56 | f(this.getUTCDate()) + 'T' + 57 | f(this.getUTCHours()) + ':' + 58 | f(this.getUTCMinutes()) + ':' + 59 | f(this.getUTCSeconds()) + 'Z'; 60 | }; 61 | 62 | You can provide an optional replacer method. It will be passed the 63 | key and value of each member, with this bound to the containing 64 | object. The value that is returned from your method will be 65 | serialized. If your method returns undefined, then the member will 66 | be excluded from the serialization. 67 | 68 | If the replacer parameter is an array of strings, then it will be 69 | used to select the members to be serialized. It filters the results 70 | such that only members with keys listed in the replacer array are 71 | stringified. 72 | 73 | Values that do not have JSON representations, such as undefined or 74 | functions, will not be serialized. Such values in objects will be 75 | dropped; in arrays they will be replaced with null. You can use 76 | a replacer function to replace those with JSON values. 77 | JSON.stringify(undefined) returns undefined. 78 | 79 | The optional space parameter produces a stringification of the 80 | value that is filled with line breaks and indentation to make it 81 | easier to read. 82 | 83 | If the space parameter is a non-empty string, then that string will 84 | be used for indentation. If the space parameter is a number, then 85 | the indentation will be that many spaces. 86 | 87 | Example: 88 | 89 | text = JSON.stringify(['e', {pluribus: 'unum'}]); 90 | // text is '["e",{"pluribus":"unum"}]' 91 | 92 | 93 | text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); 94 | // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' 95 | 96 | text = JSON.stringify([new Date()], function (key, value) { 97 | return this[key] instanceof Date ? 98 | 'Date(' + this[key] + ')' : value; 99 | }); 100 | // text is '["Date(---current time---)"]' 101 | 102 | 103 | JSON.parse(text, reviver) 104 | This method parses a JSON text to produce an object or array. 105 | It can throw a SyntaxError exception. 106 | 107 | The optional reviver parameter is a function that can filter and 108 | transform the results. It receives each of the keys and values, 109 | and its return value is used instead of the original value. 110 | If it returns what it received, then the structure is not modified. 111 | If it returns undefined then the member is deleted. 112 | 113 | Example: 114 | 115 | // Parse the text. Values that look like ISO date strings will 116 | // be converted to Date objects. 117 | 118 | myData = JSON.parse(text, function (key, value) { 119 | var a; 120 | if (typeof value === 'string') { 121 | a = 122 | /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); 123 | if (a) { 124 | return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], 125 | +a[5], +a[6])); 126 | } 127 | } 128 | return value; 129 | }); 130 | 131 | myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { 132 | var d; 133 | if (typeof value === 'string' && 134 | value.slice(0, 5) === 'Date(' && 135 | value.slice(-1) === ')') { 136 | d = new Date(value.slice(5, -1)); 137 | if (d) { 138 | return d; 139 | } 140 | } 141 | return value; 142 | }); 143 | 144 | 145 | This is a reference implementation. You are free to copy, modify, or 146 | redistribute. 147 | */ 148 | 149 | /*jslint evil: true, regexp: true */ 150 | 151 | /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, 152 | call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, 153 | getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, 154 | lastIndex, length, parse, prototype, push, replace, slice, stringify, 155 | test, toJSON, toString, valueOf 156 | */ 157 | 158 | 159 | // Create a JSON object only if one does not already exist. We create the 160 | // methods in a closure to avoid creating global variables. 161 | 162 | var JSON; 163 | if (!JSON) { 164 | JSON = {}; 165 | } 166 | 167 | (function () { 168 | 'use strict'; 169 | 170 | function f(n) { 171 | // Format integers to have at least two digits. 172 | return n < 10 ? '0' + n : n; 173 | } 174 | 175 | if (typeof Date.prototype.toJSON !== 'function') { 176 | 177 | Date.prototype.toJSON = function (key) { 178 | 179 | return isFinite(this.valueOf()) 180 | ? this.getUTCFullYear() + '-' + 181 | f(this.getUTCMonth() + 1) + '-' + 182 | f(this.getUTCDate()) + 'T' + 183 | f(this.getUTCHours()) + ':' + 184 | f(this.getUTCMinutes()) + ':' + 185 | f(this.getUTCSeconds()) + 'Z' 186 | : null; 187 | }; 188 | 189 | String.prototype.toJSON = 190 | Number.prototype.toJSON = 191 | Boolean.prototype.toJSON = function (key) { 192 | return this.valueOf(); 193 | }; 194 | } 195 | 196 | var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, 197 | escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, 198 | gap, 199 | indent, 200 | meta = { // table of character substitutions 201 | '\b': '\\b', 202 | '\t': '\\t', 203 | '\n': '\\n', 204 | '\f': '\\f', 205 | '\r': '\\r', 206 | '"' : '\\"', 207 | '\\': '\\\\' 208 | }, 209 | rep; 210 | 211 | 212 | function quote(string) { 213 | 214 | // If the string contains no control characters, no quote characters, and no 215 | // backslash characters, then we can safely slap some quotes around it. 216 | // Otherwise we must also replace the offending characters with safe escape 217 | // sequences. 218 | 219 | escapable.lastIndex = 0; 220 | return escapable.test(string) ? '"' + string.replace(escapable, function (a) { 221 | var c = meta[a]; 222 | return typeof c === 'string' 223 | ? c 224 | : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); 225 | }) + '"' : '"' + string + '"'; 226 | } 227 | 228 | 229 | function str(key, holder) { 230 | 231 | // Produce a string from holder[key]. 232 | 233 | var i, // The loop counter. 234 | k, // The member key. 235 | v, // The member value. 236 | length, 237 | mind = gap, 238 | partial, 239 | value = holder[key]; 240 | 241 | // If the value has a toJSON method, call it to obtain a replacement value. 242 | 243 | if (value && typeof value === 'object' && 244 | typeof value.toJSON === 'function') { 245 | value = value.toJSON(key); 246 | } 247 | 248 | // If we were called with a replacer function, then call the replacer to 249 | // obtain a replacement value. 250 | 251 | if (typeof rep === 'function') { 252 | value = rep.call(holder, key, value); 253 | } 254 | 255 | // What happens next depends on the value's type. 256 | 257 | switch (typeof value) { 258 | case 'string': 259 | return quote(value); 260 | 261 | case 'number': 262 | 263 | // JSON numbers must be finite. Encode non-finite numbers as null. 264 | 265 | return isFinite(value) ? String(value) : 'null'; 266 | 267 | case 'boolean': 268 | case 'null': 269 | 270 | // If the value is a boolean or null, convert it to a string. Note: 271 | // typeof null does not produce 'null'. The case is included here in 272 | // the remote chance that this gets fixed someday. 273 | 274 | return String(value); 275 | 276 | // If the type is 'object', we might be dealing with an object or an array or 277 | // null. 278 | 279 | case 'object': 280 | 281 | // Due to a specification blunder in ECMAScript, typeof null is 'object', 282 | // so watch out for that case. 283 | 284 | if (!value) { 285 | return 'null'; 286 | } 287 | 288 | // Make an array to hold the partial results of stringifying this object value. 289 | 290 | gap += indent; 291 | partial = []; 292 | 293 | // Is the value an array? 294 | 295 | if (Object.prototype.toString.apply(value) === '[object Array]') { 296 | 297 | // The value is an array. Stringify every element. Use null as a placeholder 298 | // for non-JSON values. 299 | 300 | length = value.length; 301 | for (i = 0; i < length; i += 1) { 302 | partial[i] = str(i, value) || 'null'; 303 | } 304 | 305 | // Join all of the elements together, separated with commas, and wrap them in 306 | // brackets. 307 | 308 | v = partial.length === 0 309 | ? '[]' 310 | : gap 311 | ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' 312 | : '[' + partial.join(',') + ']'; 313 | gap = mind; 314 | return v; 315 | } 316 | 317 | // If the replacer is an array, use it to select the members to be stringified. 318 | 319 | if (rep && typeof rep === 'object') { 320 | length = rep.length; 321 | for (i = 0; i < length; i += 1) { 322 | if (typeof rep[i] === 'string') { 323 | k = rep[i]; 324 | v = str(k, value); 325 | if (v) { 326 | partial.push(quote(k) + (gap ? ': ' : ':') + v); 327 | } 328 | } 329 | } 330 | } else { 331 | 332 | // Otherwise, iterate through all of the keys in the object. 333 | 334 | for (k in value) { 335 | if (Object.prototype.hasOwnProperty.call(value, k)) { 336 | v = str(k, value); 337 | if (v) { 338 | partial.push(quote(k) + (gap ? ': ' : ':') + v); 339 | } 340 | } 341 | } 342 | } 343 | 344 | // Join all of the member texts together, separated with commas, 345 | // and wrap them in braces. 346 | 347 | v = partial.length === 0 348 | ? '{}' 349 | : gap 350 | ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' 351 | : '{' + partial.join(',') + '}'; 352 | gap = mind; 353 | return v; 354 | } 355 | } 356 | 357 | // If the JSON object does not yet have a stringify method, give it one. 358 | 359 | if (typeof JSON.stringify !== 'function') { 360 | JSON.stringify = function (value, replacer, space) { 361 | 362 | // The stringify method takes a value and an optional replacer, and an optional 363 | // space parameter, and returns a JSON text. The replacer can be a function 364 | // that can replace values, or an array of strings that will select the keys. 365 | // A default replacer method can be provided. Use of the space parameter can 366 | // produce text that is more easily readable. 367 | 368 | var i; 369 | gap = ''; 370 | indent = ''; 371 | 372 | // If the space parameter is a number, make an indent string containing that 373 | // many spaces. 374 | 375 | if (typeof space === 'number') { 376 | for (i = 0; i < space; i += 1) { 377 | indent += ' '; 378 | } 379 | 380 | // If the space parameter is a string, it will be used as the indent string. 381 | 382 | } else if (typeof space === 'string') { 383 | indent = space; 384 | } 385 | 386 | // If there is a replacer, it must be a function or an array. 387 | // Otherwise, throw an error. 388 | 389 | rep = replacer; 390 | if (replacer && typeof replacer !== 'function' && 391 | (typeof replacer !== 'object' || 392 | typeof replacer.length !== 'number')) { 393 | throw new Error('JSON.stringify'); 394 | } 395 | 396 | // Make a fake root object containing our value under the key of ''. 397 | // Return the result of stringifying the value. 398 | 399 | return str('', {'': value}); 400 | }; 401 | } 402 | 403 | 404 | // If the JSON object does not yet have a parse method, give it one. 405 | 406 | if (typeof JSON.parse !== 'function') { 407 | JSON.parse = function (text, reviver) { 408 | 409 | // The parse method takes a text and an optional reviver function, and returns 410 | // a JavaScript value if the text is a valid JSON text. 411 | 412 | var j; 413 | 414 | function walk(holder, key) { 415 | 416 | // The walk method is used to recursively walk the resulting structure so 417 | // that modifications can be made. 418 | 419 | var k, v, value = holder[key]; 420 | if (value && typeof value === 'object') { 421 | for (k in value) { 422 | if (Object.prototype.hasOwnProperty.call(value, k)) { 423 | v = walk(value, k); 424 | if (v !== undefined) { 425 | value[k] = v; 426 | } else { 427 | delete value[k]; 428 | } 429 | } 430 | } 431 | } 432 | return reviver.call(holder, key, value); 433 | } 434 | 435 | 436 | // Parsing happens in four stages. In the first stage, we replace certain 437 | // Unicode characters with escape sequences. JavaScript handles many characters 438 | // incorrectly, either silently deleting them, or treating them as line endings. 439 | 440 | text = String(text); 441 | cx.lastIndex = 0; 442 | if (cx.test(text)) { 443 | text = text.replace(cx, function (a) { 444 | return '\\u' + 445 | ('0000' + a.charCodeAt(0).toString(16)).slice(-4); 446 | }); 447 | } 448 | 449 | // In the second stage, we run the text against regular expressions that look 450 | // for non-JSON patterns. We are especially concerned with '()' and 'new' 451 | // because they can cause invocation, and '=' because it can cause mutation. 452 | // But just to be safe, we want to reject all unexpected forms. 453 | 454 | // We split the second stage into 4 regexp operations in order to work around 455 | // crippling inefficiencies in IE's and Safari's regexp engines. First we 456 | // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we 457 | // replace all simple value tokens with ']' characters. Third, we delete all 458 | // open brackets that follow a colon or comma or that begin the text. Finally, 459 | // we look to see that the remaining characters are only whitespace or ']' or 460 | // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. 461 | 462 | if (/^[\],:{}\s]*$/ 463 | .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@') 464 | .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']') 465 | .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { 466 | 467 | // In the third stage we use the eval function to compile the text into a 468 | // JavaScript structure. The '{' operator is subject to a syntactic ambiguity 469 | // in JavaScript: it can begin a block or an object literal. We wrap the text 470 | // in parens to eliminate the ambiguity. 471 | 472 | j = eval('(' + text + ')'); 473 | 474 | // In the optional fourth stage, we recursively walk the new structure, passing 475 | // each name/value pair to a reviver function for possible transformation. 476 | 477 | return typeof reviver === 'function' 478 | ? walk({'': j}, '') 479 | : j; 480 | } 481 | 482 | // If the text is not JSON parseable, then a SyntaxError is thrown. 483 | 484 | throw new SyntaxError('JSON.parse'); 485 | }; 486 | } 487 | }()); -------------------------------------------------------------------------------- /RESTClient/target/.gitignore: -------------------------------------------------------------------------------- 1 | /classes 2 | -------------------------------------------------------------------------------- /RESTClient/target/m2e-wtp/web-resources/.gitignore: -------------------------------------------------------------------------------- 1 | /META-INF 2 | -------------------------------------------------------------------------------- /RESTServer/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /RESTServer/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | RESTServer 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.springframework.ide.eclipse.core.springbuilder 25 | 26 | 27 | 28 | 29 | org.eclipse.wst.validation.validationbuilder 30 | 31 | 32 | 33 | 34 | org.eclipse.m2e.core.maven2Builder 35 | 36 | 37 | 38 | 39 | 40 | org.eclipse.jem.workbench.JavaEMFNature 41 | org.eclipse.wst.common.modulecore.ModuleCoreNature 42 | org.springframework.ide.eclipse.core.springnature 43 | org.eclipse.jdt.core.javanature 44 | org.eclipse.m2e.core.maven2Nature 45 | org.eclipse.wst.common.project.facet.core.nature 46 | org.eclipse.wst.jsdt.core.jsNature 47 | 48 | 49 | -------------------------------------------------------------------------------- /RESTServer/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /RESTServer/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 4 | org.eclipse.jdt.core.compiler.compliance=1.5 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 8 | org.eclipse.jdt.core.compiler.source=1.5 9 | -------------------------------------------------------------------------------- /RESTServer/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /RESTServer/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /RESTServer/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RESTServer/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /RESTServer/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /RESTServer/.springBeans: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1 4 | 5 | 6 | 7 | 8 | 9 | 10 | src/main/resources/spring/root-context.xml 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /RESTServer/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.spring.test 6 | Spring_REST_OAuth 7 | 0.0.1-SNAPSHOT 8 | 9 | RESTServer 10 | war 11 | 12 | 13 | com.fasterxml.jackson.core 14 | jackson-core 15 | 2.0.6 16 | 17 | 18 | com.fasterxml.jackson.core 19 | jackson-databind 20 | 2.0.6 21 | 22 | 23 | com.fasterxml.jackson.core 24 | jackson-annotations 25 | 2.0.6 26 | 27 | 28 | javax.xml 29 | jaxb-impl 30 | 2.1 31 | 32 | 33 | javax.xml 34 | jaxb-api 35 | 2.1 36 | 37 | 38 | -------------------------------------------------------------------------------- /RESTServer/src/main/java/org/spring/aspect/LoggerAspect.java: -------------------------------------------------------------------------------- 1 | package org.spring.aspect; 2 | 3 | import java.util.Date; 4 | 5 | import org.apache.commons.beanutils.BeanUtils; 6 | import org.aspectj.lang.ProceedingJoinPoint; 7 | import org.aspectj.lang.annotation.Around; 8 | import org.aspectj.lang.annotation.Aspect; 9 | import org.aspectj.lang.annotation.Pointcut; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | @Aspect 14 | public class LoggerAspect { 15 | private static final Logger logger = LoggerFactory 16 | .getLogger(LoggerAspect.class); 17 | 18 | @Pointcut("within(@org.springframework.stereotype.Controller *)") 19 | public void controllerBean() { 20 | } 21 | 22 | @Pointcut("within(@org.springframework.stereotype.Service *)") 23 | public void serviceBean() { 24 | } 25 | 26 | @Pointcut("within(@org.springframework.stereotype.Repository *)") 27 | public void repositoryBean() { 28 | } 29 | 30 | @Pointcut("execution(* *(..))") 31 | public void methodPointcut() { 32 | } 33 | 34 | @Around("controllerBean() && methodPointcut()") 35 | public Object aroundControllerMethod(ProceedingJoinPoint joinPoint) 36 | throws Throwable { 37 | logger.debug(">>>>>>>> invoking {}", joinPoint.getSignature()); 38 | Date start = new Date(); 39 | Object result = joinPoint.proceed(); 40 | Date end = new Date(); 41 | logger.debug(">>>>>>>> return of {} with {}", joinPoint.getSignature(), 42 | BeanUtils.describe(result)); 43 | logger.debug(">>>>>>>> end of {} take {} millisec", 44 | joinPoint.getSignature(), end.getTime() - start.getTime()); 45 | return result; 46 | } 47 | 48 | @Around("serviceBean() && methodPointcut()") 49 | public Object aroundServiceMethod(ProceedingJoinPoint joinPoint) 50 | throws Throwable { 51 | logger.debug(">>>>>>>> invoking {}", joinPoint.getSignature()); 52 | Date start = new Date(); 53 | Object result = joinPoint.proceed(); 54 | Date end = new Date(); 55 | logger.debug(">>>>>>>> return of {} with {}", joinPoint.getSignature(), 56 | BeanUtils.describe(result)); 57 | logger.debug(">>>>>>>> end of {} take {} millisec", 58 | joinPoint.getSignature(), end.getTime() - start.getTime()); 59 | return result; 60 | } 61 | 62 | @Around("repositoryBean() && methodPointcut()") 63 | public Object aroundRepositoryMethod(ProceedingJoinPoint joinPoint) 64 | throws Throwable { 65 | logger.debug(">>>>>>>> invoking {}", joinPoint.getSignature()); 66 | Date start = new Date(); 67 | Object result = joinPoint.proceed(); 68 | Date end = new Date(); 69 | logger.debug(">>>>>>>> return of {} with {}", joinPoint.getSignature(), 70 | BeanUtils.describe(result)); 71 | logger.debug(">>>>>>>> end of {} take {} millisec", 72 | joinPoint.getSignature(), end.getTime() - start.getTime()); 73 | return result; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /RESTServer/src/main/java/org/spring/web/rest/controller/PersonController.java: -------------------------------------------------------------------------------- 1 | package org.spring.web.rest.controller; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.validation.Valid; 9 | 10 | import org.spring.web.rest.model.Person; 11 | import org.spring.web.rest.service.PersonService; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.beans.propertyeditors.CustomDateEditor; 14 | import org.springframework.dao.EmptyResultDataAccessException; 15 | import org.springframework.http.HttpStatus; 16 | import org.springframework.stereotype.Controller; 17 | import org.springframework.web.bind.WebDataBinder; 18 | import org.springframework.web.bind.annotation.ExceptionHandler; 19 | import org.springframework.web.bind.annotation.InitBinder; 20 | import org.springframework.web.bind.annotation.PathVariable; 21 | import org.springframework.web.bind.annotation.RequestBody; 22 | import org.springframework.web.bind.annotation.RequestMapping; 23 | import org.springframework.web.bind.annotation.RequestMethod; 24 | import org.springframework.web.bind.annotation.ResponseBody; 25 | import org.springframework.web.bind.annotation.ResponseStatus; 26 | 27 | @Controller 28 | @RequestMapping("/") 29 | public class PersonController { 30 | 31 | @InitBinder 32 | public void initBinder(WebDataBinder binder) { 33 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); 34 | binder.registerCustomEditor(Date.class, new CustomDateEditor( 35 | dateFormat, false)); 36 | } 37 | 38 | @Autowired 39 | private PersonService personService; 40 | 41 | @RequestMapping(value = "/person/{id}", method = RequestMethod.GET) 42 | @ResponseBody 43 | public Person getPerson(@PathVariable("id") Long id) { 44 | return personService.getPerson(id); 45 | } 46 | 47 | @RequestMapping(value = "/persons", method = RequestMethod.GET) 48 | @ResponseBody 49 | public List getPersons() { 50 | return personService.getAllPersons(); 51 | } 52 | 53 | @RequestMapping(value = "/person/", method = RequestMethod.POST) 54 | public @ResponseBody 55 | Person createPerson(@RequestBody Person person) { 56 | return personService.addPerson(person); 57 | } 58 | 59 | @RequestMapping(value = "/person/{id}", method = RequestMethod.PUT) 60 | public @ResponseBody 61 | Person updatePerson(@PathVariable("id") Long id, 62 | @Valid @RequestBody Person person) { 63 | person.setId(id); 64 | Person tempPerson = personService.updatePerson(person); 65 | return tempPerson; 66 | 67 | } 68 | 69 | @RequestMapping(value = "/person/{id}", method = RequestMethod.DELETE) 70 | public @ResponseBody 71 | Person deletePerson(@PathVariable("id") Long id) { 72 | return personService.deletePerson(id); 73 | } 74 | 75 | @ExceptionHandler({ EmptyResultDataAccessException.class, 76 | NullPointerException.class }) 77 | @ResponseStatus(reason = "Reason", value = HttpStatus.NOT_FOUND) 78 | public void handleEmptyResultDataAccessException( 79 | EmptyResultDataAccessException ex, HttpServletRequest request) { 80 | return; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /RESTServer/src/main/java/org/spring/web/rest/model/Person.java: -------------------------------------------------------------------------------- 1 | package org.spring.web.rest.model; 2 | 3 | import java.util.Date; 4 | 5 | import javax.validation.constraints.Size; 6 | 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | import org.springframework.format.annotation.DateTimeFormat.ISO; 9 | 10 | public class Person { 11 | 12 | private Long id; 13 | @Size(min=3,max=25) 14 | private String firstName; 15 | @Size(min=3,max=25) 16 | private String lastName; 17 | private int number; 18 | @DateTimeFormat(iso = ISO.DATE) 19 | private Date birthDate; 20 | 21 | public Long getId() { 22 | return id; 23 | } 24 | 25 | public void setId(Long id) { 26 | this.id = id; 27 | } 28 | 29 | public String getFirstName() { 30 | return firstName; 31 | } 32 | 33 | public void setFirstName(String firstName) { 34 | this.firstName = firstName; 35 | } 36 | 37 | public String getLastName() { 38 | return lastName; 39 | } 40 | 41 | public void setLastName(String lastName) { 42 | this.lastName = lastName; 43 | } 44 | 45 | public int getNumber() { 46 | return number; 47 | } 48 | 49 | public void setNumber(int number) { 50 | this.number = number; 51 | } 52 | 53 | public Date getBirthDate() { 54 | return birthDate; 55 | } 56 | 57 | public void setBirthDate(Date birthDate) { 58 | this.birthDate = birthDate; 59 | } 60 | 61 | @Override 62 | public Person clone() { 63 | try { 64 | return (Person) super.clone(); 65 | } catch (CloneNotSupportedException e) { 66 | return null; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /RESTServer/src/main/java/org/spring/web/rest/repository/GenericRepository.java: -------------------------------------------------------------------------------- 1 | package org.spring.web.rest.repository; 2 | 3 | import java.util.List; 4 | 5 | public interface GenericRepository { 6 | 7 | public EntityType get(ID id); 8 | 9 | public Long add(EntityType o); 10 | 11 | public void update(EntityType o); 12 | 13 | public EntityType delete(ID id); 14 | 15 | public List findAll(); 16 | 17 | int getCount(); 18 | } 19 | -------------------------------------------------------------------------------- /RESTServer/src/main/java/org/spring/web/rest/repository/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package org.spring.web.rest.repository; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.spring.web.rest.model.Person; 7 | import org.springframework.jdbc.core.RowMapper; 8 | 9 | public interface PersonRepository extends GenericRepository { 10 | 11 | static final String TABLE_NAME = "PERSON"; 12 | 13 | static final Map ATTRIBUTE_COLUMN_NAMES = new HashMap(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /RESTServer/src/main/java/org/spring/web/rest/repository/impl/jdbc/JDBCPersonRepository.java: -------------------------------------------------------------------------------- 1 | package org.spring.web.rest.repository.impl.jdbc; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | import java.util.ArrayList; 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | import javax.sql.DataSource; 10 | 11 | import org.spring.web.rest.model.Person; 12 | import org.spring.web.rest.repository.PersonRepository; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.cache.annotation.Cacheable; 15 | import org.springframework.dao.DataAccessException; 16 | import org.springframework.jdbc.core.ResultSetExtractor; 17 | import org.springframework.jdbc.core.RowMapper; 18 | import org.springframework.stereotype.Repository; 19 | import org.springframework.transaction.annotation.Transactional; 20 | 21 | @Repository("JDBCPersonRepository") 22 | public class JDBCPersonRepository extends JDBCRepository implements 23 | PersonRepository { 24 | 25 | @Autowired 26 | public JDBCPersonRepository(DataSource dataSource) { 27 | super(dataSource); 28 | ATTRIBUTE_COLUMN_NAMES.put("id", "ID"); 29 | ATTRIBUTE_COLUMN_NAMES.put("firstName", "FIRST_NAME"); 30 | ATTRIBUTE_COLUMN_NAMES.put("lastName", "LAST_NAME"); 31 | ATTRIBUTE_COLUMN_NAMES.put("number", "NUMBER"); 32 | ATTRIBUTE_COLUMN_NAMES.put("birthDate", "BRITH_DATE"); 33 | } 34 | 35 | protected String getTableName() { 36 | return TABLE_NAME; 37 | } 38 | 39 | @Transactional(readOnly = true) 40 | public Person get(Long id) { 41 | String sql = new String("select * from " + getTableName() 42 | + " where id = ? "); 43 | return jdbcTemplate.queryForObject(sql, new Object[] { id }, 44 | getRowMaper()); 45 | } 46 | 47 | @Transactional 48 | public Long add(Person o) { 49 | Long id = o.getId(); 50 | if (id == null) { 51 | // User Id was not explicitly set, so try to find an appropriate 52 | // user id 53 | String sqlCount = "SELECT MAX(ID) + 1 FROM person"; 54 | id = (long) jdbcTemplate.queryForInt(sqlCount); 55 | } 56 | 57 | String sql = new String("insert into person values(?,?,?,?,?)"); 58 | jdbcTemplate.update(sql, id, o.getFirstName(), o.getLastName(), 59 | o.getNumber(), o.getBirthDate()); 60 | 61 | return id; 62 | } 63 | 64 | @Transactional 65 | public void update(Person o) { 66 | final String sql = "UPDATE person SET FIRST_NAME = ? , LAST_NAME = ?, " 67 | + "NUMBER = ?, BRITH_DATE=? WHERE ID = ?"; 68 | jdbcTemplate.update(sql, 69 | new Object[] { o.getFirstName(), o.getLastName(), 70 | o.getNumber(), o.getBirthDate(), o.getId() }); 71 | } 72 | 73 | @Transactional 74 | public Person delete(Long id) { 75 | Person temp = get(id); 76 | String sql = "DELETE FROM person WHERE id = ?"; 77 | jdbcTemplate.update(sql, id); 78 | return temp; 79 | } 80 | 81 | @Transactional(readOnly = true) 82 | public List findAll() { 83 | String sql = "SELECT ID, FIRST_NAME, LAST_NAME, NUMBER, BRITH_DATE FROM " 84 | + getTableName(); 85 | return (List) jdbcTemplate.query(sql, getResultSetExtractor()); 86 | } 87 | 88 | @Transactional(readOnly = true) 89 | public int getCount() { 90 | String sql = "SELECT Count(*) FROM " + getTableName(); 91 | return jdbcTemplate.queryForInt(sql); 92 | } 93 | 94 | private RowMapper getRowMaper() { 95 | return new RowMapper() { 96 | public Person mapRow(ResultSet rs, int arg1) throws SQLException { 97 | Person person = new Person(); 98 | person.setId(rs.getLong("ID")); 99 | person.setFirstName(rs.getString("FIRST_NAME")); 100 | person.setLastName(rs.getString("LAST_NAME")); 101 | person.setNumber(rs.getInt("NUMBER")); 102 | person.setBirthDate(rs.getDate("BRITH_DATE")); 103 | return person; 104 | } 105 | 106 | }; 107 | } 108 | 109 | @SuppressWarnings("unused") 110 | private ResultSetExtractor> getResultSetExtractor(){ 111 | return new ResultSetExtractor>() { 112 | public List extractData(ResultSet rs) throws SQLException, 113 | DataAccessException { 114 | List list = new ArrayList(); 115 | Person person; 116 | while(rs.next()){ 117 | person = new Person(); 118 | person.setId(rs.getLong("ID")); 119 | person.setFirstName(rs.getString("FIRST_NAME")); 120 | person.setLastName(rs.getString("LAST_NAME")); 121 | person.setNumber(rs.getInt("NUMBER")); 122 | person.setBirthDate(rs.getDate("BRITH_DATE")); 123 | list.add(person); 124 | } 125 | return list; 126 | } 127 | }; 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /RESTServer/src/main/java/org/spring/web/rest/repository/impl/jdbc/JDBCRepository.java: -------------------------------------------------------------------------------- 1 | package org.spring.web.rest.repository.impl.jdbc; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.spring.web.rest.repository.GenericRepository; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.jdbc.core.JdbcTemplate; 8 | 9 | public abstract class JDBCRepository { 10 | 11 | protected JdbcTemplate jdbcTemplate; 12 | 13 | public JDBCRepository(DataSource dataSource) { 14 | jdbcTemplate = new JdbcTemplate(dataSource); 15 | } 16 | 17 | protected abstract String getTableName(); 18 | } 19 | -------------------------------------------------------------------------------- /RESTServer/src/main/java/org/spring/web/rest/service/PersonService.java: -------------------------------------------------------------------------------- 1 | package org.spring.web.rest.service; 2 | 3 | import java.util.List; 4 | 5 | import org.spring.web.rest.model.Person; 6 | 7 | public interface PersonService { 8 | 9 | public List getAllPersons(); 10 | public Person getPerson(Long id); 11 | public Person addPerson(Person person); 12 | public Person updatePerson(Person person); 13 | public Person deletePerson(Long id); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /RESTServer/src/main/java/org/spring/web/rest/service/impl/PersonServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.spring.web.rest.service.impl; 2 | 3 | import java.util.List; 4 | 5 | import org.spring.web.rest.model.Person; 6 | import org.spring.web.rest.repository.PersonRepository; 7 | import org.spring.web.rest.service.PersonService; 8 | import org.springframework.beans.BeanUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | @Service 13 | public class PersonServiceImpl implements PersonService { 14 | 15 | @Autowired 16 | PersonRepository repository; 17 | 18 | public Person getPerson(Long id) { 19 | return repository.get(id); 20 | } 21 | 22 | public List getAllPersons() { 23 | return repository.findAll(); 24 | } 25 | 26 | public Person addPerson(Person person) { 27 | Long id = repository.add(person); 28 | return repository.get(id); 29 | } 30 | 31 | public Person updatePerson(Person person) { 32 | repository.update(person); 33 | return person; 34 | } 35 | 36 | public Person deletePerson(Long id) { 37 | Person temp = new Person(); 38 | BeanUtils.copyProperties(repository.get(id), temp); 39 | repository.delete(id); 40 | return temp; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /RESTServer/src/main/resources/db.properties: -------------------------------------------------------------------------------- 1 | db.driver=com.mysql.jdbc.Driver 2 | db.jdbcurl=jdbc:mysql://localhost:3306/test 3 | db.username=root 4 | db.password=123456 -------------------------------------------------------------------------------- /RESTServer/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /RESTServer/src/main/resources/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /RESTServer/src/main/resources/spring/security-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | 18 | 21 | 22 | 24 | 26 | 28 | 30 | 32 | 33 | 34 | 36 | 38 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 53 | 54 | 55 | 56 | 58 | 59 | 60 | 61 | 63 | 64 | -------------------------------------------------------------------------------- /RESTServer/src/main/webapp/WEB-INF/rest-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /RESTServer/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | /index 8 | 9 | 10 | contextConfigLocation 11 | 12 | classpath:spring/root-context.xml 13 | 14 | 15 | 16 | org.springframework.web.context.request.RequestContextListener 17 | 18 | 19 | org.springframework.web.context.ContextLoaderListener 20 | 21 | 22 | springSecurityFilterChain 23 | org.springframework.web.filter.DelegatingFilterProxy 24 | 25 | 26 | springSecurityFilterChain 27 | /* 28 | 29 | 30 | rest 31 | org.springframework.web.servlet.DispatcherServlet 32 | 1 33 | 34 | 35 | rest 36 | /rest/* 37 | 38 | 39 | -------------------------------------------------------------------------------- /RESTServer/target/.gitignore: -------------------------------------------------------------------------------- 1 | /classes 2 | -------------------------------------------------------------------------------- /RESTServer/target/m2e-wtp/web-resources/.gitignore: -------------------------------------------------------------------------------- 1 | /META-INF 2 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | org.spring.test 5 | Spring_REST_OAuth 6 | 0.0.1-SNAPSHOT 7 | pom 8 | 9 | 3.2.1.RELEASE 10 | 3.1.3.RELEASE 11 | 1.0.2.RELEASE 12 | 13 | 14 | 15 | org.springframework 16 | spring-context 17 | ${spring.version} 18 | 19 | 20 | org.springframework 21 | spring-web 22 | ${spring.version} 23 | 24 | 25 | org.springframework 26 | spring-webmvc 27 | ${spring.version} 28 | 29 | 30 | org.springframework 31 | spring-jdbc 32 | ${spring.version} 33 | 34 | 35 | org.springframework 36 | spring-aop 37 | ${spring.version} 38 | 39 | 40 | org.springframework 41 | spring-tx 42 | ${spring.version} 43 | 44 | 45 | org.springframework.security 46 | spring-security-web 47 | ${spring.security.version} 48 | 49 | 50 | org.springframework.security 51 | spring-security-core 52 | ${spring.security.version} 53 | 54 | 55 | org.springframework.security 56 | spring-security-config 57 | ${spring.security.version} 58 | 59 | 60 | org.springframework.security 61 | spring-security-taglibs 62 | ${spring.security.version} 63 | 64 | 65 | org.springframework.security.oauth 66 | spring-security-oauth2 67 | ${spring.security.oauth.version} 68 | 69 | 70 | org.aspectj 71 | aspectjrt 72 | 1.6.11 73 | 74 | 75 | org.aspectj 76 | aspectjweaver 77 | 1.6.11 78 | 79 | 80 | cglib 81 | cglib 82 | 2.2.2 83 | 84 | 85 | org.slf4j 86 | jcl-over-slf4j 87 | 1.6.6 88 | 89 | 90 | org.slf4j 91 | jul-to-slf4j 92 | 1.6.6 93 | 94 | 95 | org.slf4j 96 | slf4j-api 97 | 1.6.6 98 | 99 | 100 | ch.qos.logback 101 | logback-classic 102 | 1.0.9 103 | 104 | 105 | javax.servlet 106 | jstl 107 | 1.2 108 | 109 | 110 | javax.servlet 111 | servlet-api 112 | 2.5 113 | provided 114 | 115 | 116 | 117 | org.hibernate 118 | hibernate-validator 119 | 4.2.0.Final 120 | 121 | 122 | commons-beanutils 123 | commons-beanutils 124 | 1.8.3 125 | 126 | 127 | mysql 128 | mysql-connector-java 129 | 5.1.21 130 | 131 | 132 | 133 | RESTServer 134 | RESTClient 135 | AuthServer 136 | 137 | 138 | 139 | 140 | org.mortbay.jetty 141 | jetty-maven-plugin 142 | 143 | 10 144 | 145 | /OAuth 146 | 147 | 148 | 149 | ./AuthServer/target/AuthServer-0.0.1-SNAPSHOT.war 150 | /AuthServer 151 | 152 | 153 | ./RESTServer/target/RESTServer-0.0.1-SNAPSHOT.war 154 | /AuthServer 155 | 156 | 157 | ./RESTClient/target/RESTClient-0.0.1-SNAPSHOT.war 158 | /RESTClient 159 | 160 | 161 | 162 | 163 | 168 | 169 | 170 | --------------------------------------------------------------------------------