Skip to content

Commit eacde5e

Browse files
committed
initial commit
1 parent 7a88356 commit eacde5e

File tree

13 files changed

+3127
-0
lines changed

13 files changed

+3127
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
<attribute name="optional" value="true"/>
13+
</attributes>
14+
</classpathentry>
15+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
16+
<attributes>
17+
<attribute name="optional" value="true"/>
18+
<attribute name="maven.pomderived" value="true"/>
19+
<attribute name="test" value="true"/>
20+
</attributes>
21+
</classpathentry>
22+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
23+
<attributes>
24+
<attribute name="maven.pomderived" value="true"/>
25+
<attribute name="test" value="true"/>
26+
<attribute name="optional" value="true"/>
27+
</attributes>
28+
</classpathentry>
29+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
30+
<attributes>
31+
<attribute name="maven.pomderived" value="true"/>
32+
</attributes>
33+
</classpathentry>
34+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
35+
<attributes>
36+
<attribute name="maven.pomderived" value="true"/>
37+
</attributes>
38+
</classpathentry>
39+
<classpathentry kind="output" path="target/classes"/>
40+
</classpath>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>oci-java-sdk-simple-wrappers</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/main/resources=UTF-8
4+
encoding//src/test/java=UTF-8
5+
encoding//src/test/resources=UTF-8
6+
encoding/<project>=UTF-8
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
3+
org.eclipse.jdt.core.compiler.compliance=17
4+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
5+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
6+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
7+
org.eclipse.jdt.core.compiler.release=disabled
8+
org.eclipse.jdt.core.compiler.source=17
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<!-- Copyright (c) 2023 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE. -->
36+
37+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
38+
<modelVersion>4.0.0</modelVersion>
39+
<groupId>com.oracle.timg.demo</groupId>
40+
<artifactId>oci-java-sdk-simple-wrappers</artifactId>
41+
<name>ocicore</name>
42+
<version>1.0.0</version>
43+
<properties>
44+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
45+
<version.ocisdk>3.17.0</version.ocisdk>
46+
<version.lombok>1.18.28</version.lombok>
47+
<version.slf4j>2.0.7</version.slf4j>
48+
<maven.compiler.source>17</maven.compiler.source>
49+
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
50+
</properties>
51+
<dependencyManagement>
52+
<dependencies>
53+
<dependency>
54+
<groupId>com.oracle.oci.sdk</groupId>
55+
<artifactId>oci-java-sdk-bom</artifactId>
56+
<version>${version.ocisdk}</version>
57+
<type>pom</type>
58+
<scope>import</scope>
59+
</dependency>
60+
</dependencies>
61+
</dependencyManagement>
62+
<dependencies>
63+
<dependency>
64+
<groupId>com.oracle.oci.sdk</groupId>
65+
<artifactId>oci-java-sdk-core</artifactId>
66+
</dependency>
67+
<!-- A http client isn't included as standard, so you need to specify the one to use -->
68+
<dependency>
69+
<groupId>com.oracle.oci.sdk</groupId>
70+
<artifactId>oci-java-sdk-common-httpclient-jersey3</artifactId>
71+
</dependency>
72+
<dependency>
73+
<groupId>com.oracle.oci.sdk</groupId>
74+
<artifactId>oci-java-sdk-streaming</artifactId>
75+
</dependency>
76+
<dependency>
77+
<groupId>com.oracle.oci.sdk</groupId>
78+
<artifactId>oci-java-sdk-objectstorage</artifactId>
79+
</dependency>
80+
<dependency>
81+
<groupId>com.oracle.oci.sdk</groupId>
82+
<artifactId>oci-java-sdk-identity</artifactId>
83+
</dependency>
84+
<!-- Lombok does the auto method creation, used for the log stuff -->
85+
<dependency>
86+
<groupId>org.projectlombok</groupId>
87+
<artifactId>lombok</artifactId>
88+
<version>${version.lombok}</version>
89+
<scope>compile</scope>
90+
</dependency>
91+
<!-- SLF4J is a logging facade that let's us change the actual logger used
92+
under the covers without changing our code, slf4j-jdk14 is for output to
93+
the standard Java logging utilities. By making the dependency declaration
94+
below Maven will bring in the core SLF4J jar files, and also the SLJ4J to
95+
java.util.logging binding -->
96+
<dependency>
97+
<groupId>org.slf4j</groupId>
98+
<artifactId>slf4j-jdk14</artifactId>
99+
<version>${version.slf4j}</version>
100+
</dependency>
101+
</dependencies>
102+
</project>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*Copyright (c) 2023 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
36+
*/
37+
38+
package com.oracle.timg.oci.authentication;
39+
40+
import java.io.IOException;
41+
42+
import com.oracle.bmc.auth.AuthenticationDetailsProvider;
43+
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider;
44+
45+
import lombok.Getter;
46+
import lombok.NonNull;
47+
import lombok.Setter;
48+
49+
/**
50+
* This class provides a wrapper round the OCI authentication mechanisms
51+
*/
52+
53+
public class AuthenticationProcessor {
54+
55+
private final ConfigFileAuthenticationDetailsProvider provider;
56+
@Getter
57+
@Setter
58+
private String regionName;
59+
@Getter
60+
private String configFileRegionName;
61+
62+
/**
63+
* Creates a processor looking for the specific configuration section name in
64+
* the .oci config file using the region specified in that section
65+
*
66+
* @param providerName - must not be null
67+
* @throws IllegalArgumentException
68+
* @throws IOException
69+
*/
70+
public AuthenticationProcessor(@NonNull String providerName) throws IllegalArgumentException, IOException {
71+
this(providerName, null);
72+
}
73+
74+
/**
75+
* Creates a processor looking for the specific configuration section name in
76+
* the .oci config file using the region specified
77+
*
78+
* @param providerName - must not be null
79+
* @prram regionName - if null will use the default region in the confguration
80+
* file.
81+
* @throws IllegalArgumentException
82+
* @throws IOException
83+
*/
84+
public AuthenticationProcessor(@NonNull String providerName, String regionName)
85+
throws IllegalArgumentException, IOException {
86+
// get and save the provider away
87+
provider = new ConfigFileAuthenticationDetailsProvider(providerName);
88+
if (regionName != null) {
89+
this.regionName = regionName;
90+
} else {
91+
this.regionName = provider.getRegion().getRegionId();
92+
}
93+
}
94+
95+
/**
96+
* Provides a way to get the the underlying provider form the oci sdk, used for
97+
* tasks that this class does not support
98+
*
99+
* @return
100+
* @throws IllegalArgumentException
101+
*/
102+
public AuthenticationDetailsProvider getProvider() throws IllegalArgumentException {
103+
return provider;
104+
}
105+
106+
/**
107+
* way to get the tenancy OCID - needed for the root compartment amongst other
108+
* things
109+
*
110+
* @return
111+
*/
112+
public String getTenancyOCID() {
113+
return provider.getTenantId();
114+
}
115+
}

0 commit comments

Comments
 (0)