Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Commit d1d52df

Browse files
committed
Initial implementation of Okta User object
1 parent a83e245 commit d1d52df

File tree

10 files changed

+630
-0
lines changed

10 files changed

+630
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.stormpath.sdk.okta;
2+
3+
4+
import java.net.URL;
5+
6+
/**
7+
* HAL based link representation.
8+
*/
9+
public class Link {
10+
11+
private URL href;
12+
private String method;
13+
14+
public URL getHref() {
15+
return href;
16+
}
17+
18+
public Link setHref(URL href) {
19+
this.href = href;
20+
return this;
21+
}
22+
23+
public String getMethod() {
24+
return method;
25+
}
26+
27+
public Link setMethod(String method) {
28+
this.method = method;
29+
return this;
30+
}
31+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package com.stormpath.sdk.okta;
2+
3+
import com.stormpath.sdk.resource.Deletable;
4+
import com.stormpath.sdk.resource.Saveable;
5+
6+
import java.util.Map;
7+
8+
/**
9+
* Okta User Profile wrapper
10+
*/
11+
public interface Profile extends Map<String, Object> {
12+
13+
14+
String getLogin();
15+
void setLogin(String login);
16+
17+
String getFirstName();
18+
void setFirstName(String firstName);
19+
20+
21+
String getLastName();
22+
void setLastName(String lastName);
23+
24+
String getMiddleName();
25+
void setMiddleName(String middleName);
26+
27+
String getEmail();
28+
void setEmail(String email);
29+
30+
String getDisplayName();
31+
void setDisplayName(String displayName);
32+
33+
/*
34+
35+
// Other Okta profile attributes not yet added above.
36+
37+
Base
38+
Honorific prefix honorificPrefix
39+
string
40+
Base
41+
Honorific suffix honorificSuffix
42+
string
43+
Base
44+
Title title
45+
string
46+
47+
Base
48+
Nickname nickName
49+
string
50+
Base
51+
Profile Url profileUrl
52+
string
53+
Base
54+
Secondary email secondEmail
55+
string
56+
Base
57+
Mobile phone mobilePhone
58+
string
59+
Base
60+
Primary phone primaryPhone
61+
string
62+
Base
63+
Street address streetAddress
64+
string
65+
Base
66+
City city
67+
string
68+
Base
69+
State state
70+
string
71+
Base
72+
Zip code zipCode
73+
string
74+
Base
75+
Country code countryCode
76+
string
77+
Base
78+
Postal Address postalAddress
79+
string
80+
Base
81+
Preferred language preferredLanguage
82+
string
83+
Base
84+
Locale locale
85+
string
86+
Base
87+
Time zone timezone
88+
string
89+
Base
90+
User type userType
91+
string
92+
Base
93+
Employee number employeeNumber
94+
string
95+
Base
96+
Cost center costCenter
97+
string
98+
Base
99+
Organization organization
100+
string
101+
Base
102+
Division division
103+
string
104+
Base
105+
Department department
106+
string
107+
Base
108+
ManagerId managerId
109+
string
110+
Base
111+
Manager manager
112+
string
113+
Base
114+
*/
115+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.stormpath.sdk.okta;
2+
3+
import java.util.Date;
4+
import java.util.Map;
5+
6+
/**
7+
* User object mapped into the Okta API.
8+
*/
9+
public interface User {
10+
11+
String getId();
12+
User setId(String string);
13+
14+
// "activated": null, ????
15+
16+
UserStatus getStatus();
17+
User setStatus(UserStatus userStatus);
18+
19+
Date getStatusChanged();
20+
User setStatusChanged(Date statusChangedDate);
21+
22+
Date getCreated();
23+
User setCreated(Date createdDate);
24+
25+
Date getLastLogin();
26+
User setLastLogin(Date lastLoginDate);
27+
28+
Date getLastUpdated();
29+
User setLastUpdated(Date lastUpdatedDate);
30+
31+
Date getPasswordChanged();
32+
User setPasswordChanged(Date passwordChangedDate);
33+
34+
Profile getProfile();
35+
User setProfile(Profile profile);
36+
37+
Map<String, Link> getLinks();
38+
User setLinks(Map<String, Link> links);
39+
40+
Map<String, Object> getCredentials();
41+
User setCredentials(Map<String, Object> credentials);
42+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.stormpath.sdk.okta;
2+
3+
/**
4+
* An {@code UserStatus} represents the various states a user may be in.
5+
*/
6+
public enum UserStatus {
7+
8+
STAGED,
9+
10+
PROVISIONED,
11+
12+
ACTIVE,
13+
14+
RECOVERY,
15+
16+
PASSWORD_EXPIRED,
17+
18+
LOCKED_OUT,
19+
20+
SUSPENDED,
21+
22+
DEPROVISIONED
23+
}

impl/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@
7272
<artifactId>snakeyaml</artifactId>
7373
<optional>true</optional>
7474
</dependency>
75+
76+
<dependency>
77+
<groupId>org.hamcrest</groupId>
78+
<artifactId>java-hamcrest</artifactId>
79+
</dependency>
7580
</dependencies>
7681

7782
<build>
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
package com.stormpath.sdk.impl.okta;
2+
3+
import com.stormpath.sdk.impl.application.ConfigurableProperty;
4+
import com.stormpath.sdk.impl.resource.AbstractPropertyRetriever;
5+
import com.stormpath.sdk.lang.Objects;
6+
import com.stormpath.sdk.okta.Profile;
7+
import java.util.Collection;
8+
import java.util.Map;
9+
import java.util.Set;
10+
11+
/**
12+
*
13+
*/
14+
public class DefaultProfile extends ConfigurableProperty implements Profile {
15+
16+
private static final String LOGIN = "login";
17+
private static final String FIRST_NAME = "firstName";
18+
private static final String LAST_NAME = "lastName";
19+
private static final String MIDDLE_NAME = "middleName";
20+
private static final String EMAIL = "email";
21+
private static final String DISPLAY_NAME = "displayName";
22+
23+
public DefaultProfile(String name, Map<String, Object> properties, AbstractPropertyRetriever parent) {
24+
super(name, properties, parent);
25+
}
26+
27+
@Override
28+
public String getLogin() {
29+
return Objects.nullSafeToString(get(LOGIN));
30+
}
31+
32+
@Override
33+
public void setLogin(String login) {
34+
put(LOGIN, login);
35+
}
36+
37+
@Override
38+
public String getFirstName() {
39+
return Objects.nullSafeToString(get(FIRST_NAME));
40+
}
41+
42+
@Override
43+
public void setFirstName(String firstName) {
44+
put(FIRST_NAME, firstName);
45+
}
46+
47+
@Override
48+
public String getLastName() {
49+
return Objects.nullSafeToString(get(LAST_NAME));
50+
}
51+
52+
@Override
53+
public void setLastName(String lastName) {
54+
put(LAST_NAME, lastName);
55+
}
56+
57+
@Override
58+
public String getMiddleName() {
59+
return Objects.nullSafeToString(get(MIDDLE_NAME));
60+
}
61+
62+
@Override
63+
public void setMiddleName(String middleName) {
64+
put(MIDDLE_NAME, middleName);
65+
}
66+
67+
@Override
68+
public String getEmail() {
69+
return Objects.nullSafeToString(get(EMAIL));
70+
}
71+
72+
@Override
73+
public void setEmail(String email) {
74+
put(EMAIL, email);
75+
}
76+
77+
@Override
78+
public String getDisplayName() {
79+
return Objects.nullSafeToString(get(DISPLAY_NAME));
80+
}
81+
82+
@Override
83+
public void setDisplayName(String displayName) {
84+
put(DISPLAY_NAME, displayName);
85+
}
86+
87+
88+
89+
@Override
90+
public int size() {
91+
return properties.size();
92+
}
93+
94+
@Override
95+
public boolean isEmpty() {
96+
return properties.isEmpty();
97+
}
98+
99+
@Override
100+
public boolean containsKey(Object key) {
101+
return properties.containsKey(key);
102+
}
103+
104+
@Override
105+
public boolean containsValue(Object value) {
106+
return properties.containsValue(value);
107+
}
108+
109+
@Override
110+
public Object get(Object key) {
111+
return properties.get(key);
112+
}
113+
114+
@Override
115+
public Object put(String key, Object value) {
116+
return properties.put(key, value);
117+
}
118+
119+
@Override
120+
public Object remove(Object key) {
121+
return properties.remove(key);
122+
}
123+
124+
@Override
125+
public void putAll(Map<? extends String, ?> m) {
126+
properties.putAll(m);
127+
}
128+
129+
@Override
130+
public void clear() {
131+
properties.clear();
132+
}
133+
134+
@Override
135+
public Set<String> keySet() {
136+
return properties.keySet();
137+
}
138+
139+
@Override
140+
public Collection<Object> values() {
141+
return properties.values();
142+
}
143+
144+
@Override
145+
public Set<Entry<String, Object>> entrySet() {
146+
return properties.entrySet();
147+
}
148+
149+
}

0 commit comments

Comments
 (0)