mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 02:38:47 +00:00
Merge remote-tracking branch 'origin/master' into display-search-results
This commit is contained in:
commit
2119b63696
5
.gitignore
vendored
5
.gitignore
vendored
@ -44,6 +44,7 @@ captures/
|
||||
.idea/assetWizardSettings.xml
|
||||
.idea/dictionaries
|
||||
.idea/libraries
|
||||
*.idea*
|
||||
# Android Studio 3 in .gitignore file.
|
||||
.idea/caches
|
||||
.idea/modules.xml
|
||||
@ -83,3 +84,7 @@ lint/generated/
|
||||
lint/outputs/
|
||||
lint/tmp/
|
||||
# lint/reports/
|
||||
Lambdas/Lists/src/main/resources/dbProperties.json
|
||||
Lambdas/Lists/target/classes/dbProperties.json
|
||||
Lambdas/Lists/target/classes/META-INF/Lists.kotlin_module
|
||||
Listify/app/src/main/res/raw/auths.json
|
||||
|
||||
47
Lambdas/Lists/pom.xml
Normal file
47
Lambdas/Lists/pom.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>groupId</groupId>
|
||||
<artifactId>Lists</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-lambda-java-core</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-lambda-java-events</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-lambda-java-log4j2</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20200518</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.source>1.11</maven.compiler.source>
|
||||
<maven.compiler.target>1.11</maven.compiler.target>
|
||||
</properties>
|
||||
</project>
|
||||
53
Lambdas/Lists/src/main/java/DBConnector.java
Normal file
53
Lambdas/Lists/src/main/java/DBConnector.java
Normal file
@ -0,0 +1,53 @@
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class DBConnector {
|
||||
|
||||
Connection connection;
|
||||
|
||||
DBConnector() throws IOException, SQLException, ClassNotFoundException {
|
||||
this(loadProperties("dbProperties.json"));
|
||||
}
|
||||
|
||||
DBConnector(Properties dbProperties) throws SQLException, ClassNotFoundException {
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
System.out.println(dbProperties);
|
||||
System.out.println(DBConnector.buildURL(dbProperties));
|
||||
connection = DriverManager.getConnection(dbProperties.get("url").toString(), dbProperties.get("user").toString(), dbProperties.get("password").toString());
|
||||
System.out.println(connection);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public static Properties loadProperties(String path) throws IOException {
|
||||
Properties toReturn = new Properties();
|
||||
String propertiesJSONString = Files.readString(Path.of(path));
|
||||
JSONObject propertiesJSON = new JSONObject(propertiesJSONString);
|
||||
propertiesJSON.keys().forEachRemaining(key -> toReturn.setProperty(key, propertiesJSON.get(key).toString()));
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static String buildURL(Properties dbProperties) {
|
||||
String dbURL = dbProperties.get("url").toString();
|
||||
dbURL += "?user=" + dbProperties.get("user").toString();
|
||||
dbURL += "&password=" + dbProperties.get("password").toString();
|
||||
return dbURL;
|
||||
}
|
||||
}
|
||||
28
Lambdas/Lists/src/main/java/InputUtils.java
Normal file
28
Lambdas/Lists/src/main/java/InputUtils.java
Normal file
@ -0,0 +1,28 @@
|
||||
import java.util.Map;
|
||||
|
||||
public class InputUtils {
|
||||
public static String getCognitoIDFromBody(Map<String, Object> inputMap) {
|
||||
System.out.println(inputMap.keySet());
|
||||
System.out.println(inputMap.entrySet());
|
||||
Map<String, Object> contextMap;
|
||||
if ((inputMap.get("context") != null) && (inputMap.get("context") instanceof Map<?, ?>)) {
|
||||
contextMap = ((Map<String, Object>) inputMap.get("context"));
|
||||
} else {
|
||||
throw new IllegalArgumentException("The key \"context\" must exist and be a map");
|
||||
}
|
||||
System.out.println(inputMap.get("context"));
|
||||
System.out.println(contextMap.get("sub"));
|
||||
return contextMap.get("sub").toString();
|
||||
}
|
||||
|
||||
public static Map<String, Object> getBody(Map<String, Object> inputMap) {
|
||||
return getMap(inputMap, "body");
|
||||
}
|
||||
|
||||
public static Map<String, Object> getMap(Map<String, Object> parentMap, String childKey) {
|
||||
if ((parentMap.get(childKey) != null) && (parentMap.get(childKey) instanceof Map<?, ?>)) {
|
||||
return ((Map<String, Object>) parentMap.get(childKey));
|
||||
}
|
||||
throw new IllegalArgumentException("The key \"" + childKey + "\" must exist and be a map");
|
||||
}
|
||||
}
|
||||
27
Lambdas/Lists/src/main/java/ListAdder.java
Normal file
27
Lambdas/Lists/src/main/java/ListAdder.java
Normal file
@ -0,0 +1,27 @@
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
public class ListAdder {
|
||||
|
||||
private DBConnector connector;
|
||||
private String cognitoID;
|
||||
|
||||
private final String LIST_CREATE = "INSERT INTO Lists (Name, Owner) VALUES (?, ?)";
|
||||
|
||||
ListAdder(DBConnector connector, String cognitoID) {
|
||||
this.connector = connector;
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
|
||||
public void add(Map<String, Object> bodyMap) throws SQLException {
|
||||
Connection connection = connector.getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement(LIST_CREATE);
|
||||
statement.setString(1, bodyMap.get("name").toString());//Needs safe checking
|
||||
statement.setString(2, cognitoID);
|
||||
System.out.println(statement);
|
||||
statement.executeUpdate();
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
28
Lambdas/Lists/src/main/java/ListPOST.java
Normal file
28
Lambdas/Lists/src/main/java/ListPOST.java
Normal file
@ -0,0 +1,28 @@
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
import com.amazonaws.services.lambda.runtime.Context;
|
||||
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||
|
||||
public class ListPOST implements RequestHandler<Map<String,Object>, String>{
|
||||
|
||||
|
||||
public String handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
String cognitoID = InputUtils.getCognitoIDFromBody(inputMap);
|
||||
try {
|
||||
DBConnector connector = new DBConnector();
|
||||
try {
|
||||
new ListAdder(connector, cognitoID).add(InputUtils.getBody(inputMap));
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
connector.close();
|
||||
}
|
||||
} catch (IOException|SQLException|ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
16
Listify/.gitignore
vendored
16
Listify/.gitignore
vendored
@ -12,3 +12,19 @@
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
|
||||
#amplify
|
||||
amplify/\#current-cloud-backend
|
||||
amplify/.config/local-*
|
||||
amplify/mock-data
|
||||
amplify/backend/amplify-meta.json
|
||||
amplify/backend/awscloudformation
|
||||
build/
|
||||
dist/
|
||||
node_modules/
|
||||
aws-exports.js
|
||||
awsconfiguration.json
|
||||
amplifyconfiguration.json
|
||||
amplify-build-config.json
|
||||
amplify-gradle-config.json
|
||||
amplifytools.xcconfig
|
||||
@ -4,6 +4,7 @@
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="delegatedBuild" value="false" />
|
||||
<option name="testRunner" value="PLATFORM" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
11
Listify/Pipfile
Normal file
11
Listify/Pipfile
Normal file
@ -0,0 +1,11 @@
|
||||
[[source]]
|
||||
name = "pypi"
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.8"
|
||||
13
Listify/amplify/.config/project-config.json
Normal file
13
Listify/amplify/.config/project-config.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"projectName": "Listify",
|
||||
"version": "3.0",
|
||||
"frontend": "android",
|
||||
"android": {
|
||||
"config": {
|
||||
"ResDir": "app/src/main/res"
|
||||
}
|
||||
},
|
||||
"providers": [
|
||||
"awscloudformation"
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,396 @@
|
||||
AWSTemplateFormatVersion: 2010-09-09
|
||||
|
||||
Parameters:
|
||||
env:
|
||||
Type: String
|
||||
authRoleArn:
|
||||
Type: String
|
||||
unauthRoleArn:
|
||||
Type: String
|
||||
|
||||
|
||||
|
||||
|
||||
identityPoolName:
|
||||
Type: String
|
||||
|
||||
allowUnauthenticatedIdentities:
|
||||
Type: String
|
||||
|
||||
resourceNameTruncated:
|
||||
Type: String
|
||||
|
||||
userPoolName:
|
||||
Type: String
|
||||
|
||||
autoVerifiedAttributes:
|
||||
Type: CommaDelimitedList
|
||||
|
||||
mfaConfiguration:
|
||||
Type: String
|
||||
|
||||
mfaTypes:
|
||||
Type: CommaDelimitedList
|
||||
|
||||
smsAuthenticationMessage:
|
||||
Type: String
|
||||
|
||||
smsVerificationMessage:
|
||||
Type: String
|
||||
|
||||
emailVerificationSubject:
|
||||
Type: String
|
||||
|
||||
emailVerificationMessage:
|
||||
Type: String
|
||||
|
||||
defaultPasswordPolicy:
|
||||
Type: String
|
||||
|
||||
passwordPolicyMinLength:
|
||||
Type: Number
|
||||
|
||||
passwordPolicyCharacters:
|
||||
Type: CommaDelimitedList
|
||||
|
||||
requiredAttributes:
|
||||
Type: CommaDelimitedList
|
||||
|
||||
userpoolClientGenerateSecret:
|
||||
Type: String
|
||||
|
||||
userpoolClientRefreshTokenValidity:
|
||||
Type: Number
|
||||
|
||||
userpoolClientWriteAttributes:
|
||||
Type: CommaDelimitedList
|
||||
|
||||
userpoolClientReadAttributes:
|
||||
Type: CommaDelimitedList
|
||||
|
||||
userpoolClientLambdaRole:
|
||||
Type: String
|
||||
|
||||
userpoolClientSetAttributes:
|
||||
Type: String
|
||||
|
||||
sharedId:
|
||||
Type: String
|
||||
|
||||
resourceName:
|
||||
Type: String
|
||||
|
||||
authSelections:
|
||||
Type: String
|
||||
|
||||
useDefault:
|
||||
Type: String
|
||||
|
||||
usernameAttributes:
|
||||
Type: CommaDelimitedList
|
||||
|
||||
triggers:
|
||||
Type: String
|
||||
|
||||
userPoolGroupList:
|
||||
Type: CommaDelimitedList
|
||||
|
||||
serviceName:
|
||||
Type: String
|
||||
|
||||
parentStack:
|
||||
Type: String
|
||||
|
||||
permissions:
|
||||
Type: CommaDelimitedList
|
||||
|
||||
dependsOn:
|
||||
Type: CommaDelimitedList
|
||||
|
||||
Conditions:
|
||||
ShouldNotCreateEnvResources: !Equals [ !Ref env, NONE ]
|
||||
|
||||
Resources:
|
||||
|
||||
|
||||
# BEGIN SNS ROLE RESOURCE
|
||||
SNSRole:
|
||||
# Created to allow the UserPool SMS Config to publish via the Simple Notification Service during MFA Process
|
||||
Type: AWS::IAM::Role
|
||||
Properties:
|
||||
RoleName: !If [ShouldNotCreateEnvResources, 'listiff4fad454_sns-role', !Join ['',[ 'sns', 'f4fad454', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]]
|
||||
AssumeRolePolicyDocument:
|
||||
Version: "2012-10-17"
|
||||
Statement:
|
||||
- Sid: ""
|
||||
Effect: "Allow"
|
||||
Principal:
|
||||
Service: "cognito-idp.amazonaws.com"
|
||||
Action:
|
||||
- "sts:AssumeRole"
|
||||
Condition:
|
||||
StringEquals:
|
||||
sts:ExternalId: listiff4fad454_role_external_id
|
||||
Policies:
|
||||
-
|
||||
PolicyName: listiff4fad454-sns-policy
|
||||
PolicyDocument:
|
||||
Version: "2012-10-17"
|
||||
Statement:
|
||||
-
|
||||
Effect: "Allow"
|
||||
Action:
|
||||
- "sns:Publish"
|
||||
Resource: "*"
|
||||
# BEGIN USER POOL RESOURCES
|
||||
UserPool:
|
||||
# Created upon user selection
|
||||
# Depends on SNS Role for Arn if MFA is enabled
|
||||
Type: AWS::Cognito::UserPool
|
||||
UpdateReplacePolicy: Retain
|
||||
Properties:
|
||||
UserPoolName: !If [ShouldNotCreateEnvResources, !Ref userPoolName, !Join ['',[!Ref userPoolName, '-', !Ref env]]]
|
||||
|
||||
Schema:
|
||||
|
||||
-
|
||||
Name: email
|
||||
Required: true
|
||||
Mutable: true
|
||||
|
||||
|
||||
|
||||
|
||||
AutoVerifiedAttributes: !Ref autoVerifiedAttributes
|
||||
|
||||
|
||||
EmailVerificationMessage: !Ref emailVerificationMessage
|
||||
EmailVerificationSubject: !Ref emailVerificationSubject
|
||||
|
||||
Policies:
|
||||
PasswordPolicy:
|
||||
MinimumLength: !Ref passwordPolicyMinLength
|
||||
RequireLowercase: false
|
||||
RequireNumbers: false
|
||||
RequireSymbols: false
|
||||
RequireUppercase: false
|
||||
|
||||
UsernameAttributes: !Ref usernameAttributes
|
||||
|
||||
MfaConfiguration: !Ref mfaConfiguration
|
||||
SmsVerificationMessage: !Ref smsVerificationMessage
|
||||
SmsConfiguration:
|
||||
SnsCallerArn: !GetAtt SNSRole.Arn
|
||||
ExternalId: listiff4fad454_role_external_id
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Updating lambda role with permissions to Cognito
|
||||
|
||||
|
||||
UserPoolClientWeb:
|
||||
# Created provide application access to user pool
|
||||
# Depends on UserPool for ID reference
|
||||
Type: "AWS::Cognito::UserPoolClient"
|
||||
Properties:
|
||||
ClientName: listiff4fad454_app_clientWeb
|
||||
|
||||
RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity
|
||||
UserPoolId: !Ref UserPool
|
||||
DependsOn: UserPool
|
||||
UserPoolClient:
|
||||
# Created provide application access to user pool
|
||||
# Depends on UserPool for ID reference
|
||||
Type: "AWS::Cognito::UserPoolClient"
|
||||
Properties:
|
||||
ClientName: listiff4fad454_app_client
|
||||
|
||||
GenerateSecret: !Ref userpoolClientGenerateSecret
|
||||
RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity
|
||||
UserPoolId: !Ref UserPool
|
||||
DependsOn: UserPool
|
||||
# BEGIN USER POOL LAMBDA RESOURCES
|
||||
UserPoolClientRole:
|
||||
# Created to execute Lambda which gets userpool app client config values
|
||||
Type: 'AWS::IAM::Role'
|
||||
Properties:
|
||||
RoleName: !If [ShouldNotCreateEnvResources, !Ref userpoolClientLambdaRole, !Join ['',['upClientLambdaRole', 'f4fad454', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]]
|
||||
AssumeRolePolicyDocument:
|
||||
Version: '2012-10-17'
|
||||
Statement:
|
||||
- Effect: Allow
|
||||
Principal:
|
||||
Service:
|
||||
- lambda.amazonaws.com
|
||||
Action:
|
||||
- 'sts:AssumeRole'
|
||||
DependsOn: UserPoolClient
|
||||
UserPoolClientLambda:
|
||||
# Lambda which gets userpool app client config values
|
||||
# Depends on UserPool for id
|
||||
# Depends on UserPoolClientRole for role ARN
|
||||
Type: 'AWS::Lambda::Function'
|
||||
Properties:
|
||||
Code:
|
||||
ZipFile: !Join
|
||||
- |+
|
||||
- - 'const response = require(''cfn-response'');'
|
||||
- 'const aws = require(''aws-sdk'');'
|
||||
- 'const identity = new aws.CognitoIdentityServiceProvider();'
|
||||
- 'exports.handler = (event, context, callback) => {'
|
||||
- ' if (event.RequestType == ''Delete'') { '
|
||||
- ' response.send(event, context, response.SUCCESS, {})'
|
||||
- ' }'
|
||||
- ' if (event.RequestType == ''Update'' || event.RequestType == ''Create'') {'
|
||||
- ' const params = {'
|
||||
- ' ClientId: event.ResourceProperties.clientId,'
|
||||
- ' UserPoolId: event.ResourceProperties.userpoolId'
|
||||
- ' };'
|
||||
- ' identity.describeUserPoolClient(params).promise()'
|
||||
- ' .then((res) => {'
|
||||
- ' response.send(event, context, response.SUCCESS, {''appSecret'': res.UserPoolClient.ClientSecret});'
|
||||
- ' })'
|
||||
- ' .catch((err) => {'
|
||||
- ' response.send(event, context, response.FAILED, {err});'
|
||||
- ' });'
|
||||
- ' }'
|
||||
- '};'
|
||||
Handler: index.handler
|
||||
Runtime: nodejs10.x
|
||||
Timeout: '300'
|
||||
Role: !GetAtt
|
||||
- UserPoolClientRole
|
||||
- Arn
|
||||
DependsOn: UserPoolClientRole
|
||||
UserPoolClientLambdaPolicy:
|
||||
# Sets userpool policy for the role that executes the Userpool Client Lambda
|
||||
# Depends on UserPool for Arn
|
||||
# Marked as depending on UserPoolClientRole for easier to understand CFN sequencing
|
||||
Type: 'AWS::IAM::Policy'
|
||||
Properties:
|
||||
PolicyName: listiff4fad454_userpoolclient_lambda_iam_policy
|
||||
Roles:
|
||||
- !Ref UserPoolClientRole
|
||||
PolicyDocument:
|
||||
Version: '2012-10-17'
|
||||
Statement:
|
||||
- Effect: Allow
|
||||
Action:
|
||||
- 'cognito-idp:DescribeUserPoolClient'
|
||||
Resource: !GetAtt UserPool.Arn
|
||||
DependsOn: UserPoolClientLambda
|
||||
UserPoolClientLogPolicy:
|
||||
# Sets log policy for the role that executes the Userpool Client Lambda
|
||||
# Depends on UserPool for Arn
|
||||
# Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing
|
||||
Type: 'AWS::IAM::Policy'
|
||||
Properties:
|
||||
PolicyName: listiff4fad454_userpoolclient_lambda_log_policy
|
||||
Roles:
|
||||
- !Ref UserPoolClientRole
|
||||
PolicyDocument:
|
||||
Version: 2012-10-17
|
||||
Statement:
|
||||
- Effect: Allow
|
||||
Action:
|
||||
- 'logs:CreateLogGroup'
|
||||
- 'logs:CreateLogStream'
|
||||
- 'logs:PutLogEvents'
|
||||
Resource: !Sub
|
||||
- arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:*
|
||||
- { region: !Ref "AWS::Region", account: !Ref "AWS::AccountId", lambda: !Ref UserPoolClientLambda}
|
||||
DependsOn: UserPoolClientLambdaPolicy
|
||||
UserPoolClientInputs:
|
||||
# Values passed to Userpool client Lambda
|
||||
# Depends on UserPool for Id
|
||||
# Depends on UserPoolClient for Id
|
||||
# Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing
|
||||
Type: 'Custom::LambdaCallout'
|
||||
Properties:
|
||||
ServiceToken: !GetAtt UserPoolClientLambda.Arn
|
||||
clientId: !Ref UserPoolClient
|
||||
userpoolId: !Ref UserPool
|
||||
DependsOn: UserPoolClientLogPolicy
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# BEGIN IDENTITY POOL RESOURCES
|
||||
|
||||
|
||||
IdentityPool:
|
||||
# Always created
|
||||
Type: AWS::Cognito::IdentityPool
|
||||
Properties:
|
||||
IdentityPoolName: !If [ShouldNotCreateEnvResources, 'listifyf4fad454_identitypool_f4fad454', !Join ['',['listifyf4fad454_identitypool_f4fad454', '__', !Ref env]]]
|
||||
|
||||
CognitoIdentityProviders:
|
||||
- ClientId: !Ref UserPoolClient
|
||||
ProviderName: !Sub
|
||||
- cognito-idp.${region}.amazonaws.com/${client}
|
||||
- { region: !Ref "AWS::Region", client: !Ref UserPool}
|
||||
- ClientId: !Ref UserPoolClientWeb
|
||||
ProviderName: !Sub
|
||||
- cognito-idp.${region}.amazonaws.com/${client}
|
||||
- { region: !Ref "AWS::Region", client: !Ref UserPool}
|
||||
|
||||
AllowUnauthenticatedIdentities: !Ref allowUnauthenticatedIdentities
|
||||
|
||||
|
||||
DependsOn: UserPoolClientInputs
|
||||
|
||||
|
||||
IdentityPoolRoleMap:
|
||||
# Created to map Auth and Unauth roles to the identity pool
|
||||
# Depends on Identity Pool for ID ref
|
||||
Type: AWS::Cognito::IdentityPoolRoleAttachment
|
||||
Properties:
|
||||
IdentityPoolId: !Ref IdentityPool
|
||||
Roles:
|
||||
unauthenticated: !Ref unauthRoleArn
|
||||
authenticated: !Ref authRoleArn
|
||||
DependsOn: IdentityPool
|
||||
|
||||
|
||||
Outputs :
|
||||
|
||||
IdentityPoolId:
|
||||
Value: !Ref 'IdentityPool'
|
||||
Description: Id for the identity pool
|
||||
IdentityPoolName:
|
||||
Value: !GetAtt IdentityPool.Name
|
||||
|
||||
|
||||
|
||||
|
||||
UserPoolId:
|
||||
Value: !Ref 'UserPool'
|
||||
Description: Id for the user pool
|
||||
UserPoolName:
|
||||
Value: !Ref userPoolName
|
||||
AppClientIDWeb:
|
||||
Value: !Ref 'UserPoolClientWeb'
|
||||
Description: The user pool app client id for web
|
||||
AppClientID:
|
||||
Value: !Ref 'UserPoolClient'
|
||||
Description: The user pool app client id
|
||||
AppClientSecret:
|
||||
Value: !GetAtt UserPoolClientInputs.appSecret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
60
Listify/amplify/backend/auth/listifyf4fad454/parameters.json
Normal file
60
Listify/amplify/backend/auth/listifyf4fad454/parameters.json
Normal file
@ -0,0 +1,60 @@
|
||||
{
|
||||
"identityPoolName": "listifyf4fad454_identitypool_f4fad454",
|
||||
"allowUnauthenticatedIdentities": true,
|
||||
"resourceNameTruncated": "listiff4fad454",
|
||||
"userPoolName": "listifyf4fad454_userpool_f4fad454",
|
||||
"autoVerifiedAttributes": [
|
||||
"email"
|
||||
],
|
||||
"mfaConfiguration": "OFF",
|
||||
"mfaTypes": [
|
||||
"SMS Text Message"
|
||||
],
|
||||
"smsAuthenticationMessage": "Your authentication code is {####}",
|
||||
"smsVerificationMessage": "Your verification code is {####}",
|
||||
"emailVerificationSubject": "Your verification code",
|
||||
"emailVerificationMessage": "Your verification code is {####}",
|
||||
"defaultPasswordPolicy": false,
|
||||
"passwordPolicyMinLength": 8,
|
||||
"passwordPolicyCharacters": [],
|
||||
"requiredAttributes": [
|
||||
"email"
|
||||
],
|
||||
"userpoolClientGenerateSecret": true,
|
||||
"userpoolClientRefreshTokenValidity": 30,
|
||||
"userpoolClientWriteAttributes": [
|
||||
"email"
|
||||
],
|
||||
"userpoolClientReadAttributes": [
|
||||
"email"
|
||||
],
|
||||
"userpoolClientLambdaRole": "listiff4fad454_userpoolclient_lambda_role",
|
||||
"userpoolClientSetAttributes": false,
|
||||
"sharedId": "f4fad454",
|
||||
"resourceName": "listifyf4fad454",
|
||||
"authSelections": "identityPoolAndUserPool",
|
||||
"authRoleArn": {
|
||||
"Fn::GetAtt": [
|
||||
"AuthRole",
|
||||
"Arn"
|
||||
]
|
||||
},
|
||||
"unauthRoleArn": {
|
||||
"Fn::GetAtt": [
|
||||
"UnauthRole",
|
||||
"Arn"
|
||||
]
|
||||
},
|
||||
"useDefault": "default",
|
||||
"usernameAttributes": [
|
||||
"email"
|
||||
],
|
||||
"triggers": "{}",
|
||||
"userPoolGroupList": [],
|
||||
"serviceName": "Cognito",
|
||||
"parentStack": {
|
||||
"Ref": "AWS::StackId"
|
||||
},
|
||||
"permissions": [],
|
||||
"dependsOn": []
|
||||
}
|
||||
12
Listify/amplify/backend/backend-config.json
Normal file
12
Listify/amplify/backend/backend-config.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"auth": {
|
||||
"listifyf4fad454": {
|
||||
"service": "Cognito",
|
||||
"providerPlugin": "awscloudformation",
|
||||
"dependsOn": [],
|
||||
"customAuth": false
|
||||
}
|
||||
},
|
||||
"function": {},
|
||||
"api": {}
|
||||
}
|
||||
10
Listify/amplify/backend/tags.json
Normal file
10
Listify/amplify/backend/tags.json
Normal file
@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"Key": "user:Stack",
|
||||
"Value": "{project-env}"
|
||||
},
|
||||
{
|
||||
"Key": "user:Application",
|
||||
"Value": "{project-name}"
|
||||
}
|
||||
]
|
||||
3
Listify/amplify/cli.json
Normal file
3
Listify/amplify/cli.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"features": {}
|
||||
}
|
||||
20
Listify/amplify/team-provider-info.json
Normal file
20
Listify/amplify/team-provider-info.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"dev": {
|
||||
"awscloudformation": {
|
||||
"AuthRoleName": "amplify-listify-dev-134836-authRole",
|
||||
"UnauthRoleArn": "arn:aws:iam::569815541706:role/amplify-listify-dev-134836-unauthRole",
|
||||
"AuthRoleArn": "arn:aws:iam::569815541706:role/amplify-listify-dev-134836-authRole",
|
||||
"Region": "us-east-2",
|
||||
"DeploymentBucketName": "amplify-listify-dev-134836-deployment",
|
||||
"UnauthRoleName": "amplify-listify-dev-134836-unauthRole",
|
||||
"StackName": "amplify-listify-dev-134836",
|
||||
"StackId": "arn:aws:cloudformation:us-east-2:569815541706:stack/amplify-listify-dev-134836/5980b520-faa0-11ea-a89c-0650659cf0f8",
|
||||
"AmplifyAppId": "dbnznhwtkbqz6"
|
||||
},
|
||||
"categories": {
|
||||
"auth": {
|
||||
"listifyf4fad454": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7,13 +7,20 @@ android {
|
||||
defaultConfig {
|
||||
applicationId "com.example.listify"
|
||||
minSdkVersion 28
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 28
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
// Support for Java 8 features
|
||||
coreLibraryDesugaringEnabled true
|
||||
sourceCompatibility 1.8
|
||||
targetCompatibility 1.8
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
@ -23,7 +30,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
@ -31,9 +38,17 @@ dependencies {
|
||||
implementation 'androidx.navigation:navigation-fragment:2.1.0'
|
||||
implementation 'androidx.navigation:navigation-ui:2.1.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
|
||||
implementation files('lib\\glide\\glide-3.6.0.jar')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
implementation 'com.amplifyframework:core:1.3.2'
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.10'
|
||||
implementation 'com.amplifyframework:aws-auth-cognito:1.3.2'
|
||||
implementation 'com.android.volley:volley:1.1.1'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
|
||||
implementation 'org.json:json:20200518'
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||
|
||||
}
|
||||
@ -4,6 +4,7 @@
|
||||
<uses-permission android:name = "android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:name=".Listify"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
@ -30,8 +31,10 @@
|
||||
</activity>
|
||||
|
||||
<activity android:name="com.example.listify.ui.SignupPage" />
|
||||
|
||||
<activity android:name="com.example.listify.ui.LoginPage" />
|
||||
<activity android:name="com.example.listify.ui.ForgotPasswordPage" />
|
||||
<activity android:name="com.example.listify.ui.ResetPasswordPage" />
|
||||
<activity android:name="com.example.listify.ui.CodePage" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
139
Listify/app/src/main/java/com/example/listify/AuthManager.java
Normal file
139
Listify/app/src/main/java/com/example/listify/AuthManager.java
Normal file
@ -0,0 +1,139 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.content.Context;
|
||||
import com.amplifyframework.auth.AuthException;
|
||||
import com.amplifyframework.auth.AuthSession;
|
||||
import com.amplifyframework.auth.cognito.AWSCognitoAuthSession;
|
||||
import com.amplifyframework.auth.options.AuthSignUpOptions;
|
||||
import com.amplifyframework.auth.result.AuthSignInResult;
|
||||
import com.amplifyframework.auth.result.AuthSignUpResult;
|
||||
import com.amplifyframework.core.Amplify;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Properties;
|
||||
|
||||
public class AuthManager {
|
||||
AWSCognitoAuthSession authSession = null;
|
||||
AuthSignUpResult authSignUpResult = null;
|
||||
AuthSignInResult authSignInResult = null;
|
||||
AuthException authError = null;
|
||||
String email = null;
|
||||
String password = null;
|
||||
volatile boolean waiting = false;
|
||||
|
||||
|
||||
void fetchAuthSession() throws AuthException {
|
||||
waiting = true;
|
||||
Amplify.Auth.fetchAuthSession(
|
||||
result -> setAuthSession(result),
|
||||
error -> setAuthError(error)
|
||||
);
|
||||
throwIfAuthError();
|
||||
}
|
||||
|
||||
public AWSCognitoAuthSession getAuthSession() throws AuthException {
|
||||
if (authSession == null) {
|
||||
fetchAuthSession();
|
||||
}
|
||||
|
||||
return authSession;
|
||||
}
|
||||
|
||||
public String getUserToken() {
|
||||
return authSession.getUserPoolTokens().getValue().getIdToken();
|
||||
}
|
||||
|
||||
|
||||
public void setAuthSession(AuthSession toSet) {
|
||||
authSession = (AWSCognitoAuthSession) toSet;
|
||||
waiting = false;
|
||||
}
|
||||
|
||||
public void setAuthError(AuthException newError) {
|
||||
authError = newError;
|
||||
waiting = false;
|
||||
}
|
||||
|
||||
public void throwIfAuthError() throws AuthException{
|
||||
while (waiting);
|
||||
if (authError == null) {
|
||||
return;
|
||||
}
|
||||
AuthException toThrow = authError;
|
||||
authError = null;
|
||||
throw toThrow;
|
||||
}
|
||||
|
||||
public void setAuthSignUpResult(AuthSignUpResult toSet) {
|
||||
authSignUpResult = toSet;
|
||||
}
|
||||
|
||||
public void setAuthSignInResult(AuthSignInResult toSet) {
|
||||
authSignInResult = toSet;
|
||||
waiting = false;
|
||||
}
|
||||
|
||||
public void startSignUp(String email, String password) throws AuthException {
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
waiting = true;
|
||||
Amplify.Auth.signUp(
|
||||
email,
|
||||
password,
|
||||
AuthSignUpOptions.builder().build(),
|
||||
result -> setAuthSignUpResult(result),
|
||||
error -> setAuthError(error)
|
||||
);
|
||||
throwIfAuthError();
|
||||
|
||||
}
|
||||
|
||||
public void confirmSignUp(String confirmationCode) throws AuthException {
|
||||
waiting = true;
|
||||
Amplify.Auth.confirmSignUp(
|
||||
email,
|
||||
confirmationCode,
|
||||
result -> setAuthSignUpResult(result),
|
||||
error -> setAuthError(error)
|
||||
);
|
||||
throwIfAuthError();
|
||||
}
|
||||
|
||||
public void signIn(String email, String password) throws AuthException{
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
waiting = true;
|
||||
Amplify.Auth.signIn(
|
||||
email,
|
||||
password,
|
||||
result -> setAuthSignInResult(result),
|
||||
error -> setAuthError(error)
|
||||
);
|
||||
throwIfAuthError();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Properties loadProperties(Context context, String path) throws IOException, JSONException {
|
||||
Properties toReturn = new Properties();
|
||||
String propertiesJSONString = "";
|
||||
for (Object line : new BufferedReader(new InputStreamReader(context.getResources().openRawResource(R.raw.auths))).lines().toArray()) {
|
||||
propertiesJSONString += line.toString();
|
||||
}
|
||||
System.out.println(propertiesJSONString);
|
||||
JSONObject propertiesJSON = new JSONObject(propertiesJSONString);
|
||||
propertiesJSON.keys().forEachRemaining(key -> {
|
||||
try {
|
||||
toReturn.setProperty(key, propertiesJSON.get(key).toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
System.out.println(toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
8
Listify/app/src/main/java/com/example/listify/List.java
Normal file
8
Listify/app/src/main/java/com/example/listify/List.java
Normal file
@ -0,0 +1,8 @@
|
||||
package com.example.listify;
|
||||
|
||||
public class List {
|
||||
String name;
|
||||
List(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
20
Listify/app/src/main/java/com/example/listify/Listify.java
Normal file
20
Listify/app/src/main/java/com/example/listify/Listify.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.util.Log;
|
||||
import com.amplifyframework.AmplifyException;
|
||||
import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin;
|
||||
import com.amplifyframework.core.Amplify;
|
||||
|
||||
public class Listify extends android.app.Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
try {
|
||||
Amplify.addPlugin(new AWSCognitoAuthPlugin());
|
||||
Amplify.configure(getApplicationContext());
|
||||
Log.i("MyAmplifyApp", "Initialized Amplify");
|
||||
} catch (AmplifyException error) {
|
||||
Log.e("MyAmplifyApp", "Could not initialize Amplify", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,23 +1,23 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.Menu;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
|
||||
import android.widget.ImageButton;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.navigation.ui.AppBarConfiguration;
|
||||
import androidx.navigation.ui.NavigationUI;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.widget.ImageButton;
|
||||
import com.amplifyframework.auth.AuthException;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private AppBarConfiguration mAppBarConfiguration;
|
||||
@ -25,6 +25,46 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//------------------------------Auth Testing---------------------------------------------//
|
||||
|
||||
AuthManager authManager = new AuthManager();
|
||||
try {
|
||||
authManager.signIn("merzn@purdue.edu", "Password123");
|
||||
Log.i("Authentication", authManager.getAuthSession().toString());
|
||||
Log.i("Token", authManager.getAuthSession().getUserPoolTokens().getValue().getIdToken());
|
||||
} catch (AuthException e) {
|
||||
Log.i("Authentication", "Login failed. User probably needs to register. Exact error: " + e.getMessage());
|
||||
try {
|
||||
authManager.startSignUp("merzn@purdue.edu", "Password123");
|
||||
authManager.confirmSignUp("######");
|
||||
} catch (AuthException signUpError) {
|
||||
Log.e("Authentication", "SignUp error: " + signUpError.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------//
|
||||
|
||||
//----------------------------------API Testing---------------------------------------------//
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||
} catch (IOException|JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Requestor requestor = new Requestor(this, authManager,configs.getProperty("apiKey"));
|
||||
List testList = new List("IAmATestList");
|
||||
try {
|
||||
requestor.postObject(testList);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------//
|
||||
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
66
Listify/app/src/main/java/com/example/listify/Requestor.java
Normal file
66
Listify/app/src/main/java/com/example/listify/Requestor.java
Normal file
@ -0,0 +1,66 @@
|
||||
package com.example.listify;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.toolbox.JsonObjectRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
import com.google.gson.Gson;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Requestor {
|
||||
|
||||
private final String DEV_BASEURL = "https://datoh7woc9.execute-api.us-east-2.amazonaws.com/Development";
|
||||
|
||||
AuthManager authManager;
|
||||
RequestQueue queue;
|
||||
String apiKey;
|
||||
|
||||
Requestor(Context context, AuthManager authManager, String apiKey) {
|
||||
queue = Volley.newRequestQueue(context);
|
||||
this.authManager = authManager;
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public <T> void getObject(String id, Class<T> classType, Receiver<T> receiver) {
|
||||
String getURL = DEV_BASEURL + "/" + classType.getSimpleName() + "?id=" + id;
|
||||
}
|
||||
|
||||
public void postObject(Object toPost, Response.ErrorListener failureHandler) throws JSONException {
|
||||
String postURL = DEV_BASEURL + "/" + toPost.getClass().getSimpleName();
|
||||
queue.add(buildRequest(postURL, toPost, null, failureHandler));
|
||||
}
|
||||
|
||||
public void postObject(Object toPost) throws JSONException {
|
||||
postObject(toPost, null);
|
||||
}
|
||||
|
||||
private JsonObjectRequest buildRequest(String url, Object toJSONify, Response.Listener<JSONObject> successHandler, Response.ErrorListener failureHandler) throws JSONException {
|
||||
return buildRequest(url, new JSONObject(new Gson().toJson(toJSONify)), successHandler, failureHandler);
|
||||
}
|
||||
|
||||
private JsonObjectRequest buildRequest(String url, JSONObject jsonBody, Response.Listener<JSONObject> successHandler, Response.ErrorListener failureHandler) {
|
||||
return new JsonObjectRequest(url, jsonBody, successHandler, failureHandler) {
|
||||
@Override
|
||||
public Map<String, String> getHeaders() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
System.out.println(authManager.getUserToken());
|
||||
headers.put("Authorization", authManager.getUserToken());
|
||||
headers.put("Content-Type", "application/json");
|
||||
headers.put("X-API-Key", apiKey);
|
||||
return headers;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public class Receiver<T> {
|
||||
public void acceptDelivery(T delivered) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package com.example.listify.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.example.listify.R;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class CodePage extends AppCompatActivity {
|
||||
private Button button1; //Reset password page button
|
||||
private Button button2; //Cancel button
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_code);
|
||||
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(CodePage.this, ResetPasswordPage.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
button2 = (Button) findViewById(R.id.button2);
|
||||
button2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(CodePage.this, LoginPage.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.example.listify.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.example.listify.R;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class ForgotPasswordPage extends AppCompatActivity {
|
||||
private Button button1; //Code page button
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_forgotpswd);
|
||||
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(ForgotPasswordPage.this, CodePage.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -5,21 +5,41 @@ import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.example.listify.MainActivity;
|
||||
import com.example.listify.R;
|
||||
import com.example.listify.MainActivity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class LoginPage extends AppCompatActivity {
|
||||
private Button button;
|
||||
private Button button1; //Sign up page button
|
||||
private Button button2; //Forgot password button
|
||||
private Button button3; //Log in button
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
button = (Button) findViewById(R.id.button3);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(LoginPage.this, SignupPage.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
button2 = (Button) findViewById(R.id.button2);
|
||||
button2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(LoginPage.this, ForgotPasswordPage.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
button3 = (Button) findViewById(R.id.button3);
|
||||
button3.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(LoginPage.this, MainActivity.class);
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package com.example.listify.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.example.listify.R;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class ResetPasswordPage extends AppCompatActivity {
|
||||
private Button button1; //Log in page button
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_resetpswd);
|
||||
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(ResetPasswordPage.this, LoginPage.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -6,22 +6,33 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.example.listify.R;
|
||||
import com.example.listify.MainActivity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class SignupPage extends AppCompatActivity {
|
||||
private Button button;
|
||||
private Button button1; //Log in page button
|
||||
private Button button2; //Sign up button
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_signup);
|
||||
|
||||
button = (Button) findViewById(R.id.button2);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(SignupPage.this, com.example.listify.ui.LoginPage.class);
|
||||
Intent intent = new Intent(SignupPage.this, LoginPage.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
button2 = (Button) findViewById(R.id.button2);
|
||||
button2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(SignupPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
@ -2,16 +2,13 @@ package com.example.listify.ui.home;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
import android.view.LayoutInflater;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
|
||||
import com.example.listify.R;
|
||||
|
||||
|
||||
48
Listify/app/src/main/res/layout/activity_code.xml
Normal file
48
Listify/app/src/main/res/layout/activity_code.xml
Normal file
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="Submit"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextNumber" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="22dp"
|
||||
android:text="Cancel"
|
||||
app:layout_constraintStart_toStartOf="@+id/button1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button1" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextNumber"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="17dp"
|
||||
android:ems="10"
|
||||
android:hint="Code"
|
||||
android:inputType="number"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="31dp"
|
||||
android:layout_marginTop="260dp"
|
||||
android:text="Please enter the 6-digit code from the email sent to you."
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
39
Listify/app/src/main/res/layout/activity_forgotpswd.xml
Normal file
39
Listify/app/src/main/res/layout/activity_forgotpswd.xml
Normal file
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="31dp"
|
||||
android:text="Button"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress2" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextEmailAddress2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="Email"
|
||||
android:inputType="textEmailAddress"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="31dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:text="Please enter your email address."
|
||||
app:layout_constraintBottom_toTopOf="@+id/editTextTextEmailAddress2"
|
||||
app:layout_constraintEnd_toEndOf="@+id/editTextTextEmailAddress2" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -10,54 +10,62 @@
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginTop="53dp"
|
||||
android:text="Log in"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/button2" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPersonName"
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:ems="10"
|
||||
android:hint="Username or email"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView3" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPassword"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:ems="10"
|
||||
android:hint="Password"
|
||||
android:inputType="textPassword"
|
||||
app:layout_constraintStart_toStartOf="@+id/editTextTextPersonName"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:text="Log in"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textView3"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="324dp"
|
||||
android:layout_marginTop="274dp"
|
||||
android:text="New to Listify? Click here to sign up."
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="72dp"
|
||||
android:text="Forgot password? Click here."
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPersonName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="21dp"
|
||||
android:ems="10"
|
||||
android:hint="Username or email"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintStart_toStartOf="@+id/editTextTextPassword"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button1" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPassword"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="18dp"
|
||||
android:ems="10"
|
||||
android:hint="Password"
|
||||
android:inputType="textPassword"
|
||||
app:layout_constraintBottom_toTopOf="@+id/button2"
|
||||
app:layout_constraintStart_toStartOf="@+id/button2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="26dp"
|
||||
android:text="Log in"
|
||||
app:layout_constraintBottom_toTopOf="@+id/button1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
50
Listify/app/src/main/res/layout/activity_resetpswd.xml
Normal file
50
Listify/app/src/main/res/layout/activity_resetpswd.xml
Normal file
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="Button"
|
||||
app:layout_constraintEnd_toEndOf="@+id/editTextTextPassword2"
|
||||
app:layout_constraintStart_toStartOf="@+id/editTextTextPassword2"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword2" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPassword3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="272dp"
|
||||
android:ems="10"
|
||||
android:hint="New password"
|
||||
android:inputType="textPassword"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPassword2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="26dp"
|
||||
android:ems="10"
|
||||
android:hint="Confirm new password"
|
||||
android:inputType="textPassword"
|
||||
app:layout_constraintStart_toStartOf="@+id/editTextTextPassword3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="28dp"
|
||||
android:layout_marginEnd="31dp"
|
||||
android:text="Create a new password"
|
||||
app:layout_constraintBottom_toTopOf="@+id/editTextTextPassword3"
|
||||
app:layout_constraintEnd_toEndOf="@+id/editTextTextPassword3" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -16,18 +16,15 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPersonName"
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="32dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:ems="10"
|
||||
android:hint="Email"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView3" />
|
||||
android:layout_marginStart="18dp"
|
||||
android:layout_marginTop="288dp"
|
||||
android:text="Already have an account? Click here to log in."
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextEmailAddress"
|
||||
@ -51,29 +48,26 @@
|
||||
app:layout_constraintStart_toStartOf="@+id/editTextTextEmailAddress"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPersonName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="28dp"
|
||||
android:ems="10"
|
||||
android:hint="Email"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginEnd="86dp"
|
||||
android:layout_marginLeft="86dp"
|
||||
android:layout_marginRight="86dp"
|
||||
android:layout_marginStart="86dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:text="Sign up"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textView3"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView3"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="@+id/editTextTextPersonName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="324dp"
|
||||
android:text="Already have an account? Click here to log in."
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintBottom_toTopOf="@+id/button1"
|
||||
app:layout_constraintEnd_toEndOf="@+id/button1"
|
||||
app:layout_constraintStart_toStartOf="@+id/button1" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -19,6 +19,7 @@ allprojects {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
|
||||
BIN
Listify/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
Listify/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
@ -1,6 +1,5 @@
|
||||
#Fri Sep 18 14:57:14 EDT 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||
|
||||
53
Listify/gradlew
vendored
Normal file → Executable file
53
Listify/gradlew
vendored
Normal file → Executable file
@ -1,5 +1,21 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
@ -28,7 +44,7 @@ APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
@ -66,6 +82,7 @@ esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
@ -109,10 +126,11 @@ if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
@ -138,19 +156,19 @@ if $cygwin ; then
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@ -159,14 +177,9 @@ save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
43
Listify/gradlew.bat
vendored
43
Listify/gradlew.bat
vendored
@ -1,3 +1,19 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@ -35,7 +54,7 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
@ -45,28 +64,14 @@ echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
55
Tooling/EndpointSetup.sh
Normal file
55
Tooling/EndpointSetup.sh
Normal file
@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
#Base script from: https://github.com/NMerz/DoctorsNote/blob/master/AWS%20Setup/Lambda-GatewayInitialization.sh
|
||||
|
||||
#NOTE: This has been tested and works; however, the apigateway does not properly show as a trigger in AWS's web UI
|
||||
#NOTE2: This assumes that the root Gateway and Lambda role have been set up previously (one-time setup) and their values are set in VarSetup.sh
|
||||
|
||||
echo "Creating a Gateway/Lambda pair."
|
||||
|
||||
REL_SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||
|
||||
source ${REL_SCRIPT_DIR}/VarSetup.sh
|
||||
|
||||
|
||||
RAWLAMBDA=$(aws lambda create-function --function-name ${functionName}${method} --zip-file fileb://${jarPath} --runtime ${LANGUAGE} --role ${LAMBDAROLE} --handler ${functionName}${method} 2>${DEBUGFILE})
|
||||
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Unable to create Lamba" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LAMBDAARN=$(echo $RAWLAMBDA | head -n 3 | tail -n 1 | cut -d \" -f 8)
|
||||
|
||||
echo ${LAMBDAARN} > ${DEBUGFILE}
|
||||
|
||||
RAWRESOURCEID=$(aws apigateway create-resource --rest-api-id ${APIID} --parent-id ${ROOTRESOURCEID} --path-part ${functionName} 2>${DEBUGFILE})
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Unable to create resource." > ${DEBUGFILE}
|
||||
RAWRESOURCEID=$(aws apigateway get-resources --rest-api-id datoh7woc9 --query "items[?pathPart==\`${functionName}\`].{id:id}" | head -n 3 | tail -n 1)
|
||||
if [[ $RAWRESOURCEID == "[]" ]]; then
|
||||
echo "Unable to create or find API Gateway resource." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
RESOURCEID=$(echo ${RAWRESOURCEID} | head -n 2 | tail -n 1 | cut -d \" -f 4)
|
||||
|
||||
echo ${RESOURCEID} > ${DEBUGFILE}
|
||||
|
||||
aws apigateway put-method --rest-api-id ${APIID} --resource-id ${RESOURCEID} --http-method ${method} --authorization-type COGNITO_USER_POOLS --authorizer-id awt4cs --api-key-required > ${DEBUGFILE}
|
||||
|
||||
|
||||
|
||||
aws apigateway put-integration --rest-api-id ${APIID} --resource-id ${RESOURCEID} --http-method ${method} --type AWS --integration-http-method POST --uri arn:aws:apigateway:us-east-2:lambda:path/2015-03-31/functions/${LAMBDAARN}/invocations --request-templates "file://${REL_SCRIPT_DIR}/body_and_auth_mapping.json" --passthrough-behavior NEVER > ${DEBUGFILE}
|
||||
|
||||
aws lambda add-permission --function-name ${functionName}${method} --statement-id ${functionName}API --action lambda:InvokeFunction --principal apigateway.amazonaws.com > ${DEBUGFILE}
|
||||
|
||||
aws apigateway put-method-response --rest-api-id ${APIID} --resource-id ${RESOURCEID} --http-method ${method} --status-code 200 > ${DEBUGFILE}
|
||||
|
||||
aws apigateway put-integration-response --rest-api-id ${APIID} --resource-id ${RESOURCEID} --http-method ${method} --status-code 200 --selection-pattern "" > ${DEBUGFILE}
|
||||
|
||||
aws apigateway create-deployment --rest-api-id ${APIID} --stage-name ${DEPLOYSTAGE} --description "Deployment by creation script for function ${functionName}${method}" > ${DEBUGFILE}
|
||||
|
||||
|
||||
17
Tooling/LambdaUpdate.sh
Normal file
17
Tooling/LambdaUpdate.sh
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
echo "Updating a Lambda."
|
||||
|
||||
REL_SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||
|
||||
source ${REL_SCRIPT_DIR}/VarSetup.sh
|
||||
|
||||
|
||||
aws lambda update-function-code --function-name ${functionName}${method} --zip-file fileb://${jarPath} 1>${DEBUGFILE} 2>${DEBUGFILE}
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Unable to update Lamba" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Update successful."
|
||||
exit 0
|
||||
26
Tooling/VarSetup.sh
Normal file
26
Tooling/VarSetup.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Meant to be source'd from other scripts that need these vars.
|
||||
|
||||
#constants
|
||||
APIID=datoh7woc9 #rest-api-id is tied to the apigateway while resource-id seems tied to the specific url extension
|
||||
ROOTRESOURCEID=6xrzhzidxh #gateway root should have a consistent resource id which will serve as parent for many apis
|
||||
LAMBDAROLE=arn:aws:iam::569815541706:role/LambdaBasic
|
||||
LANGUAGE=java11
|
||||
DEPLOYSTAGE=Development
|
||||
|
||||
DEBUGFILE=/dev/null
|
||||
|
||||
REL_SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||
|
||||
echo -n "Please enter base function name: "
|
||||
read functionName
|
||||
echo -n "Please enter method(GET, POST, etc.): "
|
||||
read method
|
||||
|
||||
jarPath=$(find ${REL_SCRIPT_DIR}/.. -name "${functionName}.jar")
|
||||
if [[ "$jarPath" == "" ]]; then
|
||||
echo "Unable to find file ${functionName}.jar" >&2
|
||||
exit 1
|
||||
fi
|
||||
functionPath=${jarPath%/${functionName}.jar}
|
||||
3
Tooling/body_and_auth_mapping.json
Normal file
3
Tooling/body_and_auth_mapping.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"application/json": "#set($allParams = $input.params())\n{\"body\": $input.json('$'),\"params\" : {\n #foreach($type in $allParams.keySet())\n #set($params = $allParams.get($type))\n \"$type\" : {\n #foreach($paramName in $params.keySet())\n \"$paramName\" : \"$util.escapeJavaScript($params.get($paramName))\"\n #if($foreach.hasNext),#end\n #end\n }\n #if($foreach.hasNext),#end\n #end\n },\"context\" : {\"sub\" : \"$context.authorizer.claims.sub\",\"email\" : \"$context.authorizer.claims.email\"}}"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user