Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
fc841ea4
Commit
fc841ea4
authored
May 28, 2017
by
Sajal Narang
Committed by
GitHub
May 28, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9 from yvsriram/master, close #1
Add LoginActivity and retrieve AuthCode
parents
4e61f1f8
442278dd
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
240 additions
and
1 deletion
+240
-1
.idea/compiler.xml
.idea/compiler.xml
+22
-0
.idea/copyright/profiles_settings.xml
.idea/copyright/profiles_settings.xml
+3
-0
.idea/misc.xml
.idea/misc.xml
+1
-1
.idea/modules.xml
.idea/modules.xml
+1
-0
app/build.gradle
app/build.gradle
+2
-0
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+25
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/LoginActivity.java
.../main/java/in/ac/iitb/gymkhana/iitbapp/LoginActivity.java
+159
-0
app/src/main/res/layout/activity_login.xml
app/src/main/res/layout/activity_login.xml
+27
-0
No files found.
.idea/compiler.xml
0 → 100644
View file @
fc841ea4
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"CompilerConfiguration"
>
<resourceExtensions
/>
<wildcardResourcePatterns>
<entry
name=
"!?*.java"
/>
<entry
name=
"!?*.form"
/>
<entry
name=
"!?*.class"
/>
<entry
name=
"!?*.groovy"
/>
<entry
name=
"!?*.scala"
/>
<entry
name=
"!?*.flex"
/>
<entry
name=
"!?*.kt"
/>
<entry
name=
"!?*.clj"
/>
<entry
name=
"!?*.aj"
/>
</wildcardResourcePatterns>
<annotationProcessing>
<profile
default=
"true"
name=
"Default"
enabled=
"false"
>
<processorPath
useClasspath=
"true"
/>
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
.idea/copyright/profiles_settings.xml
0 → 100644
View file @
fc841ea4
<component
name=
"CopyrightManager"
>
<settings
default=
""
/>
</component>
\ No newline at end of file
.idea/misc.xml
View file @
fc841ea4
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
</value>
</value>
</option>
</option>
</component>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_7"
default=
"true"
project-jdk-name=
"
JDK
"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_7"
default=
"true"
project-jdk-name=
"
1.8
"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
</component>
<component
name=
"ProjectType"
>
<component
name=
"ProjectType"
>
...
...
.idea/modules.xml
View file @
fc841ea4
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
<component
name=
"ProjectModuleManager"
>
<component
name=
"ProjectModuleManager"
>
<modules>
<modules>
<module
fileurl=
"file://$PROJECT_DIR$/IITB-App.iml"
filepath=
"$PROJECT_DIR$/IITB-App.iml"
/>
<module
fileurl=
"file://$PROJECT_DIR$/IITB-App.iml"
filepath=
"$PROJECT_DIR$/IITB-App.iml"
/>
<module
fileurl=
"file://$PROJECT_DIR$/IITBApp.iml"
filepath=
"$PROJECT_DIR$/IITBApp.iml"
/>
<module
fileurl=
"file://D:\IITB-App\IITBApp.iml"
filepath=
"D:\IITB-App\IITBApp.iml"
/>
<module
fileurl=
"file://D:\IITB-App\IITBApp.iml"
filepath=
"D:\IITB-App\IITBApp.iml"
/>
<module
fileurl=
"file://$PROJECT_DIR$/app/app.iml"
filepath=
"$PROJECT_DIR$/app/app.iml"
/>
<module
fileurl=
"file://$PROJECT_DIR$/app/app.iml"
filepath=
"$PROJECT_DIR$/app/app.iml"
/>
</modules>
</modules>
...
...
app/build.gradle
View file @
fc841ea4
...
@@ -5,6 +5,7 @@ android {
...
@@ -5,6 +5,7 @@ android {
buildToolsVersion
"25.0.3"
buildToolsVersion
"25.0.3"
defaultConfig
{
defaultConfig
{
applicationId
"in.ac.iitb.gymkhana.iitbapp"
applicationId
"in.ac.iitb.gymkhana.iitbapp"
manifestPlaceholders
'appAuthRedirectScheme'
:
'https'
minSdkVersion
17
minSdkVersion
17
targetSdkVersion
25
targetSdkVersion
25
versionCode
1
versionCode
1
...
@@ -25,6 +26,7 @@ dependencies {
...
@@ -25,6 +26,7 @@ dependencies {
exclude
group:
'com.android.support'
,
module:
'support-annotations'
exclude
group:
'com.android.support'
,
module:
'support-annotations'
})
})
compile
'com.android.support:appcompat-v7:25.3.1'
compile
'com.android.support:appcompat-v7:25.3.1'
compile
'net.openid:appauth:0.2.0'
testCompile
'junit:junit:4.12'
testCompile
'junit:junit:4.12'
compile
'com.android.support:design:25.3.1'
compile
'com.android.support:design:25.3.1'
compile
'com.android.support.constraint:constraint-layout:1.0.2'
compile
'com.android.support.constraint:constraint-layout:1.0.2'
...
...
app/src/main/AndroidManifest.xml
View file @
fc841ea4
...
@@ -13,6 +13,31 @@
...
@@ -13,6 +13,31 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</intent-filter>
</activity>
</activity>
<activity
android:name=
".LoginActivity"
>
<intent-filter>
<action
android:name=
"HANDLE_AUTHORIZATION_RESPONSE"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=
"net.openid.appauth.RedirectUriReceiverActivity"
>
<intent-filter
android:autoVerify=
"true"
>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<category
android:name=
"android.intent.category.BROWSABLE"
/>
<data
android:host=
"redirecturi"
android:scheme=
"https"
/>
</intent-filter>
</activity>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/LoginActivity.java
0 → 100644
View file @
fc841ea4
package
in.ac.iitb.gymkhana.iitbapp
;
import
android.annotation.TargetApi
;
import
android.app.PendingIntent
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.Toast
;
import
net.openid.appauth.AuthState
;
import
net.openid.appauth.AuthorizationException
;
import
net.openid.appauth.AuthorizationRequest
;
import
net.openid.appauth.AuthorizationResponse
;
import
net.openid.appauth.AuthorizationService
;
import
net.openid.appauth.AuthorizationServiceConfiguration
;
import
net.openid.appauth.TokenResponse
;
import
static
android
.
R
.
attr
.
action
;
public
class
LoginActivity
extends
AppCompatActivity
{
private
static
final
String
TAG
=
"LoginActivity"
;
private
final
String
clientId
=
"pFcDDWtUUfzlAX2ibriV25lm1J2m92O5ynfT4SYk"
;
private
final
String
clientSecret
=
"k56GXiN1qB4Dt7CnTVWjuwLJyWntNulitWOkL7Wddr6JHPiHqIZgSfgUplO6neTqumVr32zA14XgQmkuoC8y6y9jnaQT9tKDsq4jQklRb8MQNQglQ1H4YrmqOwPfaNyO"
;
private
final
Uri
redirectUri
=
Uri
.
parse
(
"https://redirecturi"
);
private
final
Uri
mAuthEndpoint
=
Uri
.
parse
(
"http://gymkhana.iitb.ac.in/sso/oauth/authorize/"
);
private
final
Uri
mTokenEndpoint
=
Uri
.
parse
(
"http://gymkhana.iitb.ac.in/sso/oauth/token/"
);
private
AuthorizationService
mAuthService
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_login
);
mAuthService
=
new
AuthorizationService
(
this
);
Button
ldapLogin
=
(
Button
)
findViewById
(
R
.
id
.
ldap_login
);
ldapLogin
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Log
.
d
(
TAG
,
"Initiating auth"
);
AuthorizationServiceConfiguration
config
=
new
AuthorizationServiceConfiguration
(
mAuthEndpoint
,
mTokenEndpoint
);
makeAuthRequest
(
config
);
}
});
Button
guestLogin
=
(
Button
)
findViewById
(
R
.
id
.
guest_login
);
guestLogin
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
}
});
}
@Override
protected
void
onNewIntent
(
Intent
intent
)
{
checkIntent
(
intent
);
}
private
void
checkIntent
(
@Nullable
Intent
intent
)
{
if
(
intent
!=
null
)
{
Log
.
d
(
TAG
,
"Intent Received"
);
String
action
=
intent
.
getAction
();
switch
(
action
)
{
case
"HANDLE_AUTHORIZATION_RESPONSE"
:
{
handleAuthorizationResponse
(
intent
);
}
break
;
default
:
Log
.
d
(
TAG
,
intent
.
getAction
());
}
}
}
@Override
protected
void
onStart
()
{
super
.
onStart
();
checkIntent
(
getIntent
());
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
Log
.
d
(
TAG
,
"In Resume"
);
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
mAuthService
.
dispose
();
}
private
void
handleAuthorizationResponse
(
@NonNull
Intent
intent
)
{
AuthorizationResponse
response
=
AuthorizationResponse
.
fromIntent
(
intent
);
AuthorizationException
error
=
AuthorizationException
.
fromIntent
(
intent
);
if
(
response
!=
null
)
{
Log
.
d
(
TAG
,
"Received AuthorizationResponse: "
+
"AuthCode: "
+
response
.
authorizationCode
);
Toast
.
makeText
(
this
,
"AuthCode: "
+
response
.
authorizationCode
,
Toast
.
LENGTH_SHORT
)
.
show
();
}
else
{
Log
.
i
(
TAG
,
"Authorization failed: "
+
error
.
getMessage
());
Toast
.
makeText
(
this
,
"Authorization failed"
,
Toast
.
LENGTH_LONG
)
.
show
();
}
}
private
void
makeAuthRequest
(
@NonNull
AuthorizationServiceConfiguration
serviceConfig
)
{
AuthorizationRequest
authRequest
=
new
AuthorizationRequest
.
Builder
(
serviceConfig
,
clientId
,
"code"
,
redirectUri
)
.
setScope
(
"profile"
)
.
build
();
Log
.
d
(
TAG
,
"Making auth request"
);
String
action
=
"HANDLE_AUTHORIZATION_RESPONSE"
;
Intent
postAuthorizationIntent
=
new
Intent
(
action
);
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
this
,
authRequest
.
hashCode
(),
postAuthorizationIntent
,
0
);
mAuthService
.
performAuthorizationRequest
(
authRequest
,
pendingIntent
,
mAuthService
.
createCustomTabsIntentBuilder
()
.
setToolbarColor
(
getCustomTabColor
())
.
build
());
}
//Todo: Change the color of Chrome custom tabs based on app theme color
@TargetApi
(
Build
.
VERSION_CODES
.
M
)
@SuppressWarnings
(
"deprecation"
)
private
int
getCustomTabColor
()
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
return
getColor
(
R
.
color
.
colorPrimaryDark
);
}
else
{
return
getResources
().
getColor
(
R
.
color
.
colorPrimaryDark
);
}
}
}
app/src/main/res/layout/activity_login.xml
0 → 100644
View file @
fc841ea4
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<Button
android:id=
"@+id/guest_login"
android:layout_width=
"wrap_content"
android:layout_height=
"48dp"
android:layout_gravity=
"center"
android:text=
"Guest Login"
/>
<Button
android:id=
"@+id/ldap_login"
android:layout_width=
"wrap_content"
android:layout_height=
"48dp"
android:layout_gravity=
"center"
android:text=
"LDAP login"
/>
</LinearLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment