Skip to content

Commit

Permalink
Merge pull request #64 from personium/develop
Browse files Browse the repository at this point in the history
For 1.5.1 release
  • Loading branch information
shimono authored Sep 2, 2019
2 parents 35d947d + d6cd81f commit 4077fd0
Show file tree
Hide file tree
Showing 15 changed files with 309 additions and 157 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>io.personium</groupId>
<artifactId>personium-lib-common</artifactId>
<packaging>jar</packaging>
<version>1.5.0</version>
<version>1.5.1</version>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ public String getCookieString(String peer, String issuer) {
return AbstractLocalAccessToken.encode(raw, AbstractLocalAccessToken.getIvBytes(issuer));
}

public String[] getScopes() {
return this.scope;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public interface IAccessToken {
* returns the scopes of access token.
* @return array of scope strings
*/
String[] getScopes();
String[] getScope();

/**
* constructs token string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public final class PasswordChangeAccessToken extends AbstractLocalAccessToken im
* @param schema Schema
*/
public PasswordChangeAccessToken(final long issuedAt, final long lifespan, final String issuer,
final String subject, final String schema) {
super(issuedAt, lifespan, issuer, subject, schema, AbstractOAuth2Token.Scope.EMPTY);
final String subject, final String schema, final String[] scope) {
super(issuedAt, lifespan, issuer, subject, schema, scope);
}

/**
Expand All @@ -55,8 +55,8 @@ public PasswordChangeAccessToken(final long issuedAt, final long lifespan, final
* @param schema Schema
*/
public PasswordChangeAccessToken(final long issuedAt, final String issuer, final String subject,
final String schema) {
this(issuedAt, ACCESS_TOKEN_EXPIRES_MILLISECS, issuer, subject, schema);
final String schema, final String[] scope) {
this(issuedAt, ACCESS_TOKEN_EXPIRES_MILLISECS, issuer, subject, schema, scope);
}

public PasswordChangeAccessToken() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public IAccessToken refreshAccessToken(final long issuedAt, final long lifespan,
} else {
// 自分セルローカル払い出し時に払い出されるリフレッシュトークンにはロール入ってないので取得する。
return new TransCellAccessToken(issuedAt, lifespan, this.issuer, cellUrl + "#" + this.getSubject(),
target, roleList, schema);
target, roleList, schema, scope);
}
}

Expand Down
27 changes: 19 additions & 8 deletions src/main/java/io/personium/common/auth/token/Role.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -66,7 +67,7 @@ public Role(URL url) throws MalformedURLException {
}

/**
* コンストラクタ.
* Constructor.
* @param name ロール名.
* @param boxName ロールの属するボックス名.
* @param boxSchema ロールの属するボックスのSchema
Expand All @@ -86,6 +87,16 @@ public Role(final String name, final String boxName, final String boxSchema, fin
public Role(final String name) {
this(name, null, null, null);
}
@Override
public boolean equals(Object obj) {
boolean ret = obj instanceof Role;
Role r = (Role) obj;
ret &= Objects.equals(this.name, r.name);
ret &= Objects.equals(this.boxSchema, r.boxSchema);
ret &= Objects.equals(this.boxName, r.boxName);
ret &= Objects.equals(this.baseUrl, r.baseUrl);
return ret;
}

/**
* スキーマ用ロールリソースのURLを返す.
Expand All @@ -98,21 +109,21 @@ public String schemeCreateUrl(String url) {
if (this.boxName != null) {
boxName2 = this.boxName;
} else {
// 紐付かない場合、デフォルトボックス名を使用する
boxName2 = DEFAULT_BOX_NAME;
// 紐付かない場合、use main box name.
boxName2 = MAIN_BOX_NAME;
}
String url3 = createBaseUrl(url);
return String.format(ROLE_RESOURCE_FORMAT, url3, boxName2, this.name);
}

/**
* ロールクラスURLを返す.
* Returns Role class URL.
* @param url ロールリソースのベースURL
* @return String ロールリソースのURL
* @return String Role resource URL
*/
public String schemeCreateUrlForTranceCellToken(String url) {
String url3 = createBaseUrl(url);
return String.format(ROLE_RESOURCE_FORMAT, url3, DEFAULT_BOX_NAME, this.name);
return String.format(ROLE_RESOURCE_FORMAT, url3, MAIN_BOX_NAME, this.name);
}

/**
Expand Down Expand Up @@ -147,7 +158,7 @@ public String localCreateUrl(String url) {
boxName2 = this.boxName;
} else {
// 紐付かない場合、デフォルトボックス名を使用する
boxName2 = DEFAULT_BOX_NAME;
boxName2 = MAIN_BOX_NAME;
}
// 連結でスラッシュつけてるので、URLの最後がスラッシュだったら消す。
String url3 = url.replaceFirst("/$", "");
Expand Down Expand Up @@ -205,6 +216,6 @@ public String getBaseUrl() {
/**
* デフォルトボックス名.
*/
public static final String DEFAULT_BOX_NAME = "__";
public static final String MAIN_BOX_NAME = "__";

}
Loading

0 comments on commit 4077fd0

Please sign in to comment.