mvn archetype:generate "-DarchetypeGroupId=com.sap.cloud.sdk.archetypes" "-DarchetypeArtifactId=scp-cf-tomee" "-DarchetypeVersion=RELEASE"# exclude xsuaa folder
/xsuaa{
"xsappname": "rest-oauth",
"tenant-mode": "dedicated",
"scopes": [
{
"name": "$XSAPPNAME.Display",
"description": "display"
}
],
"role-templates": [
{
"name": "Viewer",
"description": "Required to view things in our solution",
"scope-references" : [
"$XSAPPNAME.Display"
]
}
]
}cf create-service xsuaa application my-xsuaa -c xs-security.json <login-config>
<auth-method>XSUAA</auth-method>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>Baseline Security</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>Display</role-name>
</security-role>@ServletSecurity(@HttpConstraint(rolesAllowed = { "Display" }))
package com.sap.cloud.sdk;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.annotation.HttpConstraint;
import javax.servlet.annotation.ServletSecurity;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/hello")
@ServletSecurity(@HttpConstraint(rolesAllowed = { "Display" }))
public class HelloWorldServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(HelloWorldServlet.class);
@Override
protected void doGet( final HttpServletRequest request, final HttpServletResponse response )
throws IOException
{
logger.info("I am running!");
response.getWriter().write("Hello World!");
}
}
# from project root directory
mvn clean install---
applications:
- name: rest-oauth
memory: 1024M
timeout: 300
random-route: true
path: application/target/rest-oauth-application.war
buildpacks:
- sap_java_buildpack
env:
TARGET_RUNTIME: tomee7
SET_LOGGING_LEVEL: '{ROOT: INFO, com.sap.cloud.sdk: INFO}'
JBP_CONFIG_SAPJVM_MEMORY_SIZES: 'metaspace:128m..'
services:
# - my-application-logs
- my-xsuaa
# - my-destination
# - my-connectivity
cf push
| 項目 | 設定値 |
| エンドポイント | XSUAAの"url"の値 + /oauth/token |
| HTTP メソッド | POST |
| BodyのKey Value(grant_type) | 固定値"password" |
| BodyのKey Value(username) | ロール定義で割り当てたアカウントのメールアドレス |
| BodyのKey Value(password) | ロール定義で割り当てたアカウントのパスワード |
| BodyのKey Value(client_id) | XSUAAの"clientid"の値 |
| BodyのKey Value(client_secret) | XSUAAの"clientsecret"の値 |
| BodyのKey Value(response_type) | 固定値"token" |

You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 59 | |
| 56 | |
| 43 | |
| 36 | |
| 29 | |
| 24 | |
| 23 | |
| 22 | |
| 22 | |
| 19 |