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

Initial implementation of Okta User object #1310

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions api/src/main/java/com/stormpath/sdk/okta/Link.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.stormpath.sdk.okta;


import java.net.URL;

/**
* HAL based link representation.
*/
public class Link {

private URL href;
private String method;

public URL getHref() {
return href;
}

public Link setHref(URL href) {
this.href = href;
return this;
}

public String getMethod() {
return method;
}

public Link setMethod(String method) {
this.method = method;
return this;
}
}
115 changes: 115 additions & 0 deletions api/src/main/java/com/stormpath/sdk/okta/Profile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package com.stormpath.sdk.okta;

import com.stormpath.sdk.resource.Deletable;
import com.stormpath.sdk.resource.Saveable;

import java.util.Map;

/**
* Okta User Profile wrapper
*/
public interface Profile extends Map<String, Object> {


String getLogin();
void setLogin(String login);

String getFirstName();
void setFirstName(String firstName);


String getLastName();
void setLastName(String lastName);

String getMiddleName();
void setMiddleName(String middleName);

String getEmail();
void setEmail(String email);

String getDisplayName();
void setDisplayName(String displayName);

/*

// Other Okta profile attributes not yet added above.

Base
Honorific prefix honorificPrefix
string
Base
Honorific suffix honorificSuffix
string
Base
Title title
string

Base
Nickname nickName
string
Base
Profile Url profileUrl
string
Base
Secondary email secondEmail
string
Base
Mobile phone mobilePhone
string
Base
Primary phone primaryPhone
string
Base
Street address streetAddress
string
Base
City city
string
Base
State state
string
Base
Zip code zipCode
string
Base
Country code countryCode
string
Base
Postal Address postalAddress
string
Base
Preferred language preferredLanguage
string
Base
Locale locale
string
Base
Time zone timezone
string
Base
User type userType
string
Base
Employee number employeeNumber
string
Base
Cost center costCenter
string
Base
Organization organization
string
Base
Division division
string
Base
Department department
string
Base
ManagerId managerId
string
Base
Manager manager
string
Base
*/
}
42 changes: 42 additions & 0 deletions api/src/main/java/com/stormpath/sdk/okta/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.stormpath.sdk.okta;

import java.util.Date;
import java.util.Map;

/**
* User object mapped into the Okta API.
*/
public interface User {

String getId();
User setId(String string);

// "activated": null, ????

UserStatus getStatus();
User setStatus(UserStatus userStatus);

Date getStatusChanged();
User setStatusChanged(Date statusChangedDate);

Date getCreated();
User setCreated(Date createdDate);

Date getLastLogin();
User setLastLogin(Date lastLoginDate);

Date getLastUpdated();
User setLastUpdated(Date lastUpdatedDate);

Date getPasswordChanged();
User setPasswordChanged(Date passwordChangedDate);

Profile getProfile();
User setProfile(Profile profile);

Map<String, Link> getLinks();
User setLinks(Map<String, Link> links);

Map<String, Object> getCredentials();
User setCredentials(Map<String, Object> credentials);
}
23 changes: 23 additions & 0 deletions api/src/main/java/com/stormpath/sdk/okta/UserStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.stormpath.sdk.okta;

/**
* An {@code UserStatus} represents the various states a user may be in.
*/
public enum UserStatus {

STAGED,

PROVISIONED,

ACTIVE,

RECOVERY,

PASSWORD_EXPIRED,

LOCKED_OUT,

SUSPENDED,

DEPROVISIONED
}
5 changes: 5 additions & 0 deletions impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
<artifactId>snakeyaml</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
149 changes: 149 additions & 0 deletions impl/src/main/java/com/stormpath/sdk/impl/okta/DefaultProfile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package com.stormpath.sdk.impl.okta;

import com.stormpath.sdk.impl.application.ConfigurableProperty;
import com.stormpath.sdk.impl.resource.AbstractPropertyRetriever;
import com.stormpath.sdk.lang.Objects;
import com.stormpath.sdk.okta.Profile;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
*
*/
public class DefaultProfile extends ConfigurableProperty implements Profile {

private static final String LOGIN = "login";
private static final String FIRST_NAME = "firstName";
private static final String LAST_NAME = "lastName";
private static final String MIDDLE_NAME = "middleName";
private static final String EMAIL = "email";
private static final String DISPLAY_NAME = "displayName";

public DefaultProfile(String name, Map<String, Object> properties, AbstractPropertyRetriever parent) {
super(name, properties, parent);
}

@Override
public String getLogin() {
return Objects.nullSafeToString(get(LOGIN));
}

@Override
public void setLogin(String login) {
put(LOGIN, login);
}

@Override
public String getFirstName() {
return Objects.nullSafeToString(get(FIRST_NAME));
}

@Override
public void setFirstName(String firstName) {
put(FIRST_NAME, firstName);
}

@Override
public String getLastName() {
return Objects.nullSafeToString(get(LAST_NAME));
}

@Override
public void setLastName(String lastName) {
put(LAST_NAME, lastName);
}

@Override
public String getMiddleName() {
return Objects.nullSafeToString(get(MIDDLE_NAME));
}

@Override
public void setMiddleName(String middleName) {
put(MIDDLE_NAME, middleName);
}

@Override
public String getEmail() {
return Objects.nullSafeToString(get(EMAIL));
}

@Override
public void setEmail(String email) {
put(EMAIL, email);
}

@Override
public String getDisplayName() {
return Objects.nullSafeToString(get(DISPLAY_NAME));
}

@Override
public void setDisplayName(String displayName) {
put(DISPLAY_NAME, displayName);
}



@Override
public int size() {
return properties.size();
}

@Override
public boolean isEmpty() {
return properties.isEmpty();
}

@Override
public boolean containsKey(Object key) {
return properties.containsKey(key);
}

@Override
public boolean containsValue(Object value) {
return properties.containsValue(value);
}

@Override
public Object get(Object key) {
return properties.get(key);
}

@Override
public Object put(String key, Object value) {
return properties.put(key, value);
}

@Override
public Object remove(Object key) {
return properties.remove(key);
}

@Override
public void putAll(Map<? extends String, ?> m) {
properties.putAll(m);
}

@Override
public void clear() {
properties.clear();
}

@Override
public Set<String> keySet() {
return properties.keySet();
}

@Override
public Collection<Object> values() {
return properties.values();
}

@Override
public Set<Entry<String, Object>> entrySet() {
return properties.entrySet();
}

}
Loading