SSOLoginModule.java
2.33 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.annotation.Nonnull
* javax.jcr.Credentials
* javax.jcr.SimpleCredentials
* org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule
* org.apache.jackrabbit.oak.spi.security.authentication.PreAuthenticatedLogin
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.granite.auth.sso.impl;
import com.adobe.granite.auth.sso.impl.SSOCredentials;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.jcr.Credentials;
import javax.jcr.SimpleCredentials;
import javax.security.auth.login.LoginException;
import org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule;
import org.apache.jackrabbit.oak.spi.security.authentication.PreAuthenticatedLogin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class SSOLoginModule
extends AbstractLoginModule {
private static final Logger log = LoggerFactory.getLogger(SSOLoginModule.class);
private static final Set<Class> SUPPORTED_CREDENTIALS = Collections.singleton(SSOCredentials.class);
private String userId;
@Nonnull
protected Set<Class> getSupportedCredentials() {
return SUPPORTED_CREDENTIALS;
}
public boolean login() throws LoginException {
Credentials credentials = this.getCredentials();
if (credentials instanceof SSOCredentials) {
this.userId = ((SSOCredentials)credentials).getUserId();
if (this.userId == null) {
log.debug("Could not extract userId/credentials");
} else {
this.sharedState.put(SHARED_KEY_PRE_AUTH_LOGIN, new PreAuthenticatedLogin(this.userId));
this.sharedState.put("org.apache.jackrabbit.credentials", new SimpleCredentials(this.userId, new char[0]));
this.sharedState.put("javax.security.auth.login.name", this.userId);
log.debug("login succeeded with trusted user: {}", (Object)this.userId);
}
}
return false;
}
public boolean commit() throws LoginException {
if (this.userId == null) {
this.clearState();
}
return false;
}
protected void clearState() {
this.userId = null;
super.clearState();
}
}